Esempio n. 1
0
        public Television(TLFeed feed, Database database, Collector collector, Torrenter torrenter)
        {
            feed.New += item =>
            {
                if (item.Categories[0].Name != "Episodes")
                    return;
                var shows = database.Get<Show>();
                if (shows.Any(show => item.Title.Text.ToLower().Contains(show.Title.ToLower())))
                {
                    var model = new Torrent(item.Title.Text, item.Links.First().Uri.ToString(), item.Categories.First().Name);
                    collector.Event(model);
                    torrenter.Download(item.Links.First().Uri.ToString());
                }
            };

            collector.On<Search>(search =>
            {
                var wc = new WebClient();
                var result = wc.DownloadString("http://www.imdb.com/xml/find?json=1&tt=on&q=" + search.Query);
                try
                {

                    var json = JObject.Parse(result);
                    var exact = json["title_popular"];
                    if (exact == null) return;
                    if(!exact["description"].ToString().Contains("TV")) return;
                    var show = new Show(exact[0]["title"].ToString());
                    collector.Event(show);
                }
                catch { }
            });
        }
Esempio n. 2
0
        public SearchParser(Collector collector)
        {
            collector.On<Browse>(browse =>
            {
                if (browse.Url.Contains("google.com"))
                {
                    var match = Regex.Match(browse.Url, "q=([^&]+)");
                    if (!match.Success) return;
                    _last = new Search()
                    {
                        Query = match.Groups[1].Value.Replace("+", " ").Replace("%20", " ")
                    };
                    collector.Event(_last);
                }

                if (browse.Referrer.Contains("google.com"))
                {
                    if(_last == null) return;
                    var found = new Found()
                    {
                        Query = _last.Query,
                        Url = browse.Url
                    };
                    collector.Event(found);
                }
            });
        }
Esempio n. 3
0
        public IMDBParser(Collector collector)
        {
            collector.On<Browse>(browse =>
            {
                if(!browse.Url.Contains("imdb.com/title")) return;
                var page = new WebPage(browse.Url);

                var title = page.DocumentNode.SelectSingleNode("//*[@id='overview-top']/h1/span[1]").InnerText;
                if (page.DocumentNode.SelectSingleNode("//*[@id='overview-top']/div[1]").InnerText.Contains("TV"))
                    collector.Event(new Show(title));
                else
                    collector.Event(new Movie(title));
            });
        }