2015-08-12 17:31:59 +00:00
|
|
|
|
using System.Linq;
|
2015-07-28 23:10:04 +00:00
|
|
|
|
|
|
|
|
|
namespace Jackett.Models
|
|
|
|
|
{
|
2015-08-12 17:31:59 +00:00
|
|
|
|
public static partial class TorznabCatType
|
2015-07-28 23:10:04 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static bool QueryContainsParentCategory(int[] queryCats, int releaseCat)
|
|
|
|
|
{
|
2015-08-12 17:31:59 +00:00
|
|
|
|
var cat = AllCats.FirstOrDefault(c => c.ID == releaseCat);
|
|
|
|
|
if (cat != null && queryCats != null)
|
2015-07-28 23:10:04 +00:00
|
|
|
|
{
|
2015-08-12 17:31:59 +00:00
|
|
|
|
return cat.SubCategories.Any(c => queryCats.Contains(c.ID));
|
2015-07-28 23:10:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetCatDesc(int newznabcat)
|
|
|
|
|
{
|
2015-08-12 17:31:59 +00:00
|
|
|
|
var cat = AllCats.FirstOrDefault(c => c.ID == newznabcat);
|
|
|
|
|
if (cat != null)
|
2015-07-28 23:10:04 +00:00
|
|
|
|
{
|
2015-08-12 17:31:59 +00:00
|
|
|
|
return cat.Name;
|
2015-07-28 23:10:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 07:30:03 +00:00
|
|
|
|
public static string NormalizeCatName(string name)
|
|
|
|
|
{
|
|
|
|
|
return name.Replace(" ", "").ToLower();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static TorznabCategory GetCatByName(string name)
|
|
|
|
|
{
|
|
|
|
|
var cat = AllCats.FirstOrDefault(c => NormalizeCatName(c.Name) == NormalizeCatName(name));
|
|
|
|
|
if (cat != null)
|
|
|
|
|
{
|
|
|
|
|
return cat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-28 23:10:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|