mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-24 22:55:21 -04:00
Map Cardigann capabilities from meta definition
This commit is contained in:
@@ -166,7 +166,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
||||
SupportsSearch = SupportsSearch,
|
||||
SupportsRedirect = SupportsRedirect,
|
||||
SupportsPagination = SupportsPagination,
|
||||
Capabilities = new IndexerCapabilities(),
|
||||
Capabilities = ParseCardigannCapabilities(definition),
|
||||
ExtraFields = settings
|
||||
};
|
||||
}
|
||||
@@ -238,5 +238,55 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IndexerCapabilities ParseCardigannCapabilities(CardigannMetaDefinition definition)
|
||||
{
|
||||
var capabilities = new IndexerCapabilities();
|
||||
|
||||
if (definition.Caps == null)
|
||||
{
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
capabilities.ParseCardigannSearchModes(definition.Caps.Modes);
|
||||
capabilities.SupportsRawSearch = definition.Caps.Allowrawsearch;
|
||||
|
||||
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)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
capabilities.Categories.AddCategoryMapping(category.Key, cat);
|
||||
}
|
||||
}
|
||||
|
||||
if (definition.Caps.Categorymappings != null && definition.Caps.Categorymappings.Any())
|
||||
{
|
||||
foreach (var categoryMapping in definition.Caps.Categorymappings)
|
||||
{
|
||||
IndexerCategory torznabCat = null;
|
||||
|
||||
if (categoryMapping.cat != null)
|
||||
{
|
||||
torznabCat = NewznabStandardCategory.GetCatByName(categoryMapping.cat);
|
||||
|
||||
if (torznabCat == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
capabilities.Categories.AddCategoryMapping(categoryMapping.id, torznabCat, categoryMapping.desc);
|
||||
}
|
||||
}
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
||||
public List<string> Links { get; set; }
|
||||
public List<string> Legacylinks { get; set; }
|
||||
public List<SettingsField> Settings { get; set; }
|
||||
public string Sha { get; set; }
|
||||
public LoginBlock Login { get; set; }
|
||||
public CapabilitiesBlock Caps { get; set; }
|
||||
public string Sha { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user