Ejemplo n.º 1
0
        private Subtitles ProcessSubUrl(string subUrl)
        {
            var subresult = new WebClientEx().DownloadStringIgnoreAndLog(_root + subUrl);
            if (string.IsNullOrWhiteSpace(subresult)) return null;
            try
            {
                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(subresult);

                var href = _root + doc.DocumentNode.SelectSingleNode("//a[@class='button big download']").Attributes["href"].Value;

                var name = doc.DocumentNode.SelectSingleNode("//fieldset/legend[text()='Release']/../p/a").InnerText;

                var data = new WebClientEx().DownloadDataIgnoreAndLog(href);

                var outputStream = new MemoryStream();

                using (var zf = new ZipFile(new MemoryStream(data)))
                {
                    var ze = zf[0];
                    zf.GetInputStream(ze).CopyTo(outputStream);
                }

                return new Subtitles() { Title = name, File = outputStream.ToArray() };
            }
            catch (Exception ex)
            {
                _logger.WarnException("Error getting subtitle "+subUrl,ex);
            }

            return null;
        }
        public Torrent[] Search(Series series, Episode episode)
        {
            var query = series.Title + " " + episode.CodedName;
            var url = string.Format("http://thepiratebay.se/search/{0}/0/7/0", HttpUtility.UrlEncode(query));

            var result = new WebClientEx().DownloadString(url);
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(result);
            var dts = doc.DocumentNode.SelectNodes("/html/body/div[@id='SearchResults']/div[@id='content']/div[@id='main-content']/table[@id='searchResult']/tr/td/div[@class='detName']");

            List<Torrent> results = new List<Torrent>();

            if (dts != null)
            {
                foreach (var dt in dts)
                {
                    var a = dt.ParentNode.SelectSingleNode("a");
                    var seed =
                        int.Parse(dt.ParentNode.ParentNode.SelectSingleNode("td[@align='right']").InnerText.Trim('\t', ' ', '\r',
                                                                                                                 '\n'));
                    results.Add(new Torrent() { Magnet = a.Attributes["href"].Value, Title = dt.InnerText.Trim('\t', ' ', '\r', '\n'), Seed = seed });
                }
            }

            return results.ToArray();
        }
Ejemplo n.º 3
0
        public Subtitles[] Search(Series series, Episode episode)
        {
            var query =
                string.Format("http://www.podnapisi.net/ru/ppodnapisi/search?sJ=2&sT=1&sK={2}&sTS={0}&sTE={1}",
                              episode.Season, episode.Number, HttpUtility.UrlEncode(series.Title));
            List<Subtitles> subtitleses = new List<Subtitles>();
            var result = new WebClientEx().DownloadStringIgnoreAndLog(query);

            var aas = Regex.Matches(result, "class=\"subtitle_page_link\" href=\"([^\"]*?)\"").OfType<Match>().Select(m => m.Groups[1].Value).ToArray();

            var subs = aas.Select(ProcessSubUrl).Where(r => r != null).AsParallel().ToArray();
            Thread.Sleep(1000);
            return subs;
        }