mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-22 22:43:31 -07:00
Clean up rTorrent
This commit is contained in:
parent
fdd06127fc
commit
0efdc78f8d
4 changed files with 22 additions and 94 deletions
|
@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.RTorrentTests
|
||||||
Subject.Definition = new DownloadClientDefinition();
|
Subject.Definition = new DownloadClientDefinition();
|
||||||
Subject.Definition.Settings = new RTorrentSettings()
|
Subject.Definition.Settings = new RTorrentSettings()
|
||||||
{
|
{
|
||||||
TvCategory = null
|
MovieCategory = null
|
||||||
};
|
};
|
||||||
|
|
||||||
_downloading = new RTorrentTorrent
|
_downloading = new RTorrentTorrent
|
||||||
|
|
|
@ -37,51 +37,23 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
_rTorrentDirectoryValidator = rTorrentDirectoryValidator;
|
_rTorrentDirectoryValidator = rTorrentDirectoryValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("Episodes are not working with Radarr");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("Episodes are not working with Radarr");
|
||||||
|
}
|
||||||
|
|
||||||
protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink)
|
protected override string AddFromMagnetLink(RemoteMovie remoteMovie, string hash, string magnetLink)
|
||||||
{
|
{
|
||||||
_proxy.AddTorrentFromUrl(magnetLink, Settings);
|
_proxy.AddTorrentFromUrl(magnetLink, Settings);
|
||||||
|
|
||||||
// Download the magnet to the appropriate directory.
|
// Download the magnet to the appropriate directory.
|
||||||
_proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings);
|
_proxy.SetTorrentLabel(hash, Settings.MovieCategory, Settings);
|
||||||
//SetPriority(remoteEpisode, hash);
|
|
||||||
SetDownloadDirectory(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);
|
|
||||||
|
|
||||||
// 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);
|
_proxy.StartTorrent(hash, Settings);
|
||||||
|
|
||||||
// Wait for the magnet to be resolved.
|
// Wait for the magnet to be resolved.
|
||||||
|
@ -107,13 +79,9 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
var retryDelay = 100;
|
var retryDelay = 100;
|
||||||
if (WaitForTorrent(hash, tries, retryDelay))
|
if (WaitForTorrent(hash, tries, retryDelay))
|
||||||
{
|
{
|
||||||
_proxy.SetTorrentLabel(hash, Settings.TvCategory, Settings);
|
_proxy.SetTorrentLabel(hash, Settings.MovieCategory, Settings);
|
||||||
|
|
||||||
//SetPriority(remoteEpisode, hash);
|
|
||||||
SetDownloadDirectory(hash);
|
SetDownloadDirectory(hash);
|
||||||
|
|
||||||
_proxy.StartTorrent(hash, Settings);
|
_proxy.StartTorrent(hash, Settings);
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -125,32 +93,6 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, 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(remoteEpisode.Release, "Downloading torrent failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Name => "rTorrent";
|
public override string Name => "rTorrent";
|
||||||
|
|
||||||
public override ProviderMessage Message => new ProviderMessage("Radarr 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);
|
||||||
|
@ -167,7 +109,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
foreach (RTorrentTorrent torrent in torrents)
|
foreach (RTorrentTorrent torrent in torrents)
|
||||||
{
|
{
|
||||||
// Don't concern ourselves with categories other than specified
|
// Don't concern ourselves with categories other than specified
|
||||||
if (torrent.Category != Settings.TvCategory) continue;
|
if (torrent.Category != Settings.MovieCategory) continue;
|
||||||
|
|
||||||
if (torrent.Path.StartsWith("."))
|
if (torrent.Path.StartsWith("."))
|
||||||
{
|
{
|
||||||
|
@ -287,17 +229,11 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
return result.Errors.First();
|
return result.Errors.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPriority(RemoteEpisode remoteEpisode, string hash)
|
|
||||||
{
|
|
||||||
var priority = (RTorrentPriority)(remoteEpisode.IsRecentEpisode() ? Settings.RecentTvPriority : Settings.OlderTvPriority);
|
|
||||||
_proxy.SetTorrentPriority(hash, priority, Settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetDownloadDirectory(string hash)
|
private void SetDownloadDirectory(string hash)
|
||||||
{
|
{
|
||||||
if (Settings.TvDirectory.IsNotNullOrWhiteSpace())
|
if (Settings.MovieDirectory.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
_proxy.SetTorrentDownloadDirectory(hash, Settings.TvDirectory, Settings);
|
_proxy.SetTorrentDownloadDirectory(hash, Settings.MovieDirectory, Settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,13 @@ namespace NzbDrone.Core.Download.Clients.rTorrent
|
||||||
DroneFactoryValidator droneFactoryValidator,
|
DroneFactoryValidator droneFactoryValidator,
|
||||||
MappedNetworkDriveValidator mappedNetworkDriveValidator)
|
MappedNetworkDriveValidator mappedNetworkDriveValidator)
|
||||||
{
|
{
|
||||||
RuleFor(c => c.TvDirectory).Cascade(CascadeMode.StopOnFirstFailure)
|
RuleFor(c => c.MovieDirectory).Cascade(CascadeMode.StopOnFirstFailure)
|
||||||
.IsValidPath()
|
.IsValidPath()
|
||||||
.SetValidator(rootFolderValidator)
|
.SetValidator(rootFolderValidator)
|
||||||
.SetValidator(droneFactoryValidator)
|
.SetValidator(droneFactoryValidator)
|
||||||
.SetValidator(mappedNetworkDriveValidator)
|
.SetValidator(mappedNetworkDriveValidator)
|
||||||
.SetValidator(pathExistsValidator)
|
.SetValidator(pathExistsValidator)
|
||||||
.When(c => c.TvDirectory.IsNotNullOrWhiteSpace())
|
.When(c => c.MovieDirectory.IsNotNullOrWhiteSpace())
|
||||||
.When(c => c.Host == "localhost" || c.Host == "127.0.0.1");
|
.When(c => c.Host == "localhost" || c.Host == "127.0.0.1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
{
|
{
|
||||||
RuleFor(c => c.Host).ValidHost();
|
RuleFor(c => c.Host).ValidHost();
|
||||||
RuleFor(c => c.Port).InclusiveBetween(0, 65535);
|
RuleFor(c => c.Port).InclusiveBetween(0, 65535);
|
||||||
RuleFor(c => c.TvCategory).NotEmpty()
|
RuleFor(c => c.MovieCategory).NotEmpty()
|
||||||
.WithMessage("A category is recommended")
|
.WithMessage("A category is recommended")
|
||||||
.AsWarning();
|
.AsWarning();
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
Host = "localhost";
|
Host = "localhost";
|
||||||
Port = 8080;
|
Port = 8080;
|
||||||
UrlBase = "RPC2";
|
UrlBase = "RPC2";
|
||||||
TvCategory = "movies-radarr";
|
MovieCategory = "movies-radarr";
|
||||||
OlderTvPriority = (int)RTorrentPriority.Normal;
|
|
||||||
RecentTvPriority = (int)RTorrentPriority.Normal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
|
[FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)]
|
||||||
|
@ -50,16 +48,10 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(6, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional.")]
|
[FieldDefinition(6, Label = "Category", Type = FieldType.Textbox, HelpText = "Adding a category specific to Radarr avoids conflicts with unrelated downloads, but it's optional.")]
|
||||||
public string TvCategory { get; set; }
|
public string MovieCategory { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(7, Label = "Directory", Type = FieldType.Textbox, Advanced = true, HelpText = "Optional location to put downloads in, leave blank to use the default rTorrent location")]
|
[FieldDefinition(7, Label = "Directory", Type = FieldType.Textbox, Advanced = true, HelpText = "Optional location to put downloads in, leave blank to use the default rTorrent location")]
|
||||||
public string TvDirectory { get; set; }
|
public string MovieDirectory { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(8, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "Priority to use when grabbing episodes that aired within the last 14 days")]
|
|
||||||
public int RecentTvPriority { get; set; }
|
|
||||||
|
|
||||||
[FieldDefinition(9, Label = "Older Priority", Type = FieldType.Select, SelectOptions = typeof(RTorrentPriority), HelpText = "Priority to use when grabbing episodes that aired over 14 days ago")]
|
|
||||||
public int OlderTvPriority { get; set; }
|
|
||||||
|
|
||||||
public NzbDroneValidationResult Validate()
|
public NzbDroneValidationResult Validate()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue