mirror of https://github.com/Jackett/Jackett
XSpeeds: dump feed in case of error (#742)
This commit is contained in:
parent
ab083cdec8
commit
80fd717970
|
@ -172,47 +172,58 @@ namespace Jackett.Indexers
|
||||||
// If we have no query use the RSS Page as their server is slow enough at times!
|
// If we have no query use the RSS Page as their server is slow enough at times!
|
||||||
if (string.IsNullOrWhiteSpace(searchString))
|
if (string.IsNullOrWhiteSpace(searchString))
|
||||||
{
|
{
|
||||||
|
|
||||||
var rssPage = await RequestStringWithCookiesAndRetry(string.Format(RSSUrl, configData.RSSKey.Value));
|
var rssPage = await RequestStringWithCookiesAndRetry(string.Format(RSSUrl, configData.RSSKey.Value));
|
||||||
if (rssPage.Content.EndsWith("\0")) {
|
try
|
||||||
rssPage.Content = rssPage.Content.Substring(0, rssPage.Content.Length - 1);
|
|
||||||
}
|
|
||||||
rssPage.Content = RemoveInvalidXmlChars(rssPage.Content);
|
|
||||||
var rssDoc = XDocument.Parse(rssPage.Content);
|
|
||||||
|
|
||||||
foreach (var item in rssDoc.Descendants("item"))
|
|
||||||
{
|
{
|
||||||
var title = item.Descendants("title").First().Value;
|
if (rssPage.Content.EndsWith("\0")) {
|
||||||
var description = item.Descendants("description").First().Value;
|
rssPage.Content = rssPage.Content.Substring(0, rssPage.Content.Length - 1);
|
||||||
var link = item.Descendants("link").First().Value;
|
}
|
||||||
var category = item.Descendants("category").First().Value;
|
rssPage.Content = RemoveInvalidXmlChars(rssPage.Content);
|
||||||
var date = item.Descendants("pubDate").First().Value;
|
var rssDoc = XDocument.Parse(rssPage.Content);
|
||||||
|
|
||||||
var torrentIdMatch = Regex.Match(link, "(?<=id=)(\\d)*");
|
foreach (var item in rssDoc.Descendants("item"))
|
||||||
var torrentId = torrentIdMatch.Success ? torrentIdMatch.Value : string.Empty;
|
|
||||||
if (string.IsNullOrWhiteSpace(torrentId))
|
|
||||||
throw new Exception("Missing torrent id");
|
|
||||||
|
|
||||||
var infoMatch = Regex.Match(description, @"Category:\W(?<cat>.*)\W\/\WSeeders:\W(?<seeders>[\d\,]*)\W\/\WLeechers:\W(?<leechers>[\d\,]*)\W\/\WSize:\W(?<size>[\d\.]*\W\S*)");
|
|
||||||
if (!infoMatch.Success)
|
|
||||||
throw new Exception("Unable to find info");
|
|
||||||
|
|
||||||
var release = new ReleaseInfo
|
|
||||||
{
|
{
|
||||||
Title = title,
|
var title = item.Descendants("title").First().Value;
|
||||||
Description = title,
|
var description = item.Descendants("description").First().Value;
|
||||||
Guid = new Uri(string.Format(DownloadUrl, torrentId)),
|
var link = item.Descendants("link").First().Value;
|
||||||
Comments = new Uri(string.Format(CommentUrl, torrentId)),
|
var category = item.Descendants("category").First().Value;
|
||||||
PublishDate = DateTime.ParseExact(date, "yyyy-MM-dd H:mm:ss", CultureInfo.InvariantCulture), //2015-08-08 21:20:31
|
var date = item.Descendants("pubDate").First().Value;
|
||||||
Link = new Uri(string.Format(DownloadUrl, torrentId)),
|
|
||||||
Seeders = ParseUtil.CoerceInt(infoMatch.Groups["seeders"].Value),
|
|
||||||
Peers = ParseUtil.CoerceInt(infoMatch.Groups["leechers"].Value),
|
|
||||||
Size = ReleaseInfo.GetBytes(infoMatch.Groups["size"].Value),
|
|
||||||
Category = MapTrackerCatToNewznab(category)
|
|
||||||
};
|
|
||||||
|
|
||||||
release.Peers += release.Seeders;
|
var torrentIdMatch = Regex.Match(link, "(?<=id=)(\\d)*");
|
||||||
releases.Add(release);
|
var torrentId = torrentIdMatch.Success ? torrentIdMatch.Value : string.Empty;
|
||||||
|
if (string.IsNullOrWhiteSpace(torrentId))
|
||||||
|
throw new Exception("Missing torrent id");
|
||||||
|
|
||||||
|
var infoMatch = Regex.Match(description, @"Category:\W(?<cat>.*)\W\/\WSeeders:\W(?<seeders>[\d\,]*)\W\/\WLeechers:\W(?<leechers>[\d\,]*)\W\/\WSize:\W(?<size>[\d\.]*\W\S*)");
|
||||||
|
if (!infoMatch.Success)
|
||||||
|
throw new Exception("Unable to find info");
|
||||||
|
|
||||||
|
var release = new ReleaseInfo
|
||||||
|
{
|
||||||
|
Title = title,
|
||||||
|
Description = title,
|
||||||
|
Guid = new Uri(string.Format(DownloadUrl, torrentId)),
|
||||||
|
Comments = new Uri(string.Format(CommentUrl, torrentId)),
|
||||||
|
PublishDate = DateTime.ParseExact(date, "yyyy-MM-dd H:mm:ss", CultureInfo.InvariantCulture), //2015-08-08 21:20:31
|
||||||
|
Link = new Uri(string.Format(DownloadUrl, torrentId)),
|
||||||
|
Seeders = ParseUtil.CoerceInt(infoMatch.Groups["seeders"].Value),
|
||||||
|
Peers = ParseUtil.CoerceInt(infoMatch.Groups["leechers"].Value),
|
||||||
|
Size = ReleaseInfo.GetBytes(infoMatch.Groups["size"].Value),
|
||||||
|
Category = MapTrackerCatToNewznab(category)
|
||||||
|
};
|
||||||
|
|
||||||
|
release.Peers += release.Seeders;
|
||||||
|
releases.Add(release);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error("XSpeeds: Error while parsing the RSS feed:");
|
||||||
|
logger.Error(rssPage.Content);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue