public Torrent[] Search(string query, TorrentCategory category, TorrentSortOrder sortOrder = TorrentSortOrder.Title, TorrentSortOptions sortOptions = TorrentSortOptions.Ascending) { var url = BuildSearchUrl(query, category, sortOrder, sortOptions); var html = GetHtmlData(url); return ParseHtmlData(html); }
public Torrent[] Search(string query, TorrentCategory category, TorrentSortOrder sortOrder = TorrentSortOrder.Title, TorrentSortOptions sortOptions = TorrentSortOptions.Ascending) { var url = BuildSearchUrl(query, category, sortOrder, sortOptions, 1); Debug.WriteLine("URL = " + url); var searchResults = GetSearchResults(url); return searchResults.Select(GetTorrent).Cast<Torrent>().ToArray(); }
public Torrent[] Search(string query, TorrentCategory category, TorrentSortOrder sortOrder = TorrentSortOrder.Title, TorrentSortOptions sortOptions = TorrentSortOptions.Ascending) { var url = BuildUrlString(query, category, sortOrder, sortOptions); Debug.WriteLine("URL = " + url); var xmlStream = PerformKickassRequest(url); var xmlSerializer = new XmlSerializer(typeof(KickassRssContainer)); var torrents = (KickassRssContainer)xmlSerializer.Deserialize(xmlStream); xmlStream.Close(); return torrents.Channel.Torrents; }
private static string BuildUrlString(string query, TorrentCategory category, TorrentSortOrder sortOrder, TorrentSortOptions sortOptions) { string sortOpt = null, sortOrd = null; switch (sortOrder) { case TorrentSortOrder.Title: sortOrd = "name"; break; case TorrentSortOrder.Size: sortOrd = "size"; break; case TorrentSortOrder.Seeders: sortOrd = "seeders"; break; case TorrentSortOrder.Leechers: sortOrd = "leechers"; break; case TorrentSortOrder.Files: sortOrd = "files_count"; break; case TorrentSortOrder.Age: sortOrd = "time_add"; break; } switch (sortOptions) { case TorrentSortOptions.Ascending: sortOpt = "asc"; break; case TorrentSortOptions.Decending: sortOpt = "desc"; break; } return String.Format("{0}{1} category:{2}/?field={3}&sorder={4}&rss=1", BaseUrl, query, category.ToString().ToLower(), sortOrd, sortOpt); }
private static string BuildSearchUrl(string query, TorrentCategory category, TorrentSortOrder sortOrder, TorrentSortOptions sortOptions) { query = query.Replace(' ', '+'); int iht; switch (category) { case TorrentCategory.All: iht = 0; break; case TorrentCategory.Adult: iht = 4; break; case TorrentCategory.Anime: iht = 1; break; case TorrentCategory.Application: iht = 2; break; case TorrentCategory.Book: iht = 9; break; case TorrentCategory.Game: iht = 3; break; case TorrentCategory.Movie: iht = 5; break; case TorrentCategory.Music: iht = 6; break; case TorrentCategory.Tv: iht = 8; break; default: goto case TorrentCategory.All; } string opt; switch (sortOptions) { case TorrentSortOptions.Ascending: opt = "asc"; break; case TorrentSortOptions.Decending: opt = "desc"; break; default: goto case TorrentSortOptions.Ascending; } string so; switch (sortOrder) { case TorrentSortOrder.Age: so = "&Torrent_sort=created_at." + opt; break; case TorrentSortOrder.Files: goto default; case TorrentSortOrder.Leechers: so = "&Torrent_sort=leechers." + opt; break; case TorrentSortOrder.Seeders: so = "&Torrent_sort=seeders." + opt; break; case TorrentSortOrder.Size: so = "&Torrent_sort=size." + opt; break; case TorrentSortOrder.Title: so = ""; break; default: goto case TorrentSortOrder.Title; } return string.Format("{0}search.php?q={1}{2}&iht={3}", OpenBayUrl, query, so, iht); }
private string BuildSearchUrl(string query, TorrentCategory category, TorrentSortOrder sortOrder, TorrentSortOptions sortOptions, int pageNum) { string sortUrl; switch (sortOrder) { case TorrentSortOrder.Age: sortUrl = "{0}sort-search/{1}/time/{2}/{3}/"; break; case TorrentSortOrder.Leechers: sortUrl = "{0}sort-search/{1}/leechers/{2}/{3}/"; break; case TorrentSortOrder.Seeders: sortUrl = "{0}sort-search/{1}/seeders/{2}/{3}/"; break; case TorrentSortOrder.Size: sortUrl = "{0}sort-search/{1}/size/{2}/{3}/"; break; case TorrentSortOrder.Title: sortUrl = "{0}search/{1}/{3}/"; break; default: goto case TorrentSortOrder.Title; } string sortOrd; switch (sortOptions) { case TorrentSortOptions.Ascending: sortOrd = "asc"; break; case TorrentSortOptions.Decending: sortOrd = "desc"; break; default: goto case TorrentSortOptions.Ascending; } query = query.Replace(' ', '+'); return string.Format(sortUrl, BaseUrl, query, sortOrd, pageNum); }