Example #1
0
        public async override Task <List <String> > getFileListing(TorrentResult torrent)
        {
            var fileList = new List <String>();

            fileList.Add("Engine does not support file listing");
            return(fileList);
        }
Example #2
0
        public async Task <List <TorrentResult> > getSearchResults(string query)
        {
            var torrentResults = new List <TorrentResult>();
            var r = await doSearchRequest(query);

            var j = JsonConvert.DeserializeObject <JSON.Rootobject>(r);

            foreach (JSON.Movie movie in j.data.movies)
            {
                foreach (var torrent in movie.torrents)
                {
                    var t = new TorrentResult();
                    t.source      = this;
                    t.title       = movie.title_long + " " + torrent.quality;
                    t.torrentFile = torrent.url;
                    t.date        = DateTime.Parse(torrent.date_uploaded);
                    t.url         = movie.url;
                    t.setSize(torrent.size_bytes);
                    t.peers = torrent.peers;
                    t.seeds = torrent.seeds;

                    torrentResults.Add(t);
                }
            }

            return(torrentResults);
        }
Example #3
0
        public async override Task <List <String> > getFileListing(TorrentResult torrent)
        {
            var fileList = new List <string>();
            var r        = await doFileListingRequest(torrent.hash);

            var j = JsonConvert.DeserializeObject <JSON.FileListing.Rootobject>(r);

            foreach (string f in j.torrents[0].file_info.file_names)
            {
                fileList.Add(f);
            }

            return(fileList);
        }
Example #4
0
        public virtual ActionResult SetLabel(string newLabel, string hash)
        {
            newLabel = newLabel ?? string.Empty;

            var     client  = CurrentSession.Client;
            int     counter = 0;
            Torrent torrent = null;

            while (torrent == null)
            {
                torrent = client.Torrents
                          .SingleOrDefault(t => t.Hash.Equals(hash, StringComparison.OrdinalIgnoreCase));

                if (torrent != null || counter == 10)
                {
                    break;
                }
                else
                {
                    Thread.Sleep(300);
                }

                counter++;
            }

            if (torrent != null)
            {
                client.Torrents[torrent.Hash].Label = newLabel;
            }

            if (Request.IsAjaxRequest())
            {
                var result = new TorrentResult
                {
                    Ok   = torrent != null,
                    Hash = torrent.Hash,
                };

                if (!result.Ok)
                {
                    result.ErrorMessage = "Hittade ingen torrent med hash " + hash;
                }

                return(JsonContract(result));
            }

            return(RedirectToAction(MVC.Root.Index()));
        }
Example #5
0
        public async Task <List <TorrentResult> > getSearchResults(string query)
        {
            var    torrentResults = new List <TorrentResult>();
            string r = await doSearchRequest(query);

            var j = JsonConvert.DeserializeObject <JSON.Rootobject>(r);

            foreach (JSON.Torrent torrent in j.torrents)
            {
                var t = new TorrentResult();
                t.title  = torrent.torrent_title;
                t.hash   = torrent.torrent_hash;
                t.magnet = torrent.magnet_uri;
                t.setSize(torrent.size);
                t.source = this;
                t.url    = torrent.page;
                t.seeds  = torrent.seeds;
                t.peers  = torrent.leeches;
                t.date   = DateTime.Parse(torrent.upload_date);
                torrentResults.Add(t);
            }

            return(torrentResults);
        }
Example #6
0
        private static List <TorrentResult> GetTPBTorrents(string source, int page, bool skipLinks)
        {
            if (string.IsNullOrEmpty(source))
            {
                return(null);
            }

            var torrentResults = new List <TorrentResult>();
            var htmlDoc        = new HtmlDocument();

            htmlDoc.LoadHtml(source);

            //Parse results
            var resultsTable = htmlDoc.DocumentNode.Descendants().Where
                                   (x => (x.Name == "table" && x.Attributes["id"] != null &&
                                          x.Attributes["id"].Value.Equals(searchResultDivName))).ToList();

            resultsTable.ForEach(results =>
            {
                var rows = results.Descendants("tr").ToList();
                rows.ForEach(row =>
                {
                    var tempResult = new TorrentResult()
                    {
                        Page = page
                    };
                    var details = row.Descendants()
                                  .Where(x =>
                                         x.Name == "div" &&
                                         x.Attributes["class"] != null &&
                                         x.Attributes["class"].Value.Equals(detailDivName))
                                  .ToList();

                    details.ForEach(detail =>
                    {
                        var descriptions = row.Descendants().Where(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Equals("detDesc"));
                        tempResult.Description.AddRange(descriptions.Select(d => d.InnerText));
                        tempResult.Name = detail.InnerText.Trim();

                        if (!skipLinks)
                        {
                            var links = row.Descendants().Where(x => (x.Name == "a" && x.Attributes["href"] != null && x.Attributes["title"] != null) || (x.Name == "img" && x.Attributes["title"] != null && x.Attributes["src"] != null));
                            foreach (var link in links)
                            {
                                if (link.Name == "a")
                                {
                                    tempResult.Links.Add(new Tuple <string, string>(link.Attributes["title"].Value.ToString(), link.Attributes["href"].Value));
                                }
                                else
                                {
                                    tempResult.Links.Add(new Tuple <string, string>(link.Attributes["title"].Value.ToString(), link.Attributes["src"].Value));
                                }
                            }
                        }

                        //Seeds and leeds
                        var columns  = row.Descendants().Where(x => x.Name == "td").ToList();
                        var colCount = columns.Count();
                        if (colCount > 3)
                        {
                            var types          = columns[0].Descendants().Where(x => x.Name == "a").ToList();
                            tempResult.Type    = types[0].InnerText;
                            tempResult.SubType = types[1].InnerText;
                            tempResult.Leeds   = int.Parse(columns[colCount - 1].InnerText);
                            tempResult.Seeds   = int.Parse(columns[colCount - 2].InnerText);
                        }
                    });

                    tempResult.Vip = row.Descendants().Any(x => x.Name == "img" && x.Attributes["title"] != null && x.Attributes["title"].Value.Equals("VIP"));
                    if (!string.IsNullOrEmpty(tempResult.Name))
                    {
                        torrentResults.Add(tempResult);
                    }
                });
            });
            return(torrentResults);
        }