1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-27 18:28:19 +00:00

Added Seed Time and Season-Pack seed time.

This commit is contained in:
Taloth Saldono 2018-05-03 21:40:57 +02:00
parent 47018b02a8
commit 6df61e305d
4 changed files with 28 additions and 23 deletions

View file

@ -1,10 +0,0 @@
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Configuration
{
public interface ISeedConfigProvider
{
TorrentSeedConfiguration GetSeedConfiguration(ReleaseInfo release);
}
}

View file

@ -1,9 +1,15 @@
using NzbDrone.Core.Download.Clients;
using System;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Configuration
{
public interface ISeedConfigProvider
{
TorrentSeedConfiguration GetSeedConfiguration(RemoteEpisode release);
}
public class SeedConfigProvider: ISeedConfigProvider
{
private readonly IIndexerFactory _indexerFactory;
@ -13,18 +19,27 @@ namespace NzbDrone.Core.Configuration
_indexerFactory = indexerFactory;
}
public TorrentSeedConfiguration GetSeedConfiguration(ReleaseInfo release)
public TorrentSeedConfiguration GetSeedConfiguration(RemoteEpisode remoteEpisode)
{
if (release.DownloadProtocol != DownloadProtocol.Torrent) return null;
if (remoteEpisode.Release.DownloadProtocol != DownloadProtocol.Torrent) return null;
var indexer = _indexerFactory.Get(release.IndexerId);
var indexer = _indexerFactory.Get(remoteEpisode.Release.IndexerId);
var torrentIndexerSettings = indexer?.Settings as ITorrentIndexerSettings;
if (indexer.Settings is ITorrentIndexerSettings torrentIndexerSettings)
if (torrentIndexerSettings != null)
{
return new TorrentSeedConfiguration
var seedConfig = new TorrentSeedConfiguration
{
Ratio = torrentIndexerSettings.SeedCriteria.SeedRatio
};
var seedTime = remoteEpisode.ParsedEpisodeInfo.FullSeason ? torrentIndexerSettings.SeedCriteria.SeasonPackSeedTime : torrentIndexerSettings.SeedCriteria.SeedTime;
if (seedTime.HasValue)
{
seedConfig.SeedTime = TimeSpan.FromSeconds(seedTime.Value);
}
return seedConfig;
}
return null;

View file

@ -61,7 +61,7 @@ namespace NzbDrone.Core.Download
}
// Get the seed configuration for this release.
remoteEpisode.SeedConfiguration = _seedConfigProvider.GetSeedConfiguration(remoteEpisode.Release);
remoteEpisode.SeedConfiguration = _seedConfigProvider.GetSeedConfiguration(remoteEpisode);
// Limit grabs to 2 per second.
if (remoteEpisode.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteEpisode.Release.DownloadUrl.StartsWith("magnet:"))

View file

@ -13,8 +13,8 @@ namespace NzbDrone.Core.Indexers
public SeedCriteriaSettingsValidator()
{
RuleFor(c => c.SeedRatio).GreaterThan(0.0).When(c => c.SeedRatio.HasValue);
//RuleFor(c => c.SeedTime).GreaterThan(0).When(c => c.SeedTime.HasValue);
//RuleFor(c => c.SeasonPackSeedTime).GreaterThan(0).When(c => c.SeasonPackSeedTime.HasValue);
RuleFor(c => c.SeedTime).GreaterThan(0).When(c => c.SeedTime.HasValue);
RuleFor(c => c.SeasonPackSeedTime).GreaterThan(0).When(c => c.SeasonPackSeedTime.HasValue);
}
}
@ -25,10 +25,10 @@ namespace NzbDrone.Core.Indexers
[FieldDefinition(0, Type = FieldType.Textbox, Label = "Seed Ratio", HelpText = "The ratio a torrent should reach before stopping, empty is download client's default", Advanced = true)]
public double? SeedRatio { get; set; }
//[FieldDefinition(1, Type = FieldType.Textbox, Label = "Seed Time", HelpText = "The time a torrent should be seeded before stopping, empty is download client's default", Advanced = true)]
//public int? SeedTime { get; set; }
[FieldDefinition(1, Type = FieldType.Textbox, Label = "Seed Time", HelpText = "The time a torrent should be seeded before stopping, empty is download client's default", Advanced = true)]
public int? SeedTime { get; set; }
//[FieldDefinition(2, Type = FieldType.Textbox, Label = "Season-Pack Seed Time", HelpText = "The time a torrent should be seeded before stopping, empty is download client's default", Advanced = true)]
//public int? SeasonPackSeedTime { get; set; }
[FieldDefinition(2, Type = FieldType.Textbox, Label = "Season-Pack Seed Time", HelpText = "The time a torrent should be seeded before stopping, empty is download client's default", Advanced = true)]
public int? SeasonPackSeedTime { get; set; }
}
}