mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
indexer cleanup.
This commit is contained in:
parent
9dbfc6804f
commit
3e9a6ed0ef
@ -4,26 +4,16 @@
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Eztv
|
||||
{
|
||||
public class Eztv : IndexerBase<NullSetting>
|
||||
public class Eztv : IndexerBase<NullConfig>
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get { return "Eztv"; }
|
||||
}
|
||||
|
||||
public override IndexerKind Kind
|
||||
public override DownloadProtocol Protocol
|
||||
{
|
||||
get
|
||||
{
|
||||
return IndexerKind.Torrent;
|
||||
return DownloadProtocol.Torrent;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool EnableByDefault
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override IParseFeed Parser
|
||||
{
|
||||
get
|
||||
@ -36,10 +26,7 @@ public override IEnumerable<string> RecentFeed
|
||||
{
|
||||
get
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
"http://www.ezrss.it/feed/"
|
||||
};
|
||||
yield return "http://www.ezrss.it/feed/";
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +43,7 @@ public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int
|
||||
|
||||
public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date)
|
||||
{
|
||||
//EZTV doesn't support searching based on actual epidose airdate. they only support release date.
|
||||
//EZTV doesn't support searching based on actual episode airdate. they only support release date.
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace NzbDrone.Core.Indexers
|
||||
public interface IIndexer : IProvider
|
||||
{
|
||||
IParseFeed Parser { get; }
|
||||
IndexerKind Kind { get; }
|
||||
DownloadProtocol Protocol { get; }
|
||||
|
||||
IEnumerable<string> RecentFeed { get; }
|
||||
IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber);
|
||||
|
@ -6,7 +6,13 @@ namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
public abstract class IndexerBase<TSettings> : IIndexer
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
public Type ConfigContract
|
||||
{
|
||||
get
|
||||
{
|
||||
return typeof(TSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IEnumerable<ProviderDefinition> DefaultDefinitions
|
||||
{
|
||||
@ -14,19 +20,17 @@ public virtual IEnumerable<ProviderDefinition> DefaultDefinitions
|
||||
{
|
||||
yield return new IndexerDefinition
|
||||
{
|
||||
Name = Name,
|
||||
Name = this.GetType().Name,
|
||||
Enable = false,
|
||||
Implementation = GetType().Name,
|
||||
Settings = NullSetting.Instance
|
||||
Settings = NullConfig.Instance
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public ProviderDefinition Definition { get; set; }
|
||||
|
||||
public abstract IndexerKind Kind { get; }
|
||||
|
||||
public virtual bool EnableByDefault { get { return true; } }
|
||||
public abstract DownloadProtocol Protocol { get; }
|
||||
|
||||
protected TSettings Settings
|
||||
{
|
||||
@ -42,9 +46,15 @@ protected TSettings Settings
|
||||
public abstract IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber);
|
||||
public abstract IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date);
|
||||
public abstract IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset);
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return GetType().Name;
|
||||
}
|
||||
}
|
||||
|
||||
public enum IndexerKind
|
||||
public enum DownloadProtocol
|
||||
{
|
||||
Usenet,
|
||||
Torrent
|
||||
|
@ -33,11 +33,11 @@ public FetchFeedService(IHttpProvider httpProvider, Logger logger)
|
||||
|
||||
public virtual IList<ReleaseInfo> FetchRss(IIndexer indexer)
|
||||
{
|
||||
_logger.Debug("Fetching feeds from " + indexer.Name);
|
||||
_logger.Debug("Fetching feeds from " + indexer);
|
||||
|
||||
var result = Fetch(indexer, indexer.RecentFeed);
|
||||
|
||||
_logger.Debug("Finished processing feeds from " + indexer.Name);
|
||||
_logger.Debug("Finished processing feeds from " + indexer);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -48,7 +48,7 @@ public IList<ReleaseInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCri
|
||||
|
||||
var result = Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.DownloadUrl).ToList();
|
||||
|
||||
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
|
||||
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -61,7 +61,7 @@ private IList<ReleaseInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCr
|
||||
var result = Fetch(indexer, searchUrls);
|
||||
|
||||
|
||||
_logger.Info("{0} offset {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
|
||||
_logger.Info("{0} offset {1}. Found {2}", indexer, searchCriteria, result.Count);
|
||||
|
||||
if (result.Count > 90)
|
||||
{
|
||||
@ -79,7 +79,7 @@ public IList<ReleaseInfo> Fetch(IIndexer indexer, SingleEpisodeSearchCriteria se
|
||||
var result = Fetch(indexer, searchUrls);
|
||||
|
||||
|
||||
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
|
||||
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ public IList<ReleaseInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria sea
|
||||
var searchUrls = indexer.GetDailyEpisodeSearchUrls(searchCriteria.QueryTitle, searchCriteria.Series.TvRageId, searchCriteria.Airtime);
|
||||
var result = Fetch(indexer, searchUrls);
|
||||
|
||||
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
|
||||
_logger.Info("Finished searching {0} for {1}. Found {2}", indexer, searchCriteria, result.Count);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -119,12 +119,11 @@ private List<ReleaseInfo> Fetch(IIndexer indexer, IEnumerable<string> urls)
|
||||
if (webException.Message.Contains("502") || webException.Message.Contains("503") ||
|
||||
webException.Message.Contains("timed out"))
|
||||
{
|
||||
_logger.Warn("{0} server is currently unavailable. {1} {2}", indexer.Name, url,
|
||||
webException.Message);
|
||||
_logger.Warn("{0} server is currently unavailable. {1} {2}", indexer, url, webException.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Warn("{0} {1} {2}", indexer.Name, url, webException.Message);
|
||||
_logger.Warn("{0} {1} {2}", indexer, url, webException.Message);
|
||||
}
|
||||
}
|
||||
catch (ApiKeyException)
|
||||
@ -138,7 +137,7 @@ private List<ReleaseInfo> Fetch(IIndexer indexer, IEnumerable<string> urls)
|
||||
}
|
||||
}
|
||||
|
||||
result.ForEach(c => c.Indexer = indexer.Name);
|
||||
result.ForEach(c => c.Indexer = indexer.Definition.Name);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
|
||||
@ -11,9 +12,29 @@ public interface IIndexerService : IProviderFactory<IIndexer, IndexerDefinition>
|
||||
|
||||
public class IndexerService : ProviderFactory<IIndexer, IndexerDefinition>
|
||||
{
|
||||
private readonly IProviderRepository<IndexerDefinition> _providerRepository;
|
||||
private readonly IEnumerable<IIndexer> _providers;
|
||||
|
||||
public IndexerService(IProviderRepository<IndexerDefinition> providerRepository, IEnumerable<IIndexer> providers, Logger logger)
|
||||
: base(providerRepository, providers, logger)
|
||||
{
|
||||
_providerRepository = providerRepository;
|
||||
_providers = providers;
|
||||
}
|
||||
|
||||
protected override void InitializeProviders()
|
||||
{
|
||||
var definitions = _providers.SelectMany(indexer => indexer.DefaultDefinitions);
|
||||
|
||||
var currentProviders = All();
|
||||
|
||||
var newProviders = definitions.Where(def => currentProviders.All(c => c.Implementation != def.Implementation)).ToList();
|
||||
|
||||
|
||||
if (newProviders.Any())
|
||||
{
|
||||
_providerRepository.InsertMany(newProviders.Cast<IndexerDefinition>().ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -69,7 +69,7 @@ public override IEnumerable<string> RecentFeed
|
||||
get
|
||||
{
|
||||
//Todo: We should be able to update settings on start
|
||||
if (Name.Equals("nzbs.org", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (Settings.Url.Contains("nzbs.org"))
|
||||
{
|
||||
Settings.Categories = new List<int> { 5000 };
|
||||
}
|
||||
@ -115,19 +115,11 @@ public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int
|
||||
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2}&offset={3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, offset));
|
||||
}
|
||||
|
||||
public override string Name
|
||||
public override DownloadProtocol Protocol
|
||||
{
|
||||
get
|
||||
{
|
||||
return Definition.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public override IndexerKind Kind
|
||||
{
|
||||
get
|
||||
{
|
||||
return IndexerKind.Usenet;
|
||||
return DownloadProtocol.Usenet;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,16 +5,11 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
|
||||
{
|
||||
public class Omgwtfnzbs : IndexerBase<OmgwtfnzbsSettings>
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get { return "omgwtfnzbs"; }
|
||||
}
|
||||
|
||||
public override IndexerKind Kind
|
||||
public override DownloadProtocol Protocol
|
||||
{
|
||||
get
|
||||
{
|
||||
return IndexerKind.Usenet;
|
||||
return DownloadProtocol.Usenet;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,13 @@
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Wombles
|
||||
{
|
||||
public class Wombles : IndexerBase<NullSetting>
|
||||
public class Wombles : IndexerBase<NullConfig>
|
||||
{
|
||||
public override string Name
|
||||
{
|
||||
get { return "WomblesIndex"; }
|
||||
}
|
||||
|
||||
public override IndexerKind Kind
|
||||
public override DownloadProtocol Protocol
|
||||
{
|
||||
get
|
||||
{
|
||||
return IndexerKind.Usenet;
|
||||
return DownloadProtocol.Usenet;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public TProviderDefinition GetByName(string name)
|
||||
|
||||
public interface IProvider
|
||||
{
|
||||
string Name { get; }
|
||||
Type ConfigContract { get; }
|
||||
|
||||
IEnumerable<ProviderDefinition> DefaultDefinitions { get; }
|
||||
ProviderDefinition Definition { get; set; }
|
||||
@ -51,7 +51,6 @@ public string ConfigContract
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,9 +62,9 @@ public interface IProviderConfig
|
||||
ValidationResult Validate();
|
||||
}
|
||||
|
||||
public class NullSetting : IProviderConfig
|
||||
public class NullConfig : IProviderConfig
|
||||
{
|
||||
public static readonly NullSetting Instance = new NullSetting();
|
||||
public static readonly NullConfig Instance = new NullConfig();
|
||||
|
||||
public ValidationResult Validate()
|
||||
{
|
||||
|
@ -52,21 +52,21 @@ public TProviderDefinition Get(int id)
|
||||
return _providerRepository.Get(id);
|
||||
}
|
||||
|
||||
/* public List<TProvider> Schema()
|
||||
{
|
||||
var indexers = new List<Indexer>();
|
||||
/* public List<TProvider> Schema()
|
||||
{
|
||||
var indexers = new List<Indexer>();
|
||||
|
||||
var newznab = new Indexer();
|
||||
newznab.Instance = new Newznab.Newznab();
|
||||
newznab.Id = 1;
|
||||
newznab.Name = "Newznab";
|
||||
newznab.Settings = new NewznabSettings();
|
||||
newznab.Implementation = "Newznab";
|
||||
var newznab = new Indexer();
|
||||
newznab.Instance = new Newznab.Newznab();
|
||||
newznab.Id = 1;
|
||||
newznab.Name = "Newznab";
|
||||
newznab.Settings = new NewznabSettings();
|
||||
newznab.Implementation = "Newznab";
|
||||
|
||||
indexers.Add(newznab);
|
||||
indexers.Add(newznab);
|
||||
|
||||
return indexers;
|
||||
}*/
|
||||
return indexers;
|
||||
}*/
|
||||
|
||||
public TProviderDefinition Create(TProviderDefinition provider)
|
||||
{
|
||||
@ -102,17 +102,11 @@ public void Handle(ApplicationStartedEvent message)
|
||||
|
||||
RemoveMissingImplementations();
|
||||
|
||||
var definitions = _providers.SelectMany(indexer => indexer.DefaultDefinitions);
|
||||
InitializeProviders();
|
||||
}
|
||||
|
||||
var currentProviders = All();
|
||||
|
||||
var newProviders = definitions.Where(def => currentProviders.All(c => c.Implementation != def.Implementation)).ToList();
|
||||
|
||||
|
||||
if (newProviders.Any())
|
||||
{
|
||||
_providerRepository.InsertMany(newProviders.Cast<TProviderDefinition>().ToList());
|
||||
}
|
||||
protected virtual void InitializeProviders()
|
||||
{
|
||||
}
|
||||
|
||||
private void RemoveMissingImplementations()
|
||||
|
Loading…
Reference in New Issue
Block a user