mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-21 23:32:27 +00:00
deluge: create a category for lidarr to consider a download failed. category can be applied by an external tool to handle stalled downloads.
This commit is contained in:
parent
740650ff82
commit
87c4190db6
4 changed files with 36 additions and 5 deletions
|
@ -119,6 +119,13 @@ public override IEnumerable<DownloadClientItem> GetItems()
|
|||
torrents = _proxy.GetTorrents(Settings);
|
||||
}
|
||||
|
||||
var useFailureCategory = Settings.MusicFailureCategory.IsNotNullOrWhiteSpace();
|
||||
|
||||
if (useFailureCategory)
|
||||
{
|
||||
torrents = torrents.Concat(_proxy.GetTorrentsByLabel(Settings.MusicFailureCategory, Settings));
|
||||
}
|
||||
|
||||
var items = new List<DownloadClientItem>();
|
||||
|
||||
foreach (var torrent in torrents)
|
||||
|
@ -152,7 +159,11 @@ public override IEnumerable<DownloadClientItem> GetItems()
|
|||
|
||||
item.TotalSize = torrent.Size;
|
||||
|
||||
if (torrent.State == DelugeTorrentStatus.Error)
|
||||
if (useFailureCategory && torrent.Label == Settings.MusicFailureCategory)
|
||||
{
|
||||
item.Status = DownloadItemStatus.Failed;
|
||||
}
|
||||
else if (torrent.State == DelugeTorrentStatus.Error)
|
||||
{
|
||||
item.Status = DownloadItemStatus.Warning;
|
||||
item.Message = "Deluge is reporting an error";
|
||||
|
@ -278,9 +289,9 @@ private ValidationFailure TestConnection()
|
|||
_logger.Error(ex, "Failed to test connection");
|
||||
|
||||
return new NzbDroneValidationFailure("Host", "Unable to connect to Deluge")
|
||||
{
|
||||
DetailedDescription = ex.Message
|
||||
};
|
||||
{
|
||||
DetailedDescription = ex.Message
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -333,6 +344,20 @@ private ValidationFailure TestCategory()
|
|||
}
|
||||
}
|
||||
|
||||
if (Settings.MusicFailureCategory.IsNotNullOrWhiteSpace() && !labels.Contains(Settings.MusicFailureCategory))
|
||||
{
|
||||
_proxy.AddLabel(Settings.MusicFailureCategory, Settings);
|
||||
labels = _proxy.GetAvailableLabels(Settings);
|
||||
|
||||
if (!labels.Contains(Settings.MusicFailureCategory))
|
||||
{
|
||||
return new NzbDroneValidationFailure("MusicFailureCategory", "Configuration of label failed")
|
||||
{
|
||||
DetailedDescription = "Lidarr was unable to add the label to Deluge."
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public interface IDelugeProxy
|
|||
|
||||
public class DelugeProxy : IDelugeProxy
|
||||
{
|
||||
private static readonly string[] RequiredProperties = new string[] { "hash", "name", "state", "progress", "eta", "message", "is_finished", "save_path", "total_size", "total_done", "time_added", "active_time", "ratio", "is_auto_managed", "stop_at_ratio", "remove_at_ratio", "stop_ratio" };
|
||||
private static readonly string[] RequiredProperties = new string[] { "hash", "name", "state", "progress", "eta", "message", "is_finished", "save_path", "total_size", "total_done", "time_added", "active_time", "ratio", "is_auto_managed", "stop_at_ratio", "remove_at_ratio", "stop_ratio", "label" };
|
||||
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly Logger _logger;
|
||||
|
|
|
@ -50,6 +50,9 @@ public DelugeSettings()
|
|||
[FieldDefinition(6, Label = "Post-Import Category", Type = FieldType.Textbox, Advanced = true, HelpText = "Category for Lidarr to set after it has imported the download. Lidarr will not remove torrents in that category even if seeding finished. Leave blank to keep same category.")]
|
||||
public string MusicImportedCategory { get; set; }
|
||||
|
||||
[FieldDefinition(6, Label = "Failure Category", Type = FieldType.Textbox, Advanced = true, HelpText = "Category for Lidarr to treat a download as failed (applied externally). Leave blank to ignore.")]
|
||||
public string MusicFailureCategory { get; set; }
|
||||
|
||||
[FieldDefinition(7, Label = "Recent Priority", Type = FieldType.Select, SelectOptions = typeof(DelugePriority), HelpText = "Priority to use when grabbing albums released within the last 14 days")]
|
||||
public int RecentTvPriority { get; set; }
|
||||
|
||||
|
|
|
@ -51,5 +51,8 @@ public class DelugeTorrent
|
|||
|
||||
[JsonProperty(PropertyName = "stop_ratio")]
|
||||
public double StopRatio { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "label")]
|
||||
public string Label { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue