Beispiel #1
0
        public IList <ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
        {
            var torrentInfos = new List <ReleaseInfo>();

            var parser = new HtmlParser();
            var doc    = parser.ParseDocument(indexerResponse.Content);

            // get params to build download link (user could be banned without those params)
            var rssFeedUri = new Uri(_settings.BaseUrl + doc.QuerySelector("link[href^=\"/feeds.php?feed=\"]")
                                     .GetAttribute("href"));
            var rssFeedQuery            = HttpUtility.ParseQueryString(rssFeedUri.Query);
            var downloadLinkExtraParams = "&authkey=" + rssFeedQuery["authkey"] + "&torrent_pass="******"passkey"];

            var rows = doc.QuerySelectorAll("table.torrent_table > tbody > tr.torrent");

            foreach (var row in rows)
            {
                var qDetailsLink = row.QuerySelector("a[href^=\"torrents.php?id=\"]");
                var title        = qDetailsLink.TextContent;

                var description = qDetailsLink.NextSibling.TextContent.Trim();
                title += " " + description;
                var details   = _settings.BaseUrl + qDetailsLink.GetAttribute("href");
                var torrentId = qDetailsLink.GetAttribute("href").Split('=').Last();
                var link      = _settings.BaseUrl + "torrents.php?action=download&id=" + torrentId + downloadLinkExtraParams;

                var files       = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(3)").TextContent);
                var publishDate = DateTimeUtil.FromTimeAgo(row.QuerySelector("td:nth-child(4)").TextContent);
                var size        = ParseUtil.GetBytes(row.QuerySelector("td:nth-child(5)").FirstChild.TextContent);
                var grabs       = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(6)").TextContent);
                var seeders     = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(7)").TextContent);
                var leechers    = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(8)").TextContent);

                var dlVolumeFactor = row.QuerySelector("strong.freeleech_normal") != null ? 0 : 1;

                var category = new List <IndexerCategory> {
                    TvCategoryFromQualityParser.ParseTvShowQuality(description)
                };

                var release = new TorrentInfo
                {
                    MinimumRatio         = 1,
                    MinimumSeedTime      = 0,
                    Description          = description,
                    Title                = title,
                    PublishDate          = publishDate,
                    Categories           = category,
                    DownloadUrl          = link,
                    InfoUrl              = details,
                    Guid                 = link,
                    Seeders              = seeders,
                    Peers                = leechers + seeders,
                    Size                 = size,
                    Grabs                = grabs,
                    Files                = files,
                    DownloadVolumeFactor = dlVolumeFactor,
                    UploadVolumeFactor   = 1
                };

                torrentInfos.Add(release);
            }

            return(torrentInfos.ToArray());
        }
Beispiel #2
0
        public IList <ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
        {
            var torrentInfos = new List <ReleaseInfo>();

            var parser   = new HtmlParser();
            var document = parser.ParseDocument(indexerResponse.Content);
            var rows     = document.QuerySelectorAll(".torrent_table > tbody > tr[class^='torrent row']");

            foreach (var row in rows)
            {
                var title = row.QuerySelector("a[data-src]").GetAttribute("data-src");
                if (string.IsNullOrEmpty(title) || title == "0")
                {
                    title = row.QuerySelector("a[data-src]").TextContent;
                    title = Regex.Replace(title, @"[\[\]\/]", "");
                }
                else
                {
                    if (title.Length > 5 && title.Substring(title.Length - 5).Contains("."))
                    {
                        title = title.Remove(title.LastIndexOf(".", StringComparison.Ordinal));
                    }
                }

                var posterStr = row.QuerySelector("img")?.GetAttribute("src");
                Uri.TryCreate(posterStr, UriKind.Absolute, out var poster);

                var details = _settings.BaseUrl + row.QuerySelector("a[data-src]").GetAttribute("href");
                var link    = _settings.BaseUrl + row.QuerySelector("a[href*='action=download']").GetAttribute("href");

                var qColSize = row.QuerySelector("td:nth-child(3)");
                var size     = ParseUtil.GetBytes(qColSize.Children[0].TextContent);
                var files    = ParseUtil.CoerceInt(qColSize.Children[1].TextContent.Split(':')[1].Trim());

                var qPublishdate   = row.QuerySelector("td:nth-child(4) span");
                var publishDateStr = qPublishdate.GetAttribute("title");
                var publishDate    = !string.IsNullOrEmpty(publishDateStr) && publishDateStr.Contains(",")
                    ? DateTime.ParseExact(publishDateStr, "MMM dd yyyy, HH:mm", CultureInfo.InvariantCulture)
                    : DateTime.ParseExact(qPublishdate.TextContent.Trim(), "MMM dd yyyy, HH:mm", CultureInfo.InvariantCulture);

                var grabs    = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(5)").TextContent);
                var seeds    = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(6)").TextContent);
                var leechers = ParseUtil.CoerceInt(row.QuerySelector("td:nth-child(7)").TextContent);

                var release = new TorrentInfo
                {
                    Title       = title,
                    Guid        = details,
                    InfoUrl     = details,
                    PosterUrl   = poster?.AbsoluteUri ?? null,
                    DownloadUrl = link,
                    Categories  = new List <IndexerCategory> {
                        TvCategoryFromQualityParser.ParseTvShowQuality(title)
                    },
                    Size                 = size,
                    Files                = files,
                    PublishDate          = publishDate,
                    Grabs                = grabs,
                    Seeders              = seeds,
                    Peers                = seeds + leechers,
                    MinimumRatio         = 0,     // ratioless
                    MinimumSeedTime      = 86400, // 24 hours
                    DownloadVolumeFactor = 0,     // ratioless tracker
                    UploadVolumeFactor   = 1
                };

                torrentInfos.Add(release);
            }

            return(torrentInfos.ToArray());
        }