Add indexer: Immortalseed. Add category mapping framework.

This commit is contained in:
KZ
2015-07-29 00:10:04 +01:00
parent 37587bdc7e
commit ea069810a5
46 changed files with 494 additions and 170 deletions

View File

@@ -29,6 +29,8 @@ namespace Jackett.Indexers
protected IWebClient webclient;
protected string cookieHeader = "";
private List<CategoryMapping> categoryMapping = new List<CategoryMapping>();
public BaseIndexer(string name, string link, string description, IIndexerManagerService manager, IWebClient client, Logger logger, TorznabCapabilities caps = null)
{
if (!link.EndsWith("/"))
@@ -46,6 +48,19 @@ namespace Jackett.Indexers
TorznabCaps = caps;
}
protected int MapTrackerCatToNewznab(string input)
{
if (null != input) {
input = input.ToLowerInvariant();
var mapping = categoryMapping.Where(m => m.TrackerCategory == input).FirstOrDefault();
if(mapping!= null)
{
return mapping.NewzNabCategory;
}
}
return 0;
}
public static string GetIndexerID(Type type)
{
return StringUtil.StripNonAlphaNumeric(type.Name.ToLowerInvariant());
@@ -239,5 +254,40 @@ namespace Jackett.Indexers
onError();
}
}
public virtual IEnumerable<ReleaseInfo> FilterResults(TorznabQuery query, IEnumerable<ReleaseInfo> results)
{
foreach(var result in results)
{
if(query.Categories.Length == 0 || query.Categories.Contains(result.Category) || result.Category == 0 || TorznabCatType.QueryContainsParentCategory(query.Categories, result.Category))
{
yield return result;
}
}
}
protected void AddCategoryMapping(string trackerCategory, int newznabCategory)
{
categoryMapping.Add(new CategoryMapping(trackerCategory, newznabCategory));
}
protected void AddCategoryMapping(int trackerCategory, TorznabCategory newznabCategory)
{
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory.ID));
if (!TorznabCaps.Categories.Contains(newznabCategory))
TorznabCaps.Categories.Add(newznabCategory);
}
protected void AddCategoryMapping(string trackerCategory, TorznabCategory newznabCategory)
{
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory.ID));
if (!TorznabCaps.Categories.Contains(newznabCategory))
TorznabCaps.Categories.Add(newznabCategory);
}
protected void AddCategoryMapping(int trackerCategory, int newznabCategory)
{
categoryMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory));
}
}
}