mirror of https://github.com/Jackett/Jackett
Merge branch 'master' of https://github.com/Jackett/Jackett
This commit is contained in:
commit
2dc5edbb55
|
@ -34,6 +34,7 @@ namespace Jackett.Common.Indexers
|
|||
public int? EpisodeTo;
|
||||
}
|
||||
|
||||
private static Uri SiteLinkUri = new Uri("http://www.tvsinpagar.com/");
|
||||
private ReleaseInfo _mostRecentRelease;
|
||||
private Regex _searchStringRegex = new Regex(@"(.+?)S0?(\d+)(E0?(\d+))?$", RegexOptions.IgnoreCase);
|
||||
private Regex _titleListRegex = new Regex(@"Serie(.+?)(Temporada(.+?)(\d+)(.+?))?Capitulos?(.+?)(\d+)((.+?)(\d+))?(.+?)-(.+?)Calidad(.*)", RegexOptions.IgnoreCase);
|
||||
|
@ -52,7 +53,7 @@ namespace Jackett.Common.Indexers
|
|||
public Newpct(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
||||
: base(name: "Newpct",
|
||||
description: "Newpct - descargar torrent peliculas, series",
|
||||
link: "http://www.tvsinpagar.com/",
|
||||
link: SiteLinkUri.AbsoluteUri,
|
||||
caps: new TorznabCapabilities(TorznabCatType.TV,
|
||||
TorznabCatType.TVSD,
|
||||
TorznabCatType.TVHD,
|
||||
|
@ -75,6 +76,7 @@ namespace Jackett.Common.Indexers
|
|||
{
|
||||
configData.LoadValuesFromJson(configJson);
|
||||
var releases = await PerformQuery(new TorznabQuery());
|
||||
SiteLinkUri = new Uri(configData.SiteLink.Value);
|
||||
|
||||
await ConfigureIfOK(string.Empty, releases.Count() > 0, () =>
|
||||
{
|
||||
|
@ -109,14 +111,13 @@ namespace Jackett.Common.Indexers
|
|||
var releases = new List<ReleaseInfo>();
|
||||
|
||||
bool rssMode = string.IsNullOrEmpty(query.SanitizedSearchTerm);
|
||||
Uri siteLinkUri = new Uri(configData.SiteLink.Value);
|
||||
|
||||
if (rssMode)
|
||||
{
|
||||
int pg = 1;
|
||||
while (pg <= _maxDailyPages)
|
||||
{
|
||||
Uri url = new Uri(siteLinkUri, string.Format(_dailyUrl, pg));
|
||||
Uri url = new Uri(SiteLinkUri, string.Format(_dailyUrl, pg));
|
||||
var results = await RequestStringWithCookies(url.AbsoluteUri);
|
||||
|
||||
var items = ParseDailyContent(results.Content);
|
||||
|
@ -142,6 +143,15 @@ namespace Jackett.Common.Indexers
|
|||
bool isTvSearch = query.Categories == null || query.Categories.Length == 0 ||
|
||||
query.Categories.Any(c => _allTvCategories.Contains(c));
|
||||
if (isTvSearch)
|
||||
{
|
||||
return await TvSearch(query);
|
||||
}
|
||||
}
|
||||
|
||||
return releases;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<ReleaseInfo>> TvSearch(TorznabQuery query)
|
||||
{
|
||||
var newpctReleases = new List<ReleaseInfo>();
|
||||
|
||||
|
@ -180,18 +190,50 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
if (!cacheFound)
|
||||
{
|
||||
IEnumerable<string> lettersUrl;
|
||||
if (!((BoolItem)configData.GetDynamic("IncludeVo")).Value)
|
||||
lettersUrl = _seriesLetterUrls;
|
||||
else
|
||||
lettersUrl = _seriesLetterUrls.Concat(_seriesVOLetterUrls);
|
||||
|
||||
string seriesLetter = !char.IsDigit(seriesName[0]) ? seriesName[0].ToString() : "0-9";
|
||||
//Search series url
|
||||
foreach (string urlFormat in lettersUrl)
|
||||
foreach (Uri seriesListUrl in SeriesListUris(seriesName))
|
||||
{
|
||||
Uri seriesListUrl = new Uri(siteLinkUri, string.Format(urlFormat, seriesLetter.ToLower()));
|
||||
var results = await RequestStringWithCookies(seriesListUrl.AbsoluteUri);
|
||||
newpctReleases.AddRange(await GetReleasesFromUri(seriesListUrl, seriesName));
|
||||
}
|
||||
|
||||
//Sonarr removes "the" from shows. If there is nothing try prepending "the"
|
||||
if (newpctReleases.Count == 0 && !(seriesName.ToLower().StartsWith("the")))
|
||||
{
|
||||
seriesName = "The " + seriesName;
|
||||
foreach (Uri seriesListUrl in SeriesListUris(seriesName))
|
||||
{
|
||||
newpctReleases.AddRange(await GetReleasesFromUri(seriesListUrl, seriesName));
|
||||
}
|
||||
}
|
||||
|
||||
//Cache ALL episodes
|
||||
lock (cache)
|
||||
{
|
||||
cache.Add(new CachedQueryResult(seriesName.ToLower(), newpctReleases));
|
||||
}
|
||||
}
|
||||
|
||||
//Filter only episodes needed
|
||||
return newpctReleases.Where(r =>
|
||||
{
|
||||
NewpctRelease nr = r as NewpctRelease;
|
||||
return nr.Season.HasValue != season.HasValue || //Can't determine if same season
|
||||
nr.Season.HasValue && season.Value == nr.Season.Value && //Same season and ...
|
||||
(
|
||||
nr.Episode.HasValue != episode.HasValue || //Can't determine if same episode
|
||||
nr.Episode.HasValue &&
|
||||
(
|
||||
nr.Episode.Value == episode.Value || //Same episode
|
||||
nr.EpisodeTo.HasValue && episode.Value >= nr.Episode.Value && episode.Value <= nr.EpisodeTo.Value //Episode in interval
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<ReleaseInfo>> GetReleasesFromUri(Uri uri, string seriesName)
|
||||
{
|
||||
var newpctReleases = new List<ReleaseInfo>();
|
||||
var results = await RequestStringWithCookies(uri.AbsoluteUri);
|
||||
|
||||
//Episodes list
|
||||
string seriesEpisodesUrl = ParseSeriesListContent(results.Content, seriesName);
|
||||
|
@ -212,34 +254,25 @@ namespace Jackett.Common.Indexers
|
|||
pg++;
|
||||
}
|
||||
}
|
||||
return newpctReleases;
|
||||
}
|
||||
|
||||
//Cache ALL episodes
|
||||
lock (cache)
|
||||
private IEnumerable<Uri> SeriesListUris(string seriesName)
|
||||
{
|
||||
cache.Add(new CachedQueryResult(seriesName.ToLower(), newpctReleases));
|
||||
}
|
||||
}
|
||||
|
||||
//Filter only episodes needed
|
||||
releases.AddRange(newpctReleases.Where(r =>
|
||||
IEnumerable<string> lettersUrl;
|
||||
if (!((BoolItem)configData.GetDynamic("IncludeVo")).Value)
|
||||
{
|
||||
NewpctRelease nr = r as NewpctRelease;
|
||||
return nr.Season.HasValue != season.HasValue || //Can't determine if same season
|
||||
nr.Season.HasValue && season.Value == nr.Season.Value && //Same season and ...
|
||||
(
|
||||
nr.Episode.HasValue != episode.HasValue || //Can't determine if same episode
|
||||
nr.Episode.HasValue &&
|
||||
(
|
||||
nr.Episode.Value == episode.Value || //Same episode
|
||||
nr.EpisodeTo.HasValue && episode.Value >= nr.Episode.Value && episode.Value <= nr.EpisodeTo.Value //Episode in interval
|
||||
)
|
||||
);
|
||||
}));
|
||||
lettersUrl = _seriesLetterUrls;
|
||||
}
|
||||
else
|
||||
{
|
||||
lettersUrl = _seriesLetterUrls.Concat(_seriesVOLetterUrls);
|
||||
}
|
||||
|
||||
return releases;
|
||||
string seriesLetter = !char.IsDigit(seriesName[0]) ? seriesName[0].ToString() : "0-9";
|
||||
return lettersUrl.Select(urlFormat =>
|
||||
{
|
||||
return new Uri(SiteLinkUri, string.Format(urlFormat, seriesLetter.ToLower()));
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerable<NewpctRelease> ParseDailyContent(string content)
|
||||
|
@ -409,6 +442,7 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
result.Size = size;
|
||||
result.Link = new Uri(detailsUrl);
|
||||
result.Guid = result.Link;
|
||||
result.PublishDate = publishDate;
|
||||
result.Seeders = 1;
|
||||
result.Peers = 1;
|
||||
|
|
Loading…
Reference in New Issue