mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
- try/catch block for torrent parsing Sonarr test button was failed because an invalid torrent.
This commit is contained in:
@@ -130,89 +130,95 @@ namespace Jackett.Common.Indexers
|
||||
// Check torrents only till we reach the query Limit
|
||||
for(int i=0; (i<rows.Length && ((already_founded + releases.Count) < limit )); i++)
|
||||
{
|
||||
CQ qRow = rows[i].Cq();
|
||||
|
||||
var key = dom["link[rel=alternate]"].First().Attr("href").Split('=').Last();
|
||||
|
||||
release = new ReleaseInfo();
|
||||
var torrentTxt = qRow.Find(".torrent_txt, .torrent_txt2").Find("a").Get(0);
|
||||
//if (torrentTxt == null) continue;
|
||||
release.Title = torrentTxt.GetAttribute("title");
|
||||
release.Description = qRow.Find("span").Get(0).GetAttribute("title") + " " + qRow.Find("a.infolink").Text();
|
||||
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.DownloadVolumeFactor = 0;
|
||||
release.UploadVolumeFactor = 1;
|
||||
|
||||
string downloadLink = SiteLink + torrentTxt.GetAttribute("href");
|
||||
string downloadId = downloadLink.Substring(downloadLink.IndexOf("&id=") + 4);
|
||||
|
||||
release.Link = new Uri(SiteLink.ToString() + "torrents.php?action=download&id=" + downloadId + "&key=" + key);
|
||||
release.Comments = new Uri(SiteLink.ToString() + "torrents.php?action=details&id=" + downloadId);
|
||||
release.Guid = new Uri(release.Comments.ToString() + "#comments"); ;
|
||||
release.Seeders = ParseUtil.CoerceInt(qRow.Find(".box_s2").Find("a").First().Text());
|
||||
release.Peers = ParseUtil.CoerceInt(qRow.Find(".box_l2").Find("a").First().Text()) + release.Seeders;
|
||||
var imdblink = qRow.Find("a[href*=\".imdb.com/title\"]").Attr("href");
|
||||
release.Imdb = ParseUtil.GetLongFromString(imdblink);
|
||||
var banner = qRow.Find("img.infobar_ico").Attr("onmouseover");
|
||||
if (banner != null)
|
||||
try
|
||||
{
|
||||
Regex BannerRegEx = new Regex(@"mutat\('(.*?)', '", RegexOptions.Compiled);
|
||||
var BannerMatch = BannerRegEx.Match(banner);
|
||||
var bannerurl = BannerMatch.Groups[1].Value;
|
||||
release.BannerUrl = new Uri(bannerurl);
|
||||
}
|
||||
release.PublishDate = DateTime.Parse(qRow.Find(".box_feltoltve2").Get(0).InnerHTML.Replace("<br />", " "), CultureInfo.InvariantCulture);
|
||||
string[] sizeSplit = qRow.Find(".box_meret2").Get(0).InnerText.Split(' ');
|
||||
release.Size = ReleaseInfo.GetBytes(sizeSplit[1].ToLower(), ParseUtil.CoerceFloat(sizeSplit[0]));
|
||||
string catlink = qRow.Find("a:has(img[class='categ_link'])").First().Attr("href");
|
||||
string cat = ParseUtil.GetArgumentFromQueryString(catlink, "tipus");
|
||||
release.Category = MapTrackerCatToNewznab(cat);
|
||||
CQ qRow = rows[i].Cq();
|
||||
var key = dom["link[rel=alternate]"].First().Attr("href").Split('=').Last();
|
||||
|
||||
/* if the release name not contains the language we add it because it is know from category */
|
||||
if (cat.Contains("hun") && !release.Title.Contains("hun"))
|
||||
release.Title += ".hun";
|
||||
release = new ReleaseInfo();
|
||||
var torrentTxt = qRow.Find(".torrent_txt, .torrent_txt2").Find("a").Get(0);
|
||||
//if (torrentTxt == null) continue;
|
||||
release.Title = torrentTxt.GetAttribute("title");
|
||||
release.Description = qRow.Find("span").Get(0).GetAttribute("title") + " " + qRow.Find("a.infolink").Text();
|
||||
|
||||
if (seasonep == null)
|
||||
releases.Add(release);
|
||||
release.MinimumRatio = 1;
|
||||
release.MinimumSeedTime = 172800;
|
||||
release.DownloadVolumeFactor = 0;
|
||||
release.UploadVolumeFactor = 1;
|
||||
|
||||
else
|
||||
{
|
||||
if (query.MatchQueryStringAND(release.Title, null, seasonep))
|
||||
string downloadLink = SiteLink + torrentTxt.GetAttribute("href");
|
||||
string downloadId = downloadLink.Substring(downloadLink.IndexOf("&id=") + 4);
|
||||
|
||||
release.Link = new Uri(SiteLink.ToString() + "torrents.php?action=download&id=" + downloadId + "&key=" + key);
|
||||
release.Comments = new Uri(SiteLink.ToString() + "torrents.php?action=details&id=" + downloadId);
|
||||
release.Guid = new Uri(release.Comments.ToString() + "#comments"); ;
|
||||
release.Seeders = ParseUtil.CoerceInt(qRow.Find(".box_s2").Find("a").First().Text());
|
||||
release.Peers = ParseUtil.CoerceInt(qRow.Find(".box_l2").Find("a").First().Text()) + release.Seeders;
|
||||
var imdblink = qRow.Find("a[href*=\".imdb.com/title\"]").Attr("href");
|
||||
release.Imdb = ParseUtil.GetLongFromString(imdblink);
|
||||
var banner = qRow.Find("img.infobar_ico").Attr("onmouseover");
|
||||
if (banner != null)
|
||||
{
|
||||
/* For sonnar if the search querry was english the title must be english also so we need to change the Description and Title */
|
||||
var temp = release.Title;
|
||||
Regex BannerRegEx = new Regex(@"mutat\('(.*?)', '", RegexOptions.Compiled);
|
||||
var BannerMatch = BannerRegEx.Match(banner);
|
||||
var bannerurl = BannerMatch.Groups[1].Value;
|
||||
release.BannerUrl = new Uri(bannerurl);
|
||||
}
|
||||
release.PublishDate = DateTime.Parse(qRow.Find(".box_feltoltve2").Get(0).InnerHTML.Replace("<br />", " "), CultureInfo.InvariantCulture);
|
||||
string[] sizeSplit = qRow.Find(".box_meret2").Get(0).InnerText.Split(' ');
|
||||
release.Size = ReleaseInfo.GetBytes(sizeSplit[1].ToLower(), ParseUtil.CoerceFloat(sizeSplit[0]));
|
||||
string catlink = qRow.Find("a:has(img[class='categ_link'])").First().Attr("href");
|
||||
string cat = ParseUtil.GetArgumentFromQueryString(catlink, "tipus");
|
||||
release.Category = MapTrackerCatToNewznab(cat);
|
||||
|
||||
// releasedata everithing after Name.S0Xe0X
|
||||
String releasedata =release.Title.Split(new[] { seasonep }, StringSplitOptions.None)[1].Trim();
|
||||
/* if the release name not contains the language we add it because it is know from category */
|
||||
if (cat.Contains("hun") && !release.Title.Contains("hun"))
|
||||
release.Title += ".hun";
|
||||
|
||||
/* if the release name not contains the language we add it because it is know from category */
|
||||
if (cat.Contains("hun") && !releasedata.Contains("hun"))
|
||||
releasedata += ".hun";
|
||||
|
||||
// release description contains [imdb: ****] but we only need the data before it for title
|
||||
String[] description = {release.Description, ""};
|
||||
if (release.Description.Contains("[imdb:"))
|
||||
{
|
||||
description = release.Description.Split('[');
|
||||
description[1] = "[" + description[1];
|
||||
}
|
||||
|
||||
release.Title = (description[0].Trim() + "." + seasonep.Trim() + "." + releasedata.Trim('.')).Replace(' ', '.');
|
||||
|
||||
// if search is done for S0X than we dont want to put . between S0X and E0X
|
||||
Match match = Regex.Match(releasedata, @"^E\d\d?");
|
||||
if (seasonep.Length==3 && match.Success)
|
||||
release.Title = (description[0].Trim() + "." + seasonep.Trim() + releasedata.Trim('.')).Replace(' ', '.');
|
||||
|
||||
// add back imdb points to the description [imdb: 8.7]
|
||||
release.Description = temp+" "+ description[1];
|
||||
release.Description = release.Description.Trim();
|
||||
if (seasonep == null)
|
||||
releases.Add(release);
|
||||
|
||||
else
|
||||
{
|
||||
if (query.MatchQueryStringAND(release.Title, null, seasonep))
|
||||
{
|
||||
/* For sonnar if the search querry was english the title must be english also so we need to change the Description and Title */
|
||||
var temp = release.Title;
|
||||
|
||||
// releasedata everithing after Name.S0Xe0X
|
||||
String releasedata = release.Title.Split(new[] { seasonep }, StringSplitOptions.None)[1].Trim();
|
||||
|
||||
/* if the release name not contains the language we add it because it is know from category */
|
||||
if (cat.Contains("hun") && !releasedata.Contains("hun"))
|
||||
releasedata += ".hun";
|
||||
|
||||
// release description contains [imdb: ****] but we only need the data before it for title
|
||||
String[] description = { release.Description, "" };
|
||||
if (release.Description.Contains("[imdb:"))
|
||||
{
|
||||
description = release.Description.Split('[');
|
||||
description[1] = "[" + description[1];
|
||||
}
|
||||
|
||||
release.Title = (description[0].Trim() + "." + seasonep.Trim() + "." + releasedata.Trim('.')).Replace(' ', '.');
|
||||
|
||||
// if search is done for S0X than we dont want to put . between S0X and E0X
|
||||
Match match = Regex.Match(releasedata, @"^E\d\d?");
|
||||
if (seasonep.Length == 3 && match.Success)
|
||||
release.Title = (description[0].Trim() + "." + seasonep.Trim() + releasedata.Trim('.')).Replace(' ', '.');
|
||||
|
||||
// add back imdb points to the description [imdb: 8.7]
|
||||
release.Description = temp + " " + description[1];
|
||||
release.Description = release.Description.Trim();
|
||||
releases.Add(release);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (FormatException ex)
|
||||
{
|
||||
logger.Error("Problem of parsing Torrent:" + rows[i].InnerHTML);
|
||||
logger.Error("Exception was the following:" + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Reference in New Issue
Block a user