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();
        }
Exemplo n.º 2
0
 public SeriesViewModel(Series series)
 {
     _series = series;
     Episodes =
         new BindableCollection<EpisodeViewModel>(
             series.Episodes.Where(e => !e.Watched).Select(e => new EpisodeViewModel(e)).OrderBy(e => e.CodedName));
 }
Exemplo 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;
        }
Exemplo n.º 4
0
        public void ReadSeries()
        {
            Authentication(_profile);

            IDictionary<int, RestShow> shows = null;
            IDictionary<int, RestEpisode> episodes = null;

            Parallel.Invoke(() => shows = GetShowsList(), () => episodes = GetUnwatchedEpisodesList());

            foreach (var restShow in shows.Values)
            {
                var series = _profile.Series.FirstOrDefault(p => p.Title == restShow.title);
                if (series == null)
                {
                    _profile.Series.Add(series = new Series(restShow.title));

                }
                if (series.Image == null)
                {
                    series.Image = new WebClientEx().DownloadDataIgnoreAndLog(restShow.image);
                }
            }

            var allEpisodes = _profile.Series.SelectMany(s => s.Episodes).ToList();

            foreach (var restEpisode in episodes.Values.GroupBy(e => shows[e.showId]))
            {
                var series = _profile.Series.First(s => s.Title == restEpisode.Key.title);
                foreach (var episode in restEpisode)
                {
                    if (episode.episodeNumber == 0) continue; //skip specials
                    var ep =
                        allEpisodes.FirstOrDefault(
                            e => e.Season == episode.seasonNumber && e.Number == episode.episodeNumber);
                    if (ep != null)
                    {
                        ep.AirDate = DateTime.ParseExact( episode.airDate,"dd.MM.yyyy",CultureInfo.InvariantCulture);
                        allEpisodes.Remove(ep);
                        continue;
                    }

                    series.Episodes.Add(new Episode(episode.seasonNumber, episode.episodeNumber) { Title = episode.title });
                }
            }
            foreach (var episode in allEpisodes)
            {
                episode.Watched = true;
            }
        }
Exemplo n.º 5
0
 public void RemoveSeries(Series series)
 {
     _databaseEntities.DeleteObject(series);
 }
Exemplo n.º 6
0
        public void ReadSeries(Profile profile)
        {
            var url = string.Format("http://api.myshows.ru/rss/{0}/episodes/aired/", profile.UserId);

            var xml = XDocument.Parse(new WebClientEx().DownloadString(url));
            var channel = xml.Root.Element("channel");
            foreach (var item in channel.Elements("item"))
            {
                var title = item.Element("title").Value;
                var seriesName = title.Substring(0, title.LastIndexOf(' '));
                var episodeName = title.Substring(title.LastIndexOf(' ') + 1);

                var series = profile.Series.FirstOrDefault(s => s.Title == seriesName);
                if (series == null)
                    profile.Series.Add(series = new Series(seriesName));

                var episode = series.Episodes.FirstOrDefault(e => e.CodedName == episodeName);
                if (episode == null)
                    series.Episodes.Add(episode = new Episode(episodeName));
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Create a new Series object.
 /// </summary>
 /// <param name="seriesId">Initial value of the SeriesId property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="profileId">Initial value of the ProfileId property.</param>
 public static Series CreateSeries(global::System.Int64 seriesId, global::System.String title, global::System.Int64 profileId)
 {
     Series series = new Series();
     series.SeriesId = seriesId;
     series.Title = title;
     series.ProfileId = profileId;
     return series;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Series EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSeries(Series series)
 {
     base.AddObject("Series", series);
 }