|
|
@ -70,34 +70,52 @@ namespace NzbDrone.Core.Providers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Debug("Initializing Newznab indexers. Count {0}", indexers.Count);
|
|
|
|
Logger.Debug("Initializing Newznab indexers. Count {0}", indexers.Count);
|
|
|
|
|
|
|
|
|
|
|
|
var currentIndexers = All();
|
|
|
|
try
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var feedProvider in indexers)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NewznabDefinition indexerLocal = feedProvider;
|
|
|
|
var currentIndexers = All();
|
|
|
|
var currentIndexer = currentIndexers
|
|
|
|
|
|
|
|
.FirstOrDefault(c => new Uri(c.Url.ToLower()).Host == new Uri(indexerLocal.Url.ToLower()).Host);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentIndexer == null)
|
|
|
|
foreach(var feedProvider in indexers)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var settings = new NewznabDefinition
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Enable = false,
|
|
|
|
|
|
|
|
Name = indexerLocal.Name,
|
|
|
|
|
|
|
|
Url = indexerLocal.Url,
|
|
|
|
NewznabDefinition indexerLocal = feedProvider;
|
|
|
|
ApiKey = indexerLocal.ApiKey,
|
|
|
|
var currentIndexer = currentIndexers
|
|
|
|
BuiltIn = true
|
|
|
|
.FirstOrDefault(
|
|
|
|
};
|
|
|
|
c =>
|
|
|
|
|
|
|
|
new Uri(c.Url.ToLower()).Host == new Uri(indexerLocal.Url.ToLower()).Host);
|
|
|
|
Save(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (currentIndexer == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
else
|
|
|
|
var settings = new NewznabDefinition
|
|
|
|
{
|
|
|
|
{
|
|
|
|
currentIndexer.BuiltIn = true;
|
|
|
|
Enable = false,
|
|
|
|
Save(currentIndexer);
|
|
|
|
Name = indexerLocal.Name,
|
|
|
|
|
|
|
|
Url = indexerLocal.Url,
|
|
|
|
|
|
|
|
ApiKey = indexerLocal.ApiKey,
|
|
|
|
|
|
|
|
BuiltIn = true
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Save(settings);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
currentIndexer.BuiltIn = true;
|
|
|
|
|
|
|
|
Save(currentIndexer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.ErrorException("An error occurred while setting up indexer: " + feedProvider.Name, ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Logger.ErrorException("An Error occurred while initializing Newznab Indexers", ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Delete(int id)
|
|
|
|
public virtual void Delete(int id)
|
|
|
|