/// <summary> /// /// </summary> /// <param name="series"></param> /// <param name="episode"></param> /// <param name="quality"></param> /// <returns></returns> public override SearchResult FindTorrent(Series series, Episode episode, Global.EpisodeQuality quality) { string tempQuality = string.Empty; switch (quality) { case Global.EpisodeQuality.FullBluRay: tempQuality = "1024"; break; case Global.EpisodeQuality.HdTv: tempQuality = "HD"; break; case Global.EpisodeQuality.HdBluRay: case Global.EpisodeQuality.HdWebDl: case Global.EpisodeQuality.SdDvd: case Global.EpisodeQuality.SdTv: tempQuality = "720"; break; } DailyTvTorrents api = new DailyTvTorrents(); Torrent torrent = api.TorrentGetInfo(series.Name.Replace(" ", "-").ToLower(), string.Format("S{0}E{1}", ((int)episode.SeasonNumber).ToString("D2"), ((int)episode.EpisodeNumber).ToString("D2")), tempQuality); if (torrent.torrentFile == null) { return null; } FileNameParser fileNameParser = new FileNameParser(); fileNameParser.Parse(torrent.torrentFile); if (fileNameParser.Matched() == false) { return null; } SearchResult searchResult = new SearchResult(); searchResult.Url = torrent.torrentFile; return searchResult; }
/// <summary> /// /// </summary> /// <param name="series"></param> /// <param name="minAge"></param> /// <returns></returns> public override List<RssResult> UpdateRss(List<Series> series, int minAge) { FileNameParser fileNameParser = new FileNameParser(); List<RssResult> rssResults = new List<RssResult>(); foreach (Series serie in series) { WebClient wc = new WebClient(); byte[] temp = wc.DownloadData(string.Format("http://www.dailytvtorrents.org/rss/show/{0}?items=all&minage={1}", serie.Name.Replace(" ", "-").ToLower(), minAge)); string rss = Encoding.ASCII.GetString(temp); XDocument xDoc = XDocument.Parse(rss); foreach (var item in xDoc.Descendants("item")) { RssResult rssResult = new RssResult(); rssResult.SeriesId = serie.Id; rssResult.Title = Misc.GetElementValueAsString(item, "title"); var enclosure = from e in item.Elements("enclosure") select e; if (enclosure.Any() == false) { continue; } rssResult.Url = Misc.GetAttributeValueAsString(enclosure.First(), "url"); fileNameParser.Parse(rssResult.Title); if (fileNameParser.Matched() == true) { rssResult.SeasonNumber = fileNameParser.SeasonNumber; rssResult.EpisodeNumber = fileNameParser.EpisodeNumber; rssResult.Quality = fileNameParser.Quality; rssResults.Add(rssResult); } } } return rssResults; }