public Task<IEnumerable<ITorrentSearchResult>> SearchTvShowEpisode(string name, int season, int episode, string episodeName, string imdbId = null,
                                                                    VideoQuality videoQuality = VideoQuality.Any, string extraKeywords = null, string excludeKeywords = null,
                                                                    int? minSize = null, int? maxSize = null, int? minSeed = null, ITorrentDownloader service = null) {
     var query = Settings.TvShowEpisodeSearchPattern;
     query = Helper.PopulateTvShowEpisodeSearchQuery(query, name, season, episode, imdbId, extraKeywords);
     return Search(query, videoQuality, excludeKeywords, minSize, maxSize, minSeed, service);
 }
 private void OnStartSeedingFile(ITorrentDownloader downloader)
 {
     if (StartSeedingFile != null)
     {
         StartSeedingFile(this, new SeedingEventArgs(downloader.Torrent.TorrentFileUri, downloader));
     }
 }
 public Utilities(IRssReader reader, ISettingsService settings, ITorrentDownloader td, IFilterFeed filter)
 {
     RssReader         = reader;
     Settings          = settings;
     TorrentDownloader = td;
     Filter            = filter;
 }
        public Task<IEnumerable<ITorrentSearchResult>> SearchMovie(string name, int? year = null, string imdbId = null, VideoQuality videoQuality = VideoQuality.Any,
                                                                   string extraKeywords = null, string excludeKeywords = null, 
                                                                   int? minSize = null, int? maxSize = null, int? minSeed = null, ITorrentDownloader service = null) {
            var query = Settings.MovieSearchPattern;

            if (!string.IsNullOrEmpty(imdbId))
                imdbId = imdbId.Replace("tt", "");

            query = Helper.PopulateMovieSearchQuery(query, name, year, imdbId, extraKeywords);
            query += " category:movies";
            return Search(query, videoQuality, excludeKeywords, minSize, maxSize, minSeed, service);
        }
 public TorrentSearchResult(ITorrentDownloader service, ITorrentProvider provider, string url, string name, 
                            int seed, int leech, double size, int? files, string age, string magnetUri) {
     _service = service;
     _provider = provider;
     _url = url;
     _name = name;
     _seed = seed;
     _leech = leech;
     _size = size;
     _files = files;
     _age = age;
     _magnetUri = magnetUri;
 }
 public TorrentSearchResult(ITorrentDownloader service, ITorrentProvider provider, string url, string name,
                            int seed, int leech, double size, int?files, string age, string magnetUri)
 {
     _service   = service;
     _provider  = provider;
     _url       = url;
     _name      = name;
     _seed      = seed;
     _leech     = leech;
     _size      = size;
     _files     = files;
     _age       = age;
     _magnetUri = magnetUri;
 }
        public async Task<IEnumerable<ITorrentSearchResult>> SearchMovie(string name, int? year = null, string imdbId = null, VideoQuality videoQuality = VideoQuality.Any,
                                                                         string extraKeywords = null, string excludeKeywords = null,
                                                                         int? minSize = null, int? maxSize = null, int? minSeed = null, ITorrentDownloader service = null) {
            var query = Settings.MovieSearchPattern;

            IEnumerable<ITorrentSearchResult> results;
            if (query == ThePirateBaySettings.ImdbSearchQuery)
                results = await Search(imdbId, VideoQuality.Any, excludeKeywords, minSize, maxSize, minSeed, service);
            else {
                query = Helper.PopulateMovieSearchQuery(query, name, year, imdbId, extraKeywords);
                results = await Search(query, videoQuality, excludeKeywords, minSize, maxSize, minSeed, service);
            }

            if (query == ThePirateBaySettings.ImdbSearchQuery) {
                string filter;
                switch (videoQuality) {
                    case VideoQuality.P720:
                        filter = "720p";
                        break;
                    case VideoQuality.P1080:
                        filter = "1080p";
                        break;
                    default:
                        filter = string.Empty;
                        break;
                }
                if (extraKeywords != null)
                    filter += " " + extraKeywords;

                if (filter != string.Empty) {
                    var filters = filter.Split(' ');
                    results = results.Where(r => filters.All(e => r.Name.Contains(e)));
                }
            }

            return results;
        }
        public async Task<IEnumerable<ITorrentSearchResult>> Search(string search, VideoQuality videoQuality = VideoQuality.Any, string excludeKeywords = null,
                                                                    int? minSize = null, int? maxSize = null, int? minSeed = null, ITorrentDownloader service = null) {
            if (videoQuality != VideoQuality.Any) {
                switch (videoQuality) {
                    case VideoQuality.P720:
                        search += " 720p";
                        break;
                    case VideoQuality.P1080:
                        search += " 1080p";
                        break;
                }
            }

            var excludeList = string.IsNullOrEmpty(excludeKeywords)
                ? Enumerable.Empty<string>().ToList()
                : excludeKeywords.Split(' ').Select(e => e.Trim()).Where(e => !string.IsNullOrEmpty(e)).Distinct().ToList();

            var results = new List<TorrentSearchResult>();
            var url = Helper.CombineUrls(Settings.BaseUrl, "search", search);
            using (var client = new NovaromaWebClient()) {
                var html = await client.DownloadStringTaskAsync(url);

                var document = DocumentBuilder.Html(html);
                var items = document.QuerySelectorAll("table[id='searchResult'] tr");

                foreach (var item in items) {
                    var tds = item.QuerySelectorAll("td");
                    if (tds.Length < 4) continue;

                    var mainTd = tds[1];
                    var anchor = mainTd.Children[0].Children[0];
                    var torrentUrl = Helper.CombineUrls(Settings.BaseUrl, anchor.Attributes.First(a => a.Name == "href").Value);
                    var torrentName = anchor.TextContent.Trim();
                    if (excludeList.Any(e => torrentName.IndexOf(e, StringComparison.OrdinalIgnoreCase) > 0)) continue;

                    var magnetUri = tds[1].Children[1].Attributes.First(a => a.Name == "href").Value;
                    var detDescNode = tds[1].QuerySelectorAll("font[class='detDesc']").First();
                    var detDesc = detDescNode.TextContent;
                    var idx1 = detDesc.IndexOf(",", StringComparison.OrdinalIgnoreCase);
                    var idx2 = detDesc.IndexOf(",", idx1 + 1, StringComparison.Ordinal);
                    var age = detDesc.Substring(0, idx1).Replace("Uploaded", string.Empty).Trim();
                    if (idx2 == -1) idx2 = detDesc.Length;

                    var sizeParts = detDesc.Substring(idx1 + 1, idx2 - idx1 - 1).Replace("Size", string.Empty).Trim().Split((char)160);
                    var sizeStr = sizeParts[0];
                    var sizeType = sizeParts[1];
                    var size = double.Parse(sizeStr, new NumberFormatInfo { CurrencyDecimalSeparator = "." });
                    if (sizeType == "KiB")
                        size = Math.Round(size / 1024, 2);
                    else if (sizeType == "GiB")
                        size = size * 1024;
                    if (minSize.HasValue && size < minSize.Value) continue;
                    if (maxSize.HasValue && size > maxSize.Value) continue;

                    var seed = Convert.ToInt32(tds[2].TextContent);
                    if (minSeed.HasValue && seed < minSeed.Value) continue;

                    var leech = Convert.ToInt32(tds[3].TextContent);

                    results.Add(new TorrentSearchResult(service, this, torrentUrl, torrentName, seed, leech, size, null, age, magnetUri));
                }
            }

            return results;
        }
        public async Task<IEnumerable<ITorrentSearchResult>> Search(string search, VideoQuality videoQuality = VideoQuality.Any, string excludeKeywords = null,
                                                                    int? minSize = null, int? maxSize = null, int? minSeed = null, ITorrentDownloader service = null) {
            if (videoQuality != VideoQuality.Any) {
                switch (videoQuality) {
                    case VideoQuality.P720:
                        search += " 720p";
                        break;
                    case VideoQuality.P1080:
                        search += " 1080p";
                        break;
                }
            }

            if (!string.IsNullOrEmpty(excludeKeywords)) {
                excludeKeywords = " " + excludeKeywords;
                search += excludeKeywords.Replace(" ", " -");
            }
            
            var url = Helper.CombineUrls(Settings.BaseUrl, "usearch", search);
            using (var client = new NovaromaWebClient()) {
                string html;
                try {
                    html = await client.DownloadStringTaskAsync(url);
                }
                catch (WebException ex) {
                    var errorResponse = ex.Response as HttpWebResponse;
                    if (errorResponse != null && errorResponse.StatusCode == HttpStatusCode.NotFound)
                        return Enumerable.Empty<TorrentSearchResult>();

                    throw;
                }

                var document = DocumentBuilder.Html(html);
                var items = document.All
                    .Where(n => n.TagName == "TR" && (n.ClassName == "even" || n.ClassName == "odd"));

                var results = new List<TorrentSearchResult>();
                foreach (var item in items) {
                    var tds = item.QuerySelectorAll("td");

                    var torrentDiv = tds[0].QuerySelector("div[class='iaconbox center floatright']");
                    var torrentLinks = torrentDiv.QuerySelectorAll("a");
                    var tlc = torrentLinks.Length;
                    var magnetUri = torrentLinks[tlc - 2].Attributes.First(a => a.Name == "href").Value;
                    var torrentUrl = torrentLinks[tlc - 1].Attributes.First(a => a.Name == "href").Value;

                    var torrentNameDiv = tds[0].QuerySelector("div[class='torrentname']");
                    var torrentName = torrentNameDiv.QuerySelectorAll("a").First(n => n.ClassName == "cellMainLink").TextContent;

                    var sizeParts = tds[1].TextContent.Split(' ');
                    var sizeStr = sizeParts[0];
                    var sizeType = sizeParts[1];
                    var size = double.Parse(sizeStr, new NumberFormatInfo {CurrencyDecimalSeparator = "."});
                    if (sizeType == "KB")
                        size = Math.Round(size/1024, 2);
                    else if (sizeType == "GB")
                        size = size*1024;
                    if (minSize.HasValue && size < minSize.Value) continue;
                    if (maxSize.HasValue && size > maxSize.Value) continue;

                    var seed = int.Parse(tds[4].TextContent);
                    if (minSeed.HasValue && seed < minSeed.Value) continue;

                    int? files = null;
                    int filesTmp;
                    var filesStr = tds[2].TextContent;
                    if (int.TryParse(filesStr, out filesTmp))
                        files = filesTmp;
                    var age = tds[3].TextContent;
                    var leech = int.Parse(tds[5].TextContent);

                    results.Add(new TorrentSearchResult(service, this, torrentUrl, torrentName, seed, leech, size, files, age, magnetUri));
                }

                return results;
            }
        }
        public async Task <IEnumerable <ITorrentSearchResult> > Search(string search, VideoQuality videoQuality = VideoQuality.Any, string excludeKeywords = null,
                                                                       int?minSize = null, int?maxSize = null, int?minSeed = null, ITorrentDownloader service = null)
        {
            if (videoQuality != VideoQuality.Any)
            {
                switch (videoQuality)
                {
                case VideoQuality.P720:
                    search += " 720p";
                    break;

                case VideoQuality.P1080:
                    search += " 1080p";
                    break;
                }
            }

            var excludeList = string.IsNullOrEmpty(excludeKeywords)
                ? Enumerable.Empty <string>().ToList()
                : excludeKeywords.Split(' ').Select(e => e.Trim()).Where(e => !string.IsNullOrEmpty(e)).Distinct().ToList();

            var results = new List <TorrentSearchResult>();
            var url     = Helper.CombineUrls(Settings.BaseUrl, "", search);

            using (var client = new NovaromaWebClient()) {
                var html = await client.DownloadStringTaskAsync(url);

                var document = new HtmlParser(html).Parse();
                var items    = document.QuerySelectorAll("table[id='searchResult'] tr");

                foreach (var item in items)
                {
                    var tds = item.QuerySelectorAll("td");
                    if (tds.Length < 4)
                    {
                        continue;
                    }

                    var mainTd      = tds[1];
                    var anchor      = mainTd.Children[0].Children[0];
                    var torrentUrl  = Helper.CombineUrls(Settings.BaseUrl, anchor.Attributes.First(a => a.Name == "href").Value);
                    var torrentName = anchor.TextContent.Trim();
                    if (excludeList.Any(e => torrentName.IndexOf(e, StringComparison.OrdinalIgnoreCase) > 0))
                    {
                        continue;
                    }

                    var magnetUri   = tds[1].Children[1].Attributes.First(a => a.Name == "href").Value;
                    var detDescNode = tds[1].QuerySelectorAll("font[class='detDesc']").First();
                    var detDesc     = detDescNode.TextContent;
                    var idx1        = detDesc.IndexOf(",", StringComparison.OrdinalIgnoreCase);
                    var idx2        = detDesc.IndexOf(",", idx1 + 1, StringComparison.Ordinal);
                    var age         = detDesc.Substring(0, idx1).Replace("Uploaded", string.Empty).Trim();
                    if (idx2 == -1)
                    {
                        idx2 = detDesc.Length;
                    }

                    var sizeParts = detDesc.Substring(idx1 + 1, idx2 - idx1 - 1).Replace("Size", string.Empty).Trim().Split((char)160);
                    var sizeStr   = sizeParts[0];
                    var sizeType  = sizeParts[1];
                    var size      = double.Parse(sizeStr, new NumberFormatInfo {
                        CurrencyDecimalSeparator = "."
                    });
                    if (sizeType == "KiB")
                    {
                        size = Math.Round(size / 1024, 2);
                    }
                    else if (sizeType == "GiB")
                    {
                        size = size * 1024;
                    }
                    if (minSize.HasValue && size < minSize.Value)
                    {
                        continue;
                    }
                    if (maxSize.HasValue && size > maxSize.Value)
                    {
                        continue;
                    }

                    var seed = Convert.ToInt32(tds[2].TextContent);
                    if (minSeed.HasValue && seed < minSeed.Value)
                    {
                        continue;
                    }

                    var leech = Convert.ToInt32(tds[3].TextContent);

                    results.Add(new TorrentSearchResult(service, this, torrentUrl, torrentName, seed, leech, size, null, age, magnetUri));
                }
            }

            return(results);
        }
        public Task <IEnumerable <ITorrentSearchResult> > SearchTvShowEpisode(string name, int season, int episode, string episodeName, string imdbId = null,
                                                                              VideoQuality videoQuality = VideoQuality.Any, string extraKeywords = null, string excludeKeywords = null,
                                                                              int?minSize = null, int?maxSize = null, int?minSeed = null, ITorrentDownloader service = null)
        {
            var query = Settings.TvShowEpisodeSearchPattern;

            query = Helper.PopulateTvShowEpisodeSearchQuery(query, name, season, episode, imdbId, extraKeywords);
            return(Search(query, videoQuality, excludeKeywords, minSize, maxSize, minSeed, service));
        }
        public async Task <IEnumerable <ITorrentSearchResult> > SearchMovie(string name, int?year = null, string imdbId          = null, VideoQuality videoQuality = VideoQuality.Any,
                                                                            string extraKeywords  = null, string excludeKeywords = null,
                                                                            int?minSize           = null, int?maxSize = null, int?minSeed = null, ITorrentDownloader service = null)
        {
            var query = Settings.MovieSearchPattern;

            IEnumerable <ITorrentSearchResult> results;

            if (query == ThePirateBaySettings.ImdbSearchQuery)
            {
                results = await Search(imdbId, VideoQuality.Any, excludeKeywords, minSize, maxSize, minSeed, service);
            }
            else
            {
                query   = Helper.PopulateMovieSearchQuery(query, name, year, imdbId, extraKeywords);
                results = await Search(query, videoQuality, excludeKeywords, minSize, maxSize, minSeed, service);
            }

            if (query == ThePirateBaySettings.ImdbSearchQuery)
            {
                string filter;
                switch (videoQuality)
                {
                case VideoQuality.P720:
                    filter = "720p";
                    break;

                case VideoQuality.P1080:
                    filter = "1080p";
                    break;

                default:
                    filter = string.Empty;
                    break;
                }
                if (extraKeywords != null)
                {
                    filter += " " + extraKeywords;
                }

                if (filter != string.Empty)
                {
                    var filters = filter.Split(' ');
                    results = results.Where(r => filters.All(e => r.Name.Contains(e)));
                }
            }

            return(results);
        }
Exemple #13
0
        public async Task <IEnumerable <ITorrentSearchResult> > Search(string search, VideoQuality videoQuality = VideoQuality.Any, string excludeKeywords = null,
                                                                       int?minSize = null, int?maxSize = null, int?minSeed = null, ITorrentDownloader service = null)
        {
            if (videoQuality != VideoQuality.Any)
            {
                switch (videoQuality)
                {
                case VideoQuality.P720:
                    search += " 720p";
                    break;

                case VideoQuality.P1080:
                    search += " 1080p";
                    break;
                }
            }

            if (!string.IsNullOrEmpty(excludeKeywords))
            {
                excludeKeywords = " " + excludeKeywords;
                search         += excludeKeywords.Replace(" ", " -");
            }

            var url = Helper.CombineUrls(Settings.BaseUrl, "usearch", search);

            using (var client = new NovaromaWebClient()) {
                string html;
                try {
                    html = await client.DownloadStringTaskAsync(url);
                }
                catch (WebException ex) {
                    var errorResponse = ex.Response as HttpWebResponse;
                    if (errorResponse != null && errorResponse.StatusCode == HttpStatusCode.NotFound)
                    {
                        return(Enumerable.Empty <TorrentSearchResult>());
                    }

                    throw;
                }

                var document = DocumentBuilder.Html(html);
                var items    = document.All
                               .Where(n => n.TagName == "TR" && (n.ClassName == "even" || n.ClassName == "odd"));

                var results = new List <TorrentSearchResult>();
                foreach (var item in items)
                {
                    var tds = item.QuerySelectorAll("td");

                    var torrentDiv   = tds[0].QuerySelector("div[class='iaconbox center floatright']");
                    var torrentLinks = torrentDiv.QuerySelectorAll("a");
                    var tlc          = torrentLinks.Length;
                    var magnetUri    = torrentLinks[tlc - 2].Attributes.First(a => a.Name == "href").Value;
                    var torrentUrl   = torrentLinks[tlc - 1].Attributes.First(a => a.Name == "href").Value;

                    var torrentNameDiv = tds[0].QuerySelector("div[class='torrentname']");
                    var torrentName    = torrentNameDiv.QuerySelectorAll("a").First(n => n.ClassName == "cellMainLink").TextContent;

                    var sizeParts = tds[1].TextContent.Split(' ');
                    var sizeStr   = sizeParts[0];
                    var sizeType  = sizeParts[1];
                    var size      = double.Parse(sizeStr, new NumberFormatInfo {
                        CurrencyDecimalSeparator = "."
                    });
                    if (sizeType == "KB")
                    {
                        size = Math.Round(size / 1024, 2);
                    }
                    else if (sizeType == "GB")
                    {
                        size = size * 1024;
                    }
                    if (minSize.HasValue && size < minSize.Value)
                    {
                        continue;
                    }
                    if (maxSize.HasValue && size > maxSize.Value)
                    {
                        continue;
                    }

                    var seed = int.Parse(tds[4].TextContent);
                    if (minSeed.HasValue && seed < minSeed.Value)
                    {
                        continue;
                    }

                    int?files = null;
                    int filesTmp;
                    var filesStr = tds[2].TextContent;
                    if (int.TryParse(filesStr, out filesTmp))
                    {
                        files = filesTmp;
                    }
                    var age   = tds[3].TextContent;
                    var leech = int.Parse(tds[5].TextContent);

                    results.Add(new TorrentSearchResult(service, this, torrentUrl, torrentName, seed, leech, size, files, age, magnetUri));
                }

                return(results);
            }
        }
Exemple #14
0
        public Task <IEnumerable <ITorrentSearchResult> > SearchMovie(string name, int?year = null, string imdbId          = null, VideoQuality videoQuality = VideoQuality.Any,
                                                                      string extraKeywords  = null, string excludeKeywords = null,
                                                                      int?minSize           = null, int?maxSize = null, int?minSeed = null, ITorrentDownloader service = null)
        {
            var query = Settings.MovieSearchPattern;

            if (!string.IsNullOrEmpty(imdbId))
            {
                imdbId = imdbId.Replace("tt", "");
            }

            query  = Helper.PopulateMovieSearchQuery(query, name, year, imdbId, extraKeywords);
            query += " category:movies";
            return(Search(query, videoQuality, excludeKeywords, minSize, maxSize, minSeed, service));
        }
Exemple #15
0
 public SeedingEventArgs(Uri torrentFileUri, ITorrentDownloader downloader)
 {
     this.TorrentFileUri = torrentFileUri;
     Downloader          = downloader;
     BeginTime           = DateTime.UtcNow;
 }