Merge pull request #68 from flightlevel/mtvseason

MoreThanTV: Fix season search
This commit is contained in:
flightlevel 2015-11-18 23:00:14 +11:00
commit 0b74f762a3
1 changed files with 16 additions and 6 deletions

View File

@ -12,6 +12,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
using Jackett.Models.IndexerConfig; using Jackett.Models.IndexerConfig;
@ -93,10 +94,17 @@ namespace Jackett.Indexers
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{ {
var releases = new List<ReleaseInfo>(); var releases = new List<ReleaseInfo>();
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(query.GetQueryString()); string qryString = query.GetQueryString();
WebClientStringResult response = null;
response = await RequestStringWithCookiesAndRetry(episodeSearchUrl); Match matchQry = new Regex(@".*\s[Ss]{1}\d{2}$").Match(qryString);
if (matchQry.Success)
{
//If search string ends in S## eg. S03 (season search) add an asterix to search term
qryString += "*";
}
var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(qryString);
WebClientStringResult response = await RequestStringWithCookiesAndRetry(episodeSearchUrl);
try try
{ {
@ -112,16 +120,18 @@ namespace Jackett.Indexers
pubDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Utc).ToLocalTime(); pubDate = DateTime.SpecifyKind(pubDate, DateTimeKind.Utc).ToLocalTime();
} }
var groupName = (string)r["groupName"]; string groupName = (string)r["groupName"];
if (r["torrents"] is JArray) if (r["torrents"] is JArray)
{ {
string showName = (string) r["artist"];
foreach (JObject t in r["torrents"]) foreach (JObject t in r["torrents"])
{ {
var release = new ReleaseInfo(); var release = new ReleaseInfo();
release.PublishDate = pubDate; release.PublishDate = pubDate;
release.Title = groupName; release.Title = $"{showName} {groupName}";
release.Description = groupName; release.Description = $"{showName} {groupName}";
FillReleaseInfoFromJson(release, t); FillReleaseInfoFromJson(release, t);
releases.Add(release); releases.Add(release);
} }