2015-04-13 06:25:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Specialized;
|
2015-04-18 20:18:14 +00:00
|
|
|
|
using System.Globalization;
|
2015-04-13 06:25:21 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Jackett
|
|
|
|
|
{
|
|
|
|
|
public class TorznabQuery
|
|
|
|
|
{
|
|
|
|
|
public string QueryType { get; private set; }
|
|
|
|
|
public string[] Categories { get; private set; }
|
|
|
|
|
public int Extended { get; private set; }
|
|
|
|
|
public string ApiKey { get; private set; }
|
|
|
|
|
public int Limit { get; private set; }
|
|
|
|
|
public int Offset { get; private set; }
|
|
|
|
|
public int RageID { get; private set; }
|
|
|
|
|
public int Season { get; private set; }
|
2015-04-18 20:18:14 +00:00
|
|
|
|
public string Episode { get; private set; }
|
|
|
|
|
public string[] ShowTitles { get; set; }
|
2015-04-26 06:51:52 +00:00
|
|
|
|
public string SearchTerm { get; set; }
|
2015-04-18 20:18:14 +00:00
|
|
|
|
|
|
|
|
|
public string GetEpisodeSearchString()
|
|
|
|
|
{
|
|
|
|
|
if (Season == 0)
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
string episodeString;
|
|
|
|
|
DateTime showDate;
|
|
|
|
|
if (DateTime.TryParseExact(string.Format("{0} {1}", Season, Episode), "yyyy MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out showDate))
|
|
|
|
|
episodeString = showDate.ToString("yyyy.MM.dd");
|
2015-04-20 05:10:50 +00:00
|
|
|
|
else if (string.IsNullOrEmpty(Episode))
|
|
|
|
|
episodeString = string.Format("S{0:00}", Season);
|
2015-04-18 20:18:14 +00:00
|
|
|
|
else
|
|
|
|
|
episodeString = string.Format("S{0:00}E{1:00}", Season, int.Parse(Episode));
|
|
|
|
|
|
|
|
|
|
return episodeString;
|
|
|
|
|
}
|
2015-04-13 06:25:21 +00:00
|
|
|
|
|
|
|
|
|
public static TorznabQuery FromHttpQuery(NameValueCollection query)
|
|
|
|
|
{
|
2015-04-16 06:04:28 +00:00
|
|
|
|
|
2015-04-13 06:25:21 +00:00
|
|
|
|
//{t=tvsearch&cat=5030%2c5040&extended=1&apikey=test&offset=0&limit=100&rid=24493&season=5&ep=1}
|
|
|
|
|
var q = new TorznabQuery();
|
|
|
|
|
q.QueryType = query["t"];
|
2015-04-26 06:51:52 +00:00
|
|
|
|
q.SearchTerm = query["q"];
|
2015-04-13 06:25:21 +00:00
|
|
|
|
q.Categories = query["cat"].Split(',');
|
|
|
|
|
q.Extended = int.Parse(query["extended"]);
|
|
|
|
|
q.ApiKey = query["apikey"];
|
|
|
|
|
q.Limit = int.Parse(query["limit"]);
|
|
|
|
|
q.Offset = int.Parse(query["offset"]);
|
2015-04-16 06:04:28 +00:00
|
|
|
|
|
|
|
|
|
int temp;
|
|
|
|
|
if (int.TryParse(query["rid"], out temp))
|
|
|
|
|
q.RageID = temp;
|
|
|
|
|
if (int.TryParse(query["season"], out temp))
|
|
|
|
|
q.Season = temp;
|
2015-04-18 20:18:14 +00:00
|
|
|
|
|
|
|
|
|
q.Episode = query["ep"];
|
2015-04-16 06:04:28 +00:00
|
|
|
|
|
2015-04-13 06:25:21 +00:00
|
|
|
|
return q;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|