mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
CategoryMapping: Add support for the tracker category description
This commit is contained in:
@@ -118,7 +118,6 @@ namespace Jackett.Indexers
|
||||
{
|
||||
if (null != input)
|
||||
{
|
||||
input = input.ToLowerInvariant();
|
||||
var mapping = categoryMapping.Where(m => m.TrackerCategory.ToLowerInvariant() == input.ToLowerInvariant()).FirstOrDefault();
|
||||
if (mapping != null)
|
||||
{
|
||||
@@ -128,6 +127,19 @@ namespace Jackett.Indexers
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int MapTrackerCatDescToNewznab(string input)
|
||||
{
|
||||
if (null != input)
|
||||
{
|
||||
var mapping = categoryMapping.Where(m => m.TrackerCategoryDesc.ToLowerInvariant() == input.ToLowerInvariant()).FirstOrDefault();
|
||||
if (mapping != null)
|
||||
{
|
||||
return mapping.NewzNabCategory;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static string GetIndexerID(Type type)
|
||||
{
|
||||
return StringUtil.StripNonAlphaNumeric(type.Name.ToLowerInvariant());
|
||||
@@ -484,16 +496,16 @@ namespace Jackett.Indexers
|
||||
}
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(string trackerCategory, TorznabCategory newznabCategory)
|
||||
protected void AddCategoryMapping(string trackerCategory, TorznabCategory newznabCategory, string trackerCategoryDesc = null)
|
||||
{
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory, newznabCategory.ID));
|
||||
categoryMapping.Add(new CategoryMapping(trackerCategory, trackerCategoryDesc, newznabCategory.ID));
|
||||
if (!TorznabCaps.Categories.Contains(newznabCategory))
|
||||
TorznabCaps.Categories.Add(newznabCategory);
|
||||
}
|
||||
|
||||
protected void AddCategoryMapping(int trackerCategory, TorznabCategory newznabCategory)
|
||||
protected void AddCategoryMapping(int trackerCategory, TorznabCategory newznabCategory, string trackerCategoryDesc = null)
|
||||
{
|
||||
AddCategoryMapping(trackerCategory.ToString(), newznabCategory);
|
||||
AddCategoryMapping(trackerCategory.ToString(), newznabCategory, trackerCategoryDesc);
|
||||
}
|
||||
|
||||
protected void AddMultiCategoryMapping(TorznabCategory newznabCategory, params int[] trackerCategories)
|
||||
|
@@ -166,7 +166,7 @@ namespace Jackett.Indexers
|
||||
|
||||
protected void AddResultCategoryMapping(string trackerCategory, TorznabCategory newznabCategory)
|
||||
{
|
||||
resultMapping.Add(new CategoryMapping(trackerCategory.ToString(), newznabCategory.ID));
|
||||
resultMapping.Add(new CategoryMapping(trackerCategory.ToString(), null, newznabCategory.ID));
|
||||
if (!TorznabCaps.Categories.Contains(newznabCategory))
|
||||
TorznabCaps.Categories.Add(newznabCategory);
|
||||
}
|
||||
|
@@ -8,13 +8,15 @@ namespace Jackett.Models
|
||||
{
|
||||
class CategoryMapping
|
||||
{
|
||||
public CategoryMapping(string trackerCat, int newzCat)
|
||||
public CategoryMapping(string trackerCat, string trackerCatDesc, int newzCat)
|
||||
{
|
||||
TrackerCategory = trackerCat;
|
||||
TrackerCategoryDesc = trackerCatDesc;
|
||||
NewzNabCategory = newzCat;
|
||||
}
|
||||
|
||||
public string TrackerCategory { get; private set; }
|
||||
public string TrackerCategoryDesc { get; private set; }
|
||||
public int NewzNabCategory { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,13 @@ namespace Jackett.Utils
|
||||
{
|
||||
public static string RFC1123ZPattern = "ddd, dd MMM yyyy HH':'mm':'ss z";
|
||||
|
||||
public static DateTime UnixTimestampToDateTime(long unixTime)
|
||||
{
|
||||
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
|
||||
dt = dt.AddSeconds(unixTime).ToLocalTime();
|
||||
return dt;
|
||||
}
|
||||
|
||||
public static DateTime UnixTimestampToDateTime(double unixTime)
|
||||
{
|
||||
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
|
||||
@@ -170,9 +177,7 @@ namespace Jackett.Utils
|
||||
{
|
||||
// try parsing the str as an unix timestamp
|
||||
var unixTimeStamp = long.Parse(str);
|
||||
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
|
||||
dt = dt.AddSeconds(unixTimeStamp).ToLocalTime();
|
||||
return dt;
|
||||
return UnixTimestampToDateTime(unixTimeStamp);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
|
Reference in New Issue
Block a user