mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
This commit is contained in:
@@ -24,14 +24,15 @@ namespace Jackett.Common.Indexers
|
|||||||
private string LoginUrl => SiteLink + "forum/login.php";
|
private string LoginUrl => SiteLink + "forum/login.php";
|
||||||
private string SearchUrl => SiteLink + "forum/tracker.php";
|
private string SearchUrl => SiteLink + "forum/tracker.php";
|
||||||
|
|
||||||
protected string cap_sid = null;
|
private string _capSid;
|
||||||
protected string cap_code_field = null;
|
private string _capCodeField;
|
||||||
|
|
||||||
private new ConfigurationDataRutracker configData
|
private new ConfigurationDataRutracker configData => (ConfigurationDataRutracker)base.configData;
|
||||||
{
|
|
||||||
get => (ConfigurationDataRutracker)base.configData;
|
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
||||||
set => base.configData = value;
|
"https://rutracker.org/",
|
||||||
}
|
"https://rutracker.net/"
|
||||||
|
};
|
||||||
|
|
||||||
public RuTracker(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
public RuTracker(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
||||||
: base(id: "rutracker",
|
: base(id: "rutracker",
|
||||||
@@ -1505,27 +1506,33 @@ namespace Jackett.Common.Indexers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
configData.CookieHeader.Value = null;
|
configData.CookieHeader.Value = null;
|
||||||
var response = await RequestStringWithCookies(LoginUrl);
|
var response = await RequestStringWithCookies(LoginUrl);
|
||||||
var LoginResultParser = new HtmlParser();
|
var parser = new HtmlParser();
|
||||||
var LoginResultDocument = LoginResultParser.ParseDocument(response.Content);
|
var doc = parser.ParseDocument(response.Content);
|
||||||
var captchaimg = LoginResultDocument.QuerySelector("img[src^=\"https://static.t-ru.org/captcha/\"]");
|
var captchaimg = doc.QuerySelector("img[src^=\"https://static.t-ru.org/captcha/\"]");
|
||||||
if (captchaimg != null)
|
if (captchaimg != null)
|
||||||
{
|
{
|
||||||
var captchaImage = await RequestBytesWithCookies(captchaimg.GetAttribute("src"));
|
var captchaImage = await RequestBytesWithCookies(captchaimg.GetAttribute("src"));
|
||||||
configData.CaptchaImage.Value = captchaImage.Content;
|
configData.CaptchaImage.Value = captchaImage.Content;
|
||||||
|
|
||||||
var codefield = LoginResultDocument.QuerySelector("input[name^=\"cap_code_\"]");
|
var codefield = doc.QuerySelector("input[name^=\"cap_code_\"]");
|
||||||
cap_code_field = codefield.GetAttribute("name");
|
_capCodeField = codefield.GetAttribute("name");
|
||||||
|
|
||||||
var sidfield = LoginResultDocument.QuerySelector("input[name=\"cap_sid\"]");
|
var sidfield = doc.QuerySelector("input[name=\"cap_sid\"]");
|
||||||
cap_sid = sidfield.GetAttribute("value");
|
_capSid = sidfield.GetAttribute("value");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
configData.CaptchaImage.Value = null;
|
configData.CaptchaImage.Value = null;
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.Error("Error loading configuration: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
return configData;
|
return configData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1540,13 +1547,13 @@ namespace Jackett.Common.Indexers
|
|||||||
{ "login", "Login" }
|
{ "login", "Login" }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(cap_sid))
|
if (!string.IsNullOrWhiteSpace(_capSid))
|
||||||
{
|
{
|
||||||
pairs.Add("cap_sid", cap_sid);
|
pairs.Add("cap_sid", _capSid);
|
||||||
pairs.Add(cap_code_field, configData.CaptchaText.Value);
|
pairs.Add(_capCodeField, configData.CaptchaText.Value);
|
||||||
|
|
||||||
cap_sid = null;
|
_capSid = null;
|
||||||
cap_code_field = null;
|
_capCodeField = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, CookieHeader, true, null, LoginUrl, true);
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, CookieHeader, true, null, LoginUrl, true);
|
||||||
@@ -1554,9 +1561,9 @@ namespace Jackett.Common.Indexers
|
|||||||
{
|
{
|
||||||
logger.Debug(result.Content);
|
logger.Debug(result.Content);
|
||||||
var errorMessage = "Unknown error message, please report";
|
var errorMessage = "Unknown error message, please report";
|
||||||
var LoginResultParser = new HtmlParser();
|
var parser = new HtmlParser();
|
||||||
var LoginResultDocument = LoginResultParser.ParseDocument(result.Content);
|
var doc = parser.ParseDocument(result.Content);
|
||||||
var errormsg = LoginResultDocument.QuerySelector("h4[class=\"warnColor1 tCenter mrg_16\"]");
|
var errormsg = doc.QuerySelector("h4[class=\"warnColor1 tCenter mrg_16\"]");
|
||||||
if (errormsg != null)
|
if (errormsg != null)
|
||||||
errorMessage = errormsg.TextContent;
|
errorMessage = errormsg.TextContent;
|
||||||
|
|
||||||
@@ -1574,16 +1581,12 @@ namespace Jackett.Common.Indexers
|
|||||||
|
|
||||||
// if the search string is empty use the getnew view
|
// if the search string is empty use the getnew view
|
||||||
if (string.IsNullOrWhiteSpace(searchString))
|
if (string.IsNullOrWhiteSpace(searchString))
|
||||||
{
|
|
||||||
queryCollection.Add("nm", searchString);
|
queryCollection.Add("nm", searchString);
|
||||||
}
|
|
||||||
else // use the normal search
|
else // use the normal search
|
||||||
{
|
{
|
||||||
searchString = searchString.Replace("-", " ");
|
searchString = searchString.Replace("-", " ");
|
||||||
if (query.Season != 0)
|
if (query.Season != 0)
|
||||||
{
|
|
||||||
searchString += " Сезон: " + query.Season;
|
searchString += " Сезон: " + query.Season;
|
||||||
}
|
|
||||||
queryCollection.Add("nm", searchString);
|
queryCollection.Add("nm", searchString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1597,36 +1600,33 @@ namespace Jackett.Common.Indexers
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var RowsSelector = "table#tor-tbl > tbody > tr";
|
var parser = new HtmlParser();
|
||||||
|
var doc = parser.ParseDocument(results.Content);
|
||||||
var SearchResultParser = new HtmlParser();
|
var rows = doc.QuerySelectorAll("table#tor-tbl > tbody > tr");
|
||||||
var SearchResultDocument = SearchResultParser.ParseDocument(results.Content);
|
foreach (var row in rows)
|
||||||
var Rows = SearchResultDocument.QuerySelectorAll(RowsSelector);
|
|
||||||
foreach (var Row in Rows)
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var qDownloadLink = Row.QuerySelector("td.tor-size > a.tr-dl");
|
var qDownloadLink = row.QuerySelector("td.tor-size > a.tr-dl");
|
||||||
if (qDownloadLink == null) // Expects moderation
|
if (qDownloadLink == null) // Expects moderation
|
||||||
continue;
|
continue;
|
||||||
var qDetailsLink = Row.QuerySelector("td.t-title > div.t-title > a.tLink");
|
var qDetailsLink = row.QuerySelector("td.t-title > div.t-title > a.tLink");
|
||||||
var qSize = Row.QuerySelector("td.tor-size");
|
var qSize = row.QuerySelector("td.tor-size");
|
||||||
var comments = new Uri(SiteLink + "forum/" + qDetailsLink.GetAttribute("href"));
|
var comments = new Uri(SiteLink + "forum/" + qDetailsLink.GetAttribute("href"));
|
||||||
var seeders = 0;
|
var seeders = 0;
|
||||||
var qSeeders = Row.QuerySelector("td:nth-child(7)");
|
var qSeeders = row.QuerySelector("td:nth-child(7)");
|
||||||
if (qSeeders != null && !qSeeders.TextContent.Contains("дн"))
|
if (qSeeders != null && !qSeeders.TextContent.Contains("дн"))
|
||||||
{
|
{
|
||||||
var seedersString = qSeeders.QuerySelector("b").TextContent;
|
var seedersString = qSeeders.QuerySelector("b").TextContent;
|
||||||
if (!string.IsNullOrWhiteSpace(seedersString))
|
if (!string.IsNullOrWhiteSpace(seedersString))
|
||||||
seeders = ParseUtil.CoerceInt(seedersString);
|
seeders = ParseUtil.CoerceInt(seedersString);
|
||||||
}
|
}
|
||||||
var timestr = Row.QuerySelector("td:nth-child(10)").GetAttribute("data-ts_text");
|
var timestr = row.QuerySelector("td:nth-child(10)").GetAttribute("data-ts_text");
|
||||||
var forum = Row.QuerySelector("td.f-name > div.f-name > a");
|
var forum = row.QuerySelector("td.f-name > div.f-name > a");
|
||||||
var forumid = forum.GetAttribute("href").Split('=')[1];
|
var forumid = forum.GetAttribute("href").Split('=')[1];
|
||||||
var link = new Uri(SiteLink + "forum/" + qDownloadLink.GetAttribute("href"));
|
var link = new Uri(SiteLink + "forum/" + qDownloadLink.GetAttribute("href"));
|
||||||
var size = ReleaseInfo.GetBytes(qSize.GetAttribute("data-ts_text"));
|
var size = ReleaseInfo.GetBytes(qSize.GetAttribute("data-ts_text"));
|
||||||
var leechers = ParseUtil.CoerceInt(Row.QuerySelector("td:nth-child(8)").TextContent);
|
var leechers = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(8)").TextContent);
|
||||||
var grabs = ParseUtil.CoerceLong(Row.QuerySelector("td:nth-child(9)").TextContent);
|
var grabs = ParseUtil.CoerceLong(row.QuerySelector("td:nth-child(9)").TextContent);
|
||||||
var publishDate = DateTimeUtil.UnixTimestampToDateTime(long.Parse(timestr));
|
var publishDate = DateTimeUtil.UnixTimestampToDateTime(long.Parse(timestr));
|
||||||
var release = new ReleaseInfo
|
var release = new ReleaseInfo
|
||||||
{
|
{
|
||||||
@@ -1646,11 +1646,6 @@ namespace Jackett.Common.Indexers
|
|||||||
UploadVolumeFactor = 1
|
UploadVolumeFactor = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO finish extracting release variables to simiplify release initialization
|
// TODO finish extracting release variables to simiplify release initialization
|
||||||
if (release.Category.Contains(TorznabCatType.TV.ID) ||
|
if (release.Category.Contains(TorznabCatType.TV.ID) ||
|
||||||
TorznabCatType.TV.SubCategories.Any(subCat => release.Category.Contains(subCat.ID)))
|
TorznabCatType.TV.SubCategories.Any(subCat => release.Category.Contains(subCat.ID)))
|
||||||
@@ -1696,8 +1691,7 @@ namespace Jackett.Common.Indexers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.Error(string.Format("{0}: Error while parsing row '{1}':\n\n{2}", Id, Row.OuterHtml, ex));
|
logger.Error($"{Id}: Error while parsing row '{row.OuterHtml}':\n\n{ex}");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Reference in New Issue
Block a user