public override string Download(RemoteMovie remoteMovie) { var url = remoteMovie.Release.DownloadUrl; var title = remoteMovie.Release.Title; // We don't have full seasons in movies. //if (remoteMovie.ParsedEpisodeInfo.FullSeason) //{ // throw new NotSupportedException("Full season releases are not supported with Pneumatic."); //} title = FileNameBuilder.CleanFileName(title); //Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC) var nzbFile = Path.Combine(Settings.NzbFolder, title + ".nzb"); _logger.Debug("Downloading NZB from: {0} to: {1}", url, nzbFile); _httpClient.DownloadFile(url, nzbFile); _logger.Debug("NZB Download succeeded, saved to: {0}", nzbFile); var strmFile = WriteStrmFile(title, nzbFile); return(GetDownloadClientId(strmFile)); }
public override IEnumerable <DownloadClientItem> GetItems() { foreach (var file in _diskProvider.GetFiles(Settings.StrmFolder, SearchOption.TopDirectoryOnly)) { if (Path.GetExtension(file) != ".strm") { continue; } var title = FileNameBuilder.CleanFileName(Path.GetFileName(file)); var historyItem = new DownloadClientItem { DownloadClient = Definition.Name, DownloadId = GetDownloadClientId(file), Title = title, TotalSize = _diskProvider.GetFileSize(file), OutputPath = new OsPath(file) }; if (_diskProvider.IsFileLocked(file)) { historyItem.Status = DownloadItemStatus.Downloading; } else { historyItem.Status = DownloadItemStatus.Completed; } yield return(historyItem); } }
public override string Download(RemoteAlbum remoteAlbum) { var url = remoteAlbum.Release.DownloadUrl; var title = remoteAlbum.Release.Title; if (remoteAlbum.ParsedAlbumInfo.Discography) { throw new NotSupportedException("Discography releases are not supported with Pneumatic."); } title = FileNameBuilder.CleanFileName(title); //Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC) var nzbFile = Path.Combine(Settings.NzbFolder, title + ".nzb"); _logger.Debug("Downloading NZB from: {0} to: {1}", url, nzbFile); _httpClient.DownloadFile(url, nzbFile); _logger.Debug("NZB Download succeeded, saved to: {0}", nzbFile); var strmFile = WriteStrmFile(title, nzbFile); return(GetDownloadClientId(strmFile)); }
public override string Download(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var filename = FileNameBuilder.CleanFileName(remoteEpisode.Release.Title) + ".nzb"; byte[] nzbData; try { nzbData = _httpClient.Get(new HttpRequest(url)).ResponseData; _logger.Debug("Downloaded nzb for episode '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, nzbData.Length, url); } catch (HttpException ex) { _logger.Error(ex, "Downloading nzb for episode '{0}' failed ({1})", remoteEpisode.Release.Title, url); throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); } catch (WebException ex) { _logger.Error(ex, "Downloading nzb for episode '{0}' failed ({1})", remoteEpisode.Release.Title, url); throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); } _logger.Info("Adding report [{0}] to the queue.", remoteEpisode.Release.Title); return(AddFromNzbFile(remoteEpisode, filename, nzbData)); }
private string DownloadFromWebUrl(RemoteEpisode remoteEpisode, String torrentUrl) { Byte[] torrentFile = null; try { var request = new HttpRequest(torrentUrl); request.Headers.Accept = "application/x-bittorrent"; request.AllowAutoRedirect = false; var response = _httpClient.Get(request); if (response.StatusCode == HttpStatusCode.SeeOther || response.StatusCode == HttpStatusCode.Found) { var locationHeader = (string)response.Headers.GetValueOrDefault("Location", null); _logger.Trace("Torrent request is being redirected to: {0}", locationHeader); if (locationHeader != null) { if (locationHeader.StartsWith("magnet:")) { return(DownloadFromMagnetUrl(remoteEpisode, locationHeader)); } return(DownloadFromWebUrl(remoteEpisode, locationHeader)); } throw new WebException("Remote website tried to redirect without providing a location."); } torrentFile = response.ResponseData; } catch (WebException ex) { _logger.ErrorException(String.Format("Downloading torrentfile for episode '{0}' failed ({1})", remoteEpisode.Release.Title, torrentUrl), ex); throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading torrent failed", ex); } var filename = String.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteEpisode.Release.Title)); var hash = _torrentFileInfoReader.GetHashFromTorrentFile(torrentFile); var actualHash = AddFromTorrentFile(remoteEpisode, hash, filename, torrentFile); if (hash != actualHash) { _logger.Warn( "{0} did not return the expected InfoHash for '{1}', NzbDrone could potential lose track of the download in progress.", Definition.Implementation, remoteEpisode.Release.DownloadUrl); } return(actualHash); }
public override string Download(RemoteBook remoteBook) { var url = remoteBook.Release.DownloadUrl; var filename = FileNameBuilder.CleanFileName(remoteBook.Release.Title) + ".nzb"; byte[] nzbData; try { var request = new HttpRequest(url); request.RateLimitKey = remoteBook?.Release?.IndexerId.ToString(); // TODO: Look into moving download request handling to indexer if (remoteBook.Release.BasicAuthString.IsNotNullOrWhiteSpace()) { request.Headers.Set("Authorization", "Basic " + remoteBook.Release.BasicAuthString); } nzbData = _httpClient.Get(request).ResponseData; _logger.Debug("Downloaded nzb for release '{0}' finished ({1} bytes from {2})", remoteBook.Release.Title, nzbData.Length, url); } catch (HttpException ex) { if (ex.Response.StatusCode == HttpStatusCode.NotFound) { _logger.Error(ex, "Downloading nzb file for book '{0}' failed since it no longer exists ({1})", remoteBook.Release.Title, url); throw new ReleaseUnavailableException(remoteBook.Release, "Downloading torrent failed", ex); } if ((int)ex.Response.StatusCode == 429) { _logger.Error("API Grab Limit reached for {0}", url); } else { _logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteBook.Release.Title, url); } throw new ReleaseDownloadException(remoteBook.Release, "Downloading nzb failed", ex); } catch (WebException ex) { _logger.Error(ex, "Downloading nzb for release '{0}' failed ({1})", remoteBook.Release.Title, url); throw new ReleaseDownloadException(remoteBook.Release, "Downloading nzb failed", ex); } _nzbValidationService.Validate(filename, nzbData); _logger.Info("Adding report [{0}] to the queue.", remoteBook.Release.Title); return(AddFromNzbFile(remoteBook, filename, nzbData)); }
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) { var pageableRequests = new IndexerPageableRequestChain(); if (searchCriteria?.SceneTitles != null) { searchCriteria.SceneTitles.ForEach(sceneTitle => pageableRequests.Add(GetRequest(FileNameBuilder.CleanFileName(sceneTitle)))); } return(pageableRequests); }
public override string Download(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var title = remoteEpisode.Release.Title; title = FileNameBuilder.CleanFileName(title); var filename = Path.Combine(Settings.TorrentFolder, String.Format("{0}.torrent", title)); _logger.Debug("Downloading torrent from: {0} to: {1}", url, filename); _httpClient.DownloadFile(url, filename); _logger.Debug("Torrent Download succeeded, saved to: {0}", filename); return(null); }
public override string Download(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var title = remoteEpisode.Release.Title; title = FileNameBuilder.CleanFileName(title); var filename = Path.Combine(Settings.NzbFolder, title + ".nzb"); _logger.Debug("Downloading NZB from: {0} to: {1}", url, filename); _httpClient.DownloadFile(url, filename); _logger.Debug("NZB Download succeeded, saved to: {0}", filename); return(null); }
protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent) { var title = remoteEpisode.Release.Title; title = FileNameBuilder.CleanFileName(title); var filepath = Path.Combine(Settings.NzbFolder, title + ".nzb"); using (var stream = _diskProvider.OpenWriteStream(filepath)) { stream.Write(fileContent, 0, fileContent.Length); } _logger.Debug("NZB Download succeeded, saved to: {0}", filepath); return(null); }
public override string Download(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var filename = FileNameBuilder.CleanFileName(remoteEpisode.Release.Title) + ".nzb"; byte[] nzbData; try { var request = new HttpRequest(url); request.RateLimitKey = remoteEpisode?.Release?.IndexerId.ToString(); nzbData = _httpClient.Get(request).ResponseData; _logger.Debug("Downloaded nzb for episode '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, nzbData.Length, url); } catch (HttpException ex) { if (ex.Response.StatusCode == HttpStatusCode.NotFound) { _logger.Error(ex, "Downloading nzb file for episode '{0}' failed since it no longer exists ({1})", remoteEpisode.Release.Title, url); throw new ReleaseUnavailableException(remoteEpisode.Release, "Downloading nzb failed", ex); } if ((int)ex.Response.StatusCode == 429) { _logger.Error("API Grab Limit reached for {0}", url); } else { _logger.Error(ex, "Downloading nzb for episode '{0}' failed ({1})", remoteEpisode.Release.Title, url); } throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); } catch (WebException ex) { _logger.Error(ex, "Downloading nzb for episode '{0}' failed ({1})", remoteEpisode.Release.Title, url); throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex); } _nzbValidationService.Validate(filename, nzbData); _logger.Info("Adding report [{0}] to the queue.", remoteEpisode.Release.Title); return(AddFromNzbFile(remoteEpisode, filename, nzbData)); }
protected override string AddFromTorrentFile(RemoteBook remoteBook, string hash, string filename, byte[] fileContent) { var title = remoteBook.Release.Title; title = FileNameBuilder.CleanFileName(title); var filepath = Path.Combine(Settings.TorrentFolder, string.Format("{0}.torrent", title)); using (var stream = _diskProvider.OpenWriteStream(filepath)) { stream.Write(fileContent, 0, fileContent.Length); } _logger.Debug("Torrent Download succeeded, saved to: {0}", filepath); return(null); }
public override string Download(RemoteMovie remoteMovie) { var url = remoteMovie.Release.DownloadUrl; var filename = FileNameBuilder.CleanFileName(remoteMovie.Release.Title) + ".nzb"; byte[] nzbData; try { nzbData = _httpClient.Get(new HttpRequest(url)).ResponseData; _logger.Debug("Downloaded nzb for movie '{0}' finished ({1} bytes from {2})", remoteMovie.Release.Title, nzbData.Length, url); } catch (HttpException ex) { if ((int)ex.Response.StatusCode == 429) { _logger.Error("API Grab Limit reached for {0}", url); } else { _logger.Error(ex, "Downloading nzb for movie '{0}' failed ({1})", remoteMovie.Release.Title, url); } throw new ReleaseDownloadException(remoteMovie.Release, "Downloading nzb failed", ex); } catch (WebException ex) { _logger.Error(ex, "Downloading nzb for movie '{0}' failed ({1})", remoteMovie.Release.Title, url); throw new ReleaseDownloadException(remoteMovie.Release, "Downloading nzb failed", ex); } _nzbValidationService.Validate(filename, nzbData); _logger.Info("Adding report [{0}] to the queue.", remoteMovie.Release.Title); return(AddFromNzbFile(remoteMovie, filename, nzbData)); }
protected override string AddFromMagnetLink(RemoteBook remoteBook, string hash, string magnetLink) { if (!Settings.SaveMagnetFiles) { throw new NotSupportedException("Blackhole does not support magnet links."); } var title = remoteBook.Release.Title; title = FileNameBuilder.CleanFileName(title); var filepath = Path.Combine(Settings.TorrentFolder, $"{title}.{Settings.MagnetFileExtension.Trim('.')}"); var fileContent = Encoding.UTF8.GetBytes(magnetLink); using (var stream = _diskProvider.OpenWriteStream(filepath)) { stream.Write(fileContent, 0, fileContent.Length); } _logger.Debug("Saving magnet link succeeded, saved to: {0}", filepath); return(null); }
public void should_replaace_invalid_characters(string name, string expectedName) { FileNameBuilder.CleanFileName(name).Should().Be(expectedName); }
public override IEnumerable <DownloadClientItem> GetItems() { foreach (var folder in _diskProvider.GetDirectories(Settings.WatchFolder)) { var title = FileNameBuilder.CleanFileName(Path.GetFileName(folder)); var files = _diskProvider.GetFiles(folder, SearchOption.AllDirectories); var historyItem = new DownloadClientItem { DownloadClient = Definition.Name, DownloadClientId = Definition.Name + "_" + Path.GetFileName(folder) + "_" + _diskProvider.FolderGetCreationTimeUtc(folder).Ticks, Title = title, TotalSize = files.Select(_diskProvider.GetFileSize).Sum(), OutputPath = folder }; if (files.Any(_diskProvider.IsFileLocked)) { historyItem.Status = DownloadItemStatus.Downloading; } else { historyItem.Status = DownloadItemStatus.Completed; historyItem.RemainingTime = TimeSpan.Zero; } historyItem.RemoteEpisode = GetRemoteEpisode(historyItem.Title); if (historyItem.RemoteEpisode == null) { continue; } yield return(historyItem); } foreach (var videoFile in _diskScanService.GetVideoFiles(Settings.WatchFolder, false)) { var title = FileNameBuilder.CleanFileName(Path.GetFileName(videoFile)); var historyItem = new DownloadClientItem { DownloadClient = Definition.Name, DownloadClientId = Definition.Name + "_" + Path.GetFileName(videoFile) + "_" + _diskProvider.FileGetLastWriteUtc(videoFile).Ticks, Title = title, TotalSize = _diskProvider.GetFileSize(videoFile), OutputPath = videoFile }; if (_diskProvider.IsFileLocked(videoFile)) { historyItem.Status = DownloadItemStatus.Downloading; } else { historyItem.Status = DownloadItemStatus.Completed; historyItem.RemainingTime = TimeSpan.Zero; } historyItem.RemoteEpisode = GetRemoteEpisode(historyItem.Title); if (historyItem.RemoteEpisode == null) { continue; } yield return(historyItem); } }
public void should_remove_periods_from_start(string name, string expectedName) { FileNameBuilder.CleanFileName(name).Should().Be(expectedName); }
private IEnumerable <WatchFolderItem> GetDownloadItems(string watchFolder, Dictionary <string, WatchFolderItem> lastWatchItems, TimeSpan waitPeriod) { // get a fresh naming config each time, in case the user has made changes foreach (var folder in _diskProvider.GetDirectories(watchFolder)) { var title = FileNameBuilder.CleanFileName(Path.GetFileName(folder)); var newWatchItem = new WatchFolderItem { DownloadId = Path.GetFileName(folder) + "_" + _diskProvider.FolderGetCreationTime(folder).Ticks, Title = title, OutputPath = new OsPath(folder), Status = DownloadItemStatus.Completed, RemainingTime = TimeSpan.Zero }; var oldWatchItem = lastWatchItems.GetValueOrDefault(newWatchItem.DownloadId); if (PreCheckWatchItemExpiry(newWatchItem, oldWatchItem)) { var files = _diskProvider.GetFiles(folder, SearchOption.AllDirectories); newWatchItem.TotalSize = files.Select(_diskProvider.GetFileSize).Sum(); newWatchItem.Hash = GetHash(folder, files); if (files.Any(_diskProvider.IsFileLocked)) { newWatchItem.Status = DownloadItemStatus.Downloading; newWatchItem.RemainingTime = null; } UpdateWatchItemExpiry(newWatchItem, oldWatchItem, waitPeriod); } yield return(newWatchItem); } foreach (var videoFile in _diskScanService.GetVideoFiles(watchFolder, false)) { var title = FileNameBuilder.CleanFileName(Path.GetFileName(videoFile)); var newWatchItem = new WatchFolderItem { DownloadId = Path.GetFileName(videoFile) + "_" + _diskProvider.FileGetLastWrite(videoFile).Ticks, Title = title, OutputPath = new OsPath(videoFile), Status = DownloadItemStatus.Completed, RemainingTime = TimeSpan.Zero }; var oldWatchItem = lastWatchItems.GetValueOrDefault(newWatchItem.DownloadId); if (PreCheckWatchItemExpiry(newWatchItem, oldWatchItem)) { newWatchItem.TotalSize = _diskProvider.GetFileSize(videoFile); newWatchItem.Hash = GetHash(videoFile); if (_diskProvider.IsFileLocked(videoFile)) { newWatchItem.Status = DownloadItemStatus.Downloading; } UpdateWatchItemExpiry(newWatchItem, oldWatchItem, waitPeriod); } yield return(newWatchItem); } }
private string DownloadFromWebUrl(RemoteBook remoteBook, string torrentUrl) { byte[] torrentFile = null; try { var request = new HttpRequest(torrentUrl); request.RateLimitKey = remoteBook?.Release?.IndexerId.ToString(); request.Headers.Accept = "application/x-bittorrent"; request.AllowAutoRedirect = false; var response = _httpClient.Get(request); if (response.StatusCode == HttpStatusCode.MovedPermanently || response.StatusCode == HttpStatusCode.Found || response.StatusCode == HttpStatusCode.SeeOther) { var locationHeader = response.Headers.GetSingleValue("Location"); _logger.Trace("Torrent request is being redirected to: {0}", locationHeader); if (locationHeader != null) { if (locationHeader.StartsWith("magnet:")) { return(DownloadFromMagnetUrl(remoteBook, locationHeader)); } return(DownloadFromWebUrl(remoteBook, locationHeader)); } throw new WebException("Remote website tried to redirect without providing a location."); } torrentFile = response.ResponseData; _logger.Debug("Downloading torrent for release '{0}' finished ({1} bytes from {2})", remoteBook.Release.Title, torrentFile.Length, torrentUrl); } catch (HttpException ex) { if (ex.Response.StatusCode == HttpStatusCode.NotFound) { _logger.Error(ex, "Downloading torrent file for book '{0}' failed since it no longer exists ({1})", remoteBook.Release.Title, torrentUrl); throw new ReleaseUnavailableException(remoteBook.Release, "Downloading torrent failed", ex); } if ((int)ex.Response.StatusCode == 429) { _logger.Error("API Grab Limit reached for {0}", torrentUrl); } else { _logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteBook.Release.Title, torrentUrl); } throw new ReleaseDownloadException(remoteBook.Release, "Downloading torrent failed", ex); } catch (WebException ex) { _logger.Error(ex, "Downloading torrent file for release '{0}' failed ({1})", remoteBook.Release.Title, torrentUrl); throw new ReleaseDownloadException(remoteBook.Release, "Downloading torrent failed", ex); } var filename = string.Format("{0}.torrent", FileNameBuilder.CleanFileName(remoteBook.Release.Title)); var hash = _torrentFileInfoReader.GetHashFromTorrentFile(torrentFile); var actualHash = AddFromTorrentFile(remoteBook, hash, filename, torrentFile); if (actualHash.IsNotNullOrWhiteSpace() && hash != actualHash) { _logger.Debug( "{0} did not return the expected InfoHash for '{1}', Readarr could potentially lose track of the download in progress.", Definition.Implementation, remoteBook.Release.DownloadUrl); } return(actualHash); }
public void should_remove_spaces_from_start_and_end(string name, string expectedName) { FileNameBuilder.CleanFileName(name).Should().Be(expectedName); }
private IEnumerable <WatchFolderItem> GetDownloadItems(string watchFolder, Dictionary <string, WatchFolderItem> lastWatchItems, TimeSpan waitPeriod) { foreach (var folder in _diskScanService.FilterPaths(watchFolder, _diskProvider.GetDirectories(watchFolder))) { var title = FileNameBuilder.CleanFileName(Path.GetFileName(folder)); var newWatchItem = new WatchFolderItem { DownloadId = Path.GetFileName(folder) + "_" + _diskProvider.FolderGetCreationTime(folder).Ticks, Title = title, OutputPath = new OsPath(folder), Status = DownloadItemStatus.Completed, RemainingTime = TimeSpan.Zero }; var oldWatchItem = lastWatchItems.GetValueOrDefault(newWatchItem.DownloadId); if (PreCheckWatchItemExpiry(newWatchItem, oldWatchItem)) { var files = _diskProvider.GetFiles(folder, SearchOption.AllDirectories); newWatchItem.TotalSize = files.Select(_diskProvider.GetFileSize).Sum(); newWatchItem.Hash = GetHash(folder, files); if (files.Any(_diskProvider.IsFileLocked)) { newWatchItem.Status = DownloadItemStatus.Downloading; newWatchItem.RemainingTime = null; } UpdateWatchItemExpiry(newWatchItem, oldWatchItem, waitPeriod); } yield return(newWatchItem); } foreach (var audioFile in _diskScanService.FilterFiles(watchFolder, _diskScanService.GetAudioFiles(watchFolder, false))) { var title = FileNameBuilder.CleanFileName(audioFile.Name); var newWatchItem = new WatchFolderItem { DownloadId = audioFile.Name + "_" + audioFile.LastWriteTimeUtc.Ticks, Title = title, OutputPath = new OsPath(audioFile.FullName), Status = DownloadItemStatus.Completed, RemainingTime = TimeSpan.Zero }; var oldWatchItem = lastWatchItems.GetValueOrDefault(newWatchItem.DownloadId); if (PreCheckWatchItemExpiry(newWatchItem, oldWatchItem)) { newWatchItem.TotalSize = audioFile.Length; newWatchItem.Hash = GetHash(audioFile.FullName); if (_diskProvider.IsFileLocked(audioFile.FullName)) { newWatchItem.Status = DownloadItemStatus.Downloading; } UpdateWatchItemExpiry(newWatchItem, oldWatchItem, waitPeriod); } yield return(newWatchItem); } }
public void CleanFileName(string name, string expectedName) { FileNameBuilder.CleanFileName(name).Should().Be(expectedName); }
public void Setup() { _remoteEpisode = CreateRemoteEpisode(); _settings = new DownloadStationSettings() { Host = "127.0.0.1", Port = 5000, Username = "******", Password = "******" }; Subject.Definition = new DownloadClientDefinition(); Subject.Definition.Settings = _settings; _queued = new DownloadStationTask() { Id = "id1", Size = 1000, Status = DownloadStationTaskStatus.Waiting, Type = DownloadStationTaskType.NZB, Username = "******", Title = "title", Additional = new DownloadStationTaskAdditional { Detail = new Dictionary <string, string> { { "destination", "shared/folder" }, { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } }, Transfer = new Dictionary <string, string> { { "size_downloaded", "0" }, { "speed_download", "0" } } } }; _completed = new DownloadStationTask() { Id = "id2", Size = 1000, Status = DownloadStationTaskStatus.Finished, Type = DownloadStationTaskType.NZB, Username = "******", Title = "title", Additional = new DownloadStationTaskAdditional { Detail = new Dictionary <string, string> { { "destination", "shared/folder" }, { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } }, Transfer = new Dictionary <string, string> { { "size_downloaded", "1000" }, { "speed_download", "0" } }, } }; _seeding = new DownloadStationTask() { Id = "id2", Size = 1000, Status = DownloadStationTaskStatus.Seeding, Type = DownloadStationTaskType.NZB, Username = "******", Title = "title", Additional = new DownloadStationTaskAdditional { Detail = new Dictionary <string, string> { { "destination", "shared/folder" }, { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } }, Transfer = new Dictionary <string, string> { { "size_downloaded", "1000" }, { "speed_download", "0" } } } }; _downloading = new DownloadStationTask() { Id = "id3", Size = 1000, Status = DownloadStationTaskStatus.Downloading, Type = DownloadStationTaskType.NZB, Username = "******", Title = "title", Additional = new DownloadStationTaskAdditional { Detail = new Dictionary <string, string> { { "destination", "shared/folder" }, { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } }, Transfer = new Dictionary <string, string> { { "size_downloaded", "100" }, { "speed_download", "50" } } } }; _failed = new DownloadStationTask() { Id = "id4", Size = 1000, Status = DownloadStationTaskStatus.Error, Type = DownloadStationTaskType.NZB, Username = "******", Title = "title", Additional = new DownloadStationTaskAdditional { Detail = new Dictionary <string, string> { { "destination", "shared/folder" }, { "uri", FileNameBuilder.CleanFileName(_remoteEpisode.Release.Title) + ".nzb" } }, Transfer = new Dictionary <string, string> { { "size_downloaded", "10" }, { "speed_download", "0" } } } }; Mocker.GetMock <IHttpClient>() .Setup(s => s.Get(It.IsAny <HttpRequest>())) .Returns <HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0])); _downloadStationConfigItems = new Dictionary <string, object> { { "default_destination", _defaultDestination }, }; Mocker.GetMock <IDownloadStationProxy>() .Setup(v => v.GetConfig(It.IsAny <DownloadStationSettings>())) .Returns(_downloadStationConfigItems); }
protected static string CleanFileName(String name) { return(FileNameBuilder.CleanFileName(name) + ".nzb"); }