Skip to content

Commit

Permalink
Merge branch 'master' into feature/cloudproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
abeloin committed Nov 29, 2020
2 parents 8349982 + 0d35f3a commit c496942
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/Jackett.Common/Definitions/frozenlayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ search:
- name: re_replace
args: ["- Episodio ([0-9]*)", "$1"]
- name: append
args: " [spanish]"
args: " Spanish"
details:
selector: td.tit a
attribute: href
Expand Down
4 changes: 2 additions & 2 deletions src/Jackett.Common/Definitions/hdcity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ search:
optional: true
filters:
- name: append
args: " [English]"
args: " English"
- name: re_replace
args: ["(?i)T[\\s-_]?(\\d{1,2})\\b", " S$1 "]
- name: re_replace
Expand All @@ -184,7 +184,7 @@ search:
optional: true
filters:
- name: append
args: " [Spanish]"
args: " Spanish"
- name: re_replace
args: ["(?i)T[\\s-_]?(\\d{1,2})\\b", " S$1 "]
- name: re_replace
Expand Down
2 changes: 1 addition & 1 deletion src/Jackett.Common/Definitions/hdspain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ search:
- name: prepend
args: "{{ .Result.extras }} "
- name: append
args: " [Spanish]"
args: " Spanish"
- name: re_replace
args: ["(?i)T(\\d{1,2})\\b", "S$1"]
details:
Expand Down
2 changes: 1 addition & 1 deletion src/Jackett.Common/Definitions/nyaasi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ search:
optional: true
filters:
- name: append
args: " [Spanish]"
args: " Spanish"
details:
selector: td:nth-child(2) a:last-of-type
attribute: href
Expand Down
5 changes: 1 addition & 4 deletions src/Jackett.Common/Indexers/BitCityReloaded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,12 @@ public BitCityReloaded(IIndexerConfigurationService configService, WebClient wc,
client: wc,
logger: l,
p: ps,
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay())
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay("Only the results from the first search result page are shown, adjust your profile settings to show a reasonable amount (it looks like there's no maximum)."))
{
Encoding = Encoding.GetEncoding("iso-8859-1");
Language = "de-de";
Type = "private";

configData.DisplayText.Value = "Only the results from the first search result page are shown, adjust your profile settings to show a reasonable amount (it looks like there's no maximum).";
configData.DisplayText.Name = "Notice";

AddCategoryMapping(1, TorznabCatType.Other, "Other/Anderes");
AddCategoryMapping(2, TorznabCatType.TVAnime, "TV/Anime");
AddCategoryMapping(34, TorznabCatType.PC, "Appz/Linux");
Expand Down
12 changes: 9 additions & 3 deletions src/Jackett.Common/Indexers/Cinecalidad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,16 @@ public override async Task<byte[]> Download(Uri link)
{
var parser = new HtmlParser();
var dom = parser.ParseDocument(results.ContentString);
var preotectedLink = dom.QuerySelector("a[service=BitTorrent]").GetAttribute("href");
preotectedLink = SiteLink + preotectedLink.TrimStart('/');
var protectedLink = dom.QuerySelector("a[service=BitTorrent]").GetAttribute("href");
if (protectedLink.Contains("/ouo.io/"))
{
// protected link =>
// https://ouo.io/qs/qsW6rCh4?s=https://www.cinecalidad.is/protect/v2.php?i=A8--9InL&title=High+Life+%282018%29
var linkParts = protectedLink.Split('=');
protectedLink = protectedLink.Replace(linkParts[0] + "=", "");
}

results = await RequestWithCookiesAsync(preotectedLink);
results = await RequestWithCookiesAsync(protectedLink);
dom = parser.ParseDocument(results.ContentString);
var magnetUrl = dom.QuerySelector("a[href^=magnet]").GetAttribute("href");
return await base.Download(new Uri(magnetUrl));
Expand Down
4 changes: 3 additions & 1 deletion src/Jackett.Common/Indexers/Magnetico.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public Magnetico(IIndexerConfigurationService configService, WebClient wc, Logge
client: wc,
logger: l,
p: ps,
configData: new ConfigurationDataBasicLogin("Configure the URL, username and password from your local magneticow.<br>Default credentials are: username=username, password=password."))
configData: new ConfigurationDataBasicLogin("Configure the URL, username and password from your local magneticow.<br>" +
"Default credentials are: username=username, password=password.<br>" +
"If you have many torrents, it is recommended to use PostgreSQL database to make queries faster. With SQLite, timeouts may occur."))

{
Encoding = Encoding.UTF8;
Expand Down
5 changes: 1 addition & 4 deletions src/Jackett.Common/Indexers/PirateTheNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,12 @@ public PirateTheNet(IIndexerConfigurationService configService, WebClient w, Log
client: w,
logger: l,
p: ps,
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay())
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay("Only the results from the first search result page are shown, adjust your profile settings to show the maximum."))
{
Encoding = Encoding.UTF8;
Language = "en-us";
Type = "private";

configData.DisplayText.Value = "Only the results from the first search result page are shown, adjust your profile settings to show the maximum.";
configData.DisplayText.Name = "Notice";

AddCategoryMapping("1080P", TorznabCatType.MoviesHD, "1080P");
AddCategoryMapping("2160P", TorznabCatType.MoviesHD, "2160P");
AddCategoryMapping("720P", TorznabCatType.MoviesHD, "720P");
Expand Down
83 changes: 77 additions & 6 deletions src/Jackett.Common/Indexers/TorrentSeeds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Jackett.Common.Models.IndexerConfig;
using Jackett.Common.Services.Interfaces;
using Jackett.Common.Utils;
using Jackett.Common.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;

Expand Down Expand Up @@ -54,7 +55,7 @@ public TorrentSeeds(IIndexerConfigurationService configService, Utils.Clients.We
client: wc,
logger: l,
p: ps,
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay())
configData: new ConfigurationDataBasicLoginWithRSSAndDisplay("For best results, change the <b>Torrents per page:</b> setting to <b>100</b> on your account profile."))
{
Encoding = Encoding.UTF8;
Language = "en-us";
Expand Down Expand Up @@ -139,8 +140,6 @@ await ConfigureIfOK(

protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();

// remove operator characters
var cleanSearchString = Regex.Replace(query.GetQueryString().Trim(), "[ _.+-]+", " ", RegexOptions.Compiled);

Expand All @@ -156,16 +155,87 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
queryCollection.Add("query", cleanSearchString);
foreach (var cat in MapTorznabCapsToTrackers(query))
queryCollection.Add($"cat[{cat}]", "1");

searchUrl += "?" + queryCollection.GetQueryString();
var response = await RequestWithCookiesAndRetryAsync(searchUrl);

// handle cookie expiration
var results = response.ContentString;
if (!results.Contains("/logout.php?"))
if ((response.IsRedirect && response.RedirectingTo.Contains("/login.php?")) ||
(!response.IsRedirect && !results.Contains("/logout.php?")))
{
await ApplyConfiguration(null);
await ApplyConfiguration(null); // re-login
response = await RequestWithCookiesAndRetryAsync(searchUrl);
results = response.ContentString;
}

// handle single entries
if (response.IsRedirect)
{
var detailsLink = new Uri(response.RedirectingTo);
await FollowIfRedirect(response, accumulateCookies: true);
return ParseSingleResult(response, detailsLink);
}

return ParseMultiResult(response);
}

private List<ReleaseInfo> ParseSingleResult(WebResult response, Uri detailsLink)
{
var releases = new List<ReleaseInfo>();
var results = response.ContentString;

try
{
var parser = new HtmlParser();
var dom = parser.ParseDocument(results);
var content = dom.QuerySelector("tbody:has(script)");
var release = new ReleaseInfo();
release.MinimumRatio = 1;
release.MinimumSeedTime = 72 * 60 * 60;
var catStr = content.QuerySelector("tr:has(td:contains(\"Type\"))").Children[1].TextContent;
release.Category = MapTrackerCatDescToNewznab(catStr);
var qLink = content.QuerySelector("tr:has(td:contains(\"Download\"))")
.QuerySelector("a[href*=\"download.php?torrent=\"]");
release.Link = new Uri(SiteLink + qLink.GetAttribute("href"));
release.Title = dom.QuerySelector("h1").TextContent.Trim();
release.Details = detailsLink;
release.Guid = detailsLink;
var qSize = content.QuerySelector("tr:has(td.heading:contains(\"Size\"))").Children[1].TextContent
.Split('(')[0].Trim();
release.Size = ReleaseInfo.GetBytes(qSize);
var peerStats = content.QuerySelector("tr:has(td:has(a[href^=\"./peerlist_xbt.php?id=\"]))").Children[1]
.TextContent.Split(',');
var qSeeders = peerStats[0].Replace(" seeder(s)", "").Trim();
var qLeechers = peerStats[1].Split('=')[0].Replace(" leecher(s) ", "").Trim();
release.Seeders = ParseUtil.CoerceInt(qSeeders);
release.Peers = ParseUtil.CoerceInt(qLeechers) + release.Seeders;
var rawDateStr = content.QuerySelector("tr:has(td:contains(\"Added\"))").Children[1].TextContent;
var dateUpped = DateTimeUtil.FromUnknown(rawDateStr.Replace(",", string.Empty));

// Mar 4 2020, 05:47 AM
release.PublishDate = dateUpped.ToLocalTime();
var qGrabs = content.QuerySelector("tr:has(td:contains(\"Snatched\"))").Children[1];
release.Grabs = ParseUtil.CoerceInt(qGrabs.TextContent.Replace(" time(s)", ""));
var qFiles = content.QuerySelector("tr:has(td:has(a[href^=\"./filelist.php?id=\"]))").Children[1];
release.Files = ParseUtil.CoerceInt(qFiles.TextContent.Replace(" files", ""));
var qRatio = content.QuerySelector("tr:has(td:contains(\"Ratio After Download\"))").Children[1];
release.DownloadVolumeFactor = qRatio.QuerySelector("del") != null ? 0 : 1;
release.UploadVolumeFactor = 1;
releases.Add(release);
}
catch (Exception ex)
{
OnParseError(results, ex);
}

return releases;
}

private List<ReleaseInfo> ParseMultiResult(WebResult response)
{
var releases = new List<ReleaseInfo>();
var results = response.ContentString;

try
{
var parser = new HtmlParser();
Expand Down Expand Up @@ -215,5 +285,6 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer

return releases;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ public class ConfigurationDataBasicLoginWithRSSAndDisplay : ConfigurationData
public StringItem Username { get; private set; }
public StringItem Password { get; private set; }
public HiddenItem RSSKey { get; private set; }
public DisplayItem DisplayText { get; private set; }
public DisplayItem Instructions { get; private set; }

public ConfigurationDataBasicLoginWithRSSAndDisplay()
public ConfigurationDataBasicLoginWithRSSAndDisplay(string instructionMessageOptional = null)
{
Username = new StringItem { Name = "Username" };
Password = new StringItem { Name = "Password" };
RSSKey = new HiddenItem { Name = "RSSKey" };
DisplayText = new DisplayItem("") { Name = "" };
Instructions = new DisplayItem(instructionMessageOptional) { Name = "" };
}
}
}
14 changes: 12 additions & 2 deletions src/Jackett.Common/Utils/Clients/WebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,24 @@ protected virtual void PrepareRequest(WebRequest request)

public virtual async Task<WebResult> GetResultAsync(WebRequest request)
{
logger.Debug($"WebClient({ClientType}).GetResultAsync(Method: {request.Type} Url: {request.Url})");
if (logger.IsDebugEnabled) // performance optimization
{
var postData = "";
if (request.Type == RequestType.POST)
{
var lines = request.PostData.Select(kvp => kvp.Key + "=" + kvp.Value);
postData = $" PostData: {{{string.Join(", ", lines)}}} RawBody: {request.RawBody}";
}
logger.Debug($"WebClient({ClientType}).GetResultAsync(Method: {request.Type} Url: {request.Url}{postData})");
}

PrepareRequest(request);
await DelayRequest(request);
var result = await Run(request);
lastRequest = DateTime.Now;
result.Request = request;

if (logger.IsDebugEnabled) // optimization to compute result.ContentString in debug mode only
if (logger.IsDebugEnabled) // performance optimization to compute result.ContentString in debug mode only
{
var body = "";
var bodySize = 0;
Expand Down

0 comments on commit c496942

Please sign in to comment.