From d898fbb4b0dc68fd096341322ad15dba4e4576d5 Mon Sep 17 00:00:00 2001 From: Tim Schindler Date: Fri, 6 Jan 2017 21:54:24 -0500 Subject: [PATCH] dirty fix for rtorrent --- .../Download/Clients/rTorrent/RTorrent.cs | 59 ++++++++++++++++++- .../Clients/rTorrent/RTorrentSettings.cs | 2 +- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index 041708a93..b456f828c 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -37,6 +37,37 @@ namespace NzbDrone.Core.Download.Clients.RTorrent _rTorrentDirectoryValidator = rTorrentDirectoryValidator; } + protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink) + { + _proxy.AddTorrentFromUrl(magnetLink, Settings); + + // Download the magnet to the appropriate directory. + _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); + //SetPriority(remoteEpisode, hash); + SetDownloadDirectory(hash); + + // Once the magnet meta download finishes, rTorrent replaces it with the actual torrent download with default settings. + // Schedule an event to apply the appropriate settings when that happens. + // var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority); + //_proxy.SetDeferredMagnetProperties(hash, Settings.TvCategory, Settings.TvDirectory, priority, Settings); + + _proxy.StartTorrent(hash, Settings); + + // Wait for the magnet to be resolved. + var tries = 10; + var retryDelay = 500; + if (WaitForTorrent(hash, tries, retryDelay)) + { + return hash; + } + else + { + _logger.Warn("rTorrent could not resolve magnet within {0} seconds, download may remain stuck: {1}.", tries * retryDelay / 1000, magnetLink); + + return hash; + } + } + protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, Settings); @@ -68,6 +99,32 @@ namespace NzbDrone.Core.Download.Clients.RTorrent } } + protected override string AddFromTorrentFile(RemoteMovie remoteMovie, string hash, string filename, byte[] fileContent) + { + _proxy.AddTorrentFromFile(filename, fileContent, Settings); + + var tries = 2; + var retryDelay = 100; + if (WaitForTorrent(hash, tries, retryDelay)) + { + _proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings); + + //SetPriority(remoteEpisode, hash); + SetDownloadDirectory(hash); + + _proxy.StartTorrent(hash, Settings); + + return hash; + } + else + { + _logger.Debug("rTorrent could not add file"); + + RemoveItem(hash, true); + throw new ReleaseDownloadException(remoteMovie.Release, "Downloading torrent failed"); + } + } + protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromFile(filename, fileContent, Settings); @@ -96,7 +153,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent public override string Name => "rTorrent"; - public override ProviderMessage Message => new ProviderMessage("Sonarr is unable to remove torrents that have finished seeding when using rTorrent", ProviderMessageType.Warning); + public override ProviderMessage Message => new ProviderMessage("Radarr is unable to remove torrents that have finished seeding when using rTorrent", ProviderMessageType.Warning); public override IEnumerable GetItems() { diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs index 81715246c..570392395 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentSettings.cs @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent Host = "localhost"; Port = 8080; UrlBase = "RPC2"; - TvCategory = "tv-sonarr"; + TvCategory = "movies-radarr"; OlderTvPriority = (int)RTorrentPriority.Normal; RecentTvPriority = (int)RTorrentPriority.Normal; }