1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-24 22:35:49 -04:00

New: Loads of Backend Updates to Clients and Indexers

This commit is contained in:
Qstick
2019-06-13 23:54:25 -04:00
parent c48838e5b6
commit 8a9e2dc90d
345 changed files with 5859 additions and 2669 deletions
@@ -0,0 +1,59 @@
using System;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers
{
public interface ISeedConfigProvider
{
TorrentSeedConfiguration GetSeedConfiguration(RemoteMovie release);
}
public class SeedConfigProvider : ISeedConfigProvider
{
private readonly IIndexerFactory _indexerFactory;
public SeedConfigProvider(IIndexerFactory indexerFactory)
{
_indexerFactory = indexerFactory;
}
public TorrentSeedConfiguration GetSeedConfiguration(RemoteMovie remoteMovie)
{
if (remoteMovie.Release.DownloadProtocol != DownloadProtocol.Torrent) return null;
if (remoteMovie.Release.IndexerId == 0) return null;
try
{
var indexer = _indexerFactory.Get(remoteMovie.Release.IndexerId);
var torrentIndexerSettings = indexer.Settings as ITorrentIndexerSettings;
if (torrentIndexerSettings != null && torrentIndexerSettings.SeedCriteria != null)
{
var seedConfig = new TorrentSeedConfiguration
{
Ratio = torrentIndexerSettings.SeedCriteria.SeedRatio
};
var seedTime = torrentIndexerSettings.SeedCriteria.SeedTime;
if (seedTime.HasValue)
{
seedConfig.SeedTime = TimeSpan.FromMinutes(seedTime.Value);
}
return seedConfig;
}
}
catch (ModelNotFoundException)
{
return null;
}
return null;
}
}
}