mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 13:57:11 -04:00
Minor refactoring in Cardigann definition
This commit is contained in:
parent
427802a50e
commit
f0c5d8ceea
5 changed files with 30 additions and 30 deletions
|
@ -272,9 +272,9 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||
{
|
||||
IndexerCategory torznabCat = null;
|
||||
|
||||
if (categoryMapping.cat != null)
|
||||
if (categoryMapping.Cat != null)
|
||||
{
|
||||
torznabCat = NewznabStandardCategory.GetCatByName(categoryMapping.cat);
|
||||
torznabCat = NewznabStandardCategory.GetCatByName(categoryMapping.Cat);
|
||||
|
||||
if (torznabCat == null)
|
||||
{
|
||||
|
@ -282,7 +282,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||
}
|
||||
}
|
||||
|
||||
capabilities.Categories.AddCategoryMapping(categoryMapping.id, torznabCat, categoryMapping.desc);
|
||||
capabilities.Categories.AddCategoryMapping(categoryMapping.Id, torznabCat, categoryMapping.Desc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||
|
||||
protected virtual string SiteLink { get; private set; }
|
||||
|
||||
protected readonly IndexerCapabilitiesCategories _categories = new IndexerCapabilitiesCategories();
|
||||
protected readonly List<string> _defaultCategories = new List<string>();
|
||||
protected readonly IndexerCapabilitiesCategories _categories = new ();
|
||||
protected readonly List<string> _defaultCategories = new ();
|
||||
|
||||
protected readonly string[] OptionalFields = new string[] { "imdb", "imdbid", "tmdbid", "rageid", "tvdbid", "tvmazeid", "traktid", "doubanid", "poster", "banner", "description", "genre" };
|
||||
|
||||
|
@ -65,14 +65,16 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||
|
||||
SiteLink = definition.Links.First();
|
||||
|
||||
if (_definition.Caps.Categories != null)
|
||||
if (_definition.Caps.Categories != null && _definition.Caps.Categories.Any())
|
||||
{
|
||||
foreach (var category in _definition.Caps.Categories)
|
||||
{
|
||||
var cat = NewznabStandardCategory.GetCatByName(category.Value);
|
||||
|
||||
if (cat == null)
|
||||
{
|
||||
_logger.Error(string.Format("CardigannIndexer ({0}): invalid Torznab category for id {1}: {2}", _definition.Id, category.Key, category.Value));
|
||||
_logger.Error("CardigannIndexer ({0}): invalid Torznab category for id {1}: {2}", _definition.Id, category.Key, category.Value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -80,27 +82,29 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||
}
|
||||
}
|
||||
|
||||
if (_definition.Caps.Categorymappings != null)
|
||||
if (_definition.Caps.Categorymappings != null && _definition.Caps.Categorymappings.Any())
|
||||
{
|
||||
foreach (var categorymapping in _definition.Caps.Categorymappings)
|
||||
foreach (var categoryMapping in _definition.Caps.Categorymappings)
|
||||
{
|
||||
IndexerCategory torznabCat = null;
|
||||
|
||||
if (categorymapping.cat != null)
|
||||
if (categoryMapping.Cat != null)
|
||||
{
|
||||
torznabCat = NewznabStandardCategory.GetCatByName(categorymapping.cat);
|
||||
torznabCat = NewznabStandardCategory.GetCatByName(categoryMapping.Cat);
|
||||
|
||||
if (torznabCat == null)
|
||||
{
|
||||
_logger.Error(string.Format("CardigannIndexer ({0}): invalid Torznab category for id {1}: {2}", _definition.Id, categorymapping.id, categorymapping.cat));
|
||||
_logger.Error("CardigannIndexer ({0}): invalid Torznab category for id {1}: {2}", _definition.Id, categoryMapping.Id, categoryMapping.Cat);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
_categories.AddCategoryMapping(categorymapping.id, torznabCat, categorymapping.desc);
|
||||
_categories.AddCategoryMapping(categoryMapping.Id, torznabCat, categoryMapping.Desc);
|
||||
|
||||
if (categorymapping.Default)
|
||||
if (categoryMapping.Default)
|
||||
{
|
||||
_defaultCategories.Add(categorymapping.id);
|
||||
_defaultCategories.Add(categoryMapping.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,9 +66,9 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||
|
||||
public class CategorymappingBlock
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string cat { get; set; }
|
||||
public string desc { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Cat { get; set; }
|
||||
public string Desc { get; set; }
|
||||
public bool Default { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace NzbDrone.Core.Indexers
|
|||
catch
|
||||
{
|
||||
// Skip indexer if we fail in Cardigann mapping
|
||||
_logger.Debug("Indexer {0} has no definition", definition.Name);
|
||||
_logger.Debug("Indexer '{0}' has no definition", definition.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ namespace NzbDrone.Core.Indexers
|
|||
|
||||
private void MapCardigannCategories(IndexerDefinition def, CardigannDefinition defFile)
|
||||
{
|
||||
if (defFile.Caps.Categories != null)
|
||||
if (defFile.Caps.Categories != null && defFile.Caps.Categories.Any())
|
||||
{
|
||||
foreach (var category in defFile.Caps.Categories)
|
||||
{
|
||||
|
@ -142,27 +142,23 @@ namespace NzbDrone.Core.Indexers
|
|||
}
|
||||
}
|
||||
|
||||
if (defFile.Caps.Categorymappings != null)
|
||||
if (defFile.Caps.Categorymappings != null && defFile.Caps.Categorymappings.Any())
|
||||
{
|
||||
foreach (var categorymapping in defFile.Caps.Categorymappings)
|
||||
foreach (var categoryMapping in defFile.Caps.Categorymappings)
|
||||
{
|
||||
IndexerCategory torznabCat = null;
|
||||
|
||||
if (categorymapping.cat != null)
|
||||
if (categoryMapping.Cat != null)
|
||||
{
|
||||
torznabCat = NewznabStandardCategory.GetCatByName(categorymapping.cat);
|
||||
torznabCat = NewznabStandardCategory.GetCatByName(categoryMapping.Cat);
|
||||
|
||||
if (torznabCat == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
def.Capabilities.Categories.AddCategoryMapping(categorymapping.id, torznabCat, categorymapping.desc);
|
||||
|
||||
//if (categorymapping.Default)
|
||||
//{
|
||||
// DefaultCategories.Add(categorymapping.id);
|
||||
//}
|
||||
def.Capabilities.Categories.AddCategoryMapping(categoryMapping.Id, torznabCat, categoryMapping.Desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue