Metasearch , fix for empty queries being converted to a single space, parent categories are now autoexpanded.

This commit is contained in:
KZ
2015-08-14 22:20:51 +01:00
parent c45929fe43
commit 98446222c9
39 changed files with 465 additions and 119 deletions

View File

@@ -47,6 +47,11 @@ namespace Jackett.Models
Categories = new int[0];
}
public string GetQueryString()
{
return (SanitizedSearchTerm + " " + GetEpisodeSearchString()).Trim();
}
public string GetEpisodeSearchString()
{
if (Season == 0)
@@ -118,5 +123,24 @@ namespace Jackett.Models
return q;
}
public void ExpandCatsToSubCats()
{
if (Categories.Count() == 0)
return;
var newCatList = new List<int>();
newCatList.AddRange(Categories);
foreach (var cat in Categories)
{
var majorCat = TorznabCatType.AllCats.Where(c => c.ID == cat).FirstOrDefault();
// If we search for TV we should also search for all sub cats
if (majorCat != null)
{
newCatList.AddRange(majorCat.SubCategories.Select(s => s.ID));
}
}
Categories = newCatList.Distinct().ToArray();
}
}
}