Example #1
0
        //Updated July 15th
        public static void WriteShows()
        {
            try
            {
                HtmlNodeCollection collection = DownloadMgmtUtils.GetHtmlNodeCollection
                                                    (ConfigurationManager.AppSettings["show_url"] +
                                                    ConfigurationManager.AppSettings["show_url_list_postfix"], "//a");

                MongoCollection mongoCollection = MongoUtils.GetMongoCollection
                                                  (
                    @"mongodb://" + ConfigurationManager.AppSettings["mongoHost"] + @"/",
                    ConfigurationManager.AppSettings["port"],
                    ConfigurationManager.AppSettings["db"],
                    ConfigurationManager.AppSettings["show_collection"]
                                                  );

                foreach (
                    HtmlNode link in
                    collection.Where(link => !ConfigurationManager.AppSettings["show_innerhtml_excl"].Split(',')
                                     .Any(s => link.InnerHtml.Contains(s))).Where(link => link.Attributes[0].Value != null))
                {
                    mongoCollection.Insert(new TvShow()
                    {
                        Name = link.InnerHtml, Path = link.Attributes[0].Value
                    });
                }
            }
            catch (Exception e)
            {
                Log.AppendToLog("Error : FATAL Write Show Issue : " + e, ConfigurationManager.AppSettings["log_file"]);
            }
        }
Example #2
0
        //Updated July 30th - Combined with WriteEpisodes
        public static void RefreshEpisodes()
        {
            try
            {
                MongoCollection mongoCollection = MongoUtils.GetMongoCollection
                                                  (
                    @"mongodb://" + ConfigurationManager.AppSettings["mongoHost"] + @"/",
                    ConfigurationManager.AppSettings["port"],
                    ConfigurationManager.AppSettings["db"],
                    ConfigurationManager.AppSettings["show_collection"]
                                                  );

                foreach (var show in mongoCollection.FindAllAs <TvShow>().ToList <TvShow>())
                {
                    if (!ConfigurationManager.AppSettings["show_excl"].Split(',').Any(s => show.Name.Contains(s)))
                    {
                        HtmlNodeCollection collection =
                            DownloadMgmtUtils.GetHtmlNodeCollection(
                                ConfigurationManager.AppSettings["show_url"] + show.Path, "//a");

                        if (collection != null)
                        {
                            foreach (var link in collection.Where(link =>
                                                                  !ConfigurationManager.AppSettings["episode_innerhtml_excl"].Split(',')
                                                                  .Any(s => link.InnerHtml.Contains(s)) &&
                                                                  link.Attributes.Count > 0 && !link.Attributes[0].Value.Contains("tvnews") &&
                                                                  link.Attributes[HrefIndex(link)].Value.Contains("/ep")))
                            {
                                UpdateShowFromHtml(show, link.InnerHtml, collection, collection.IndexOf(link));
                            }
                        }

                        mongoCollection.Save(show);
                    }
                }
            }
            catch (Exception e)
            {
                Log.AppendToLog("Error : FATAL Refresh Episodes Issue : " + e,
                                ConfigurationManager.AppSettings["log_file"]);
            }
        }
Example #3
0
        //Updated July 30th
        public static void RefreshShows()
        {
            try
            {
                HtmlNodeCollection collection = DownloadMgmtUtils.GetHtmlNodeCollection
                                                    (ConfigurationManager.AppSettings["show_url"] +
                                                    ConfigurationManager.AppSettings["show_url_list_postfix"], "//a");

                MongoCollection mongoCollection = MongoUtils.GetMongoCollection
                                                  (
                    @"mongodb://" + ConfigurationManager.AppSettings["mongoHost"] + @"/",
                    ConfigurationManager.AppSettings["port"],
                    ConfigurationManager.AppSettings["db"],
                    ConfigurationManager.AppSettings["show_collection"]
                                                  );

                foreach (HtmlNode link in from link in collection
                         where
                         !ConfigurationManager.AppSettings["show_innerhtml_excl"].Split(',')
                         .Any(s => link.InnerHtml.Contains(s))
                         let tvShowList =
                             mongoCollection.FindAs <TvShow>(Query.EQ("Name", link.InnerHtml)).ToList <TvShow>()
                             where tvShowList.Count == 0
                             select link)
                {
                    mongoCollection.Insert(new TvShow()
                    {
                        Name = link.InnerHtml, Path = link.Attributes[0].Value
                    });
                }
            }
            catch (Exception e)
            {
                Log.AppendToLog("Error : FATAL Refresh Show Issue : " + e, ConfigurationManager.AppSettings["log_file"]);
            }
        }
Example #4
0
        //Updated July 26th
        public static void WriteImdbMovies()
        {
            bool end = false, firstMovie = true;
            int  results = 252, incrementer = 1;

            try
            {
                while (!end)
                {
                    if (incrementer < results)
                    {
                        HtmlNodeCollection collection =
                            DownloadMgmtUtils.GetHtmlNodeCollection(firstMovie ? ConfigurationManager.AppSettings["imdb_root"] : ImdbUrlIncrementor(incrementer), "//a");
                        if (firstMovie)
                        {
                            HtmlNodeCollection divCollection = DownloadMgmtUtils.GetHtmlNodeCollection(ConfigurationManager.AppSettings["imdb_root"], "//div");
                            var ppp = divCollection.Where(d => d.Attributes.Count > 0 && d.Attributes[0].Value == "left").ToList();
                            results = Convert.ToInt32(ppp[0].InnerText.Replace("1-250 of", "")
                                                      .Replace("\n", "")
                                                      .Replace(",", "")
                                                      .Replace("titles.", ""));
                            firstMovie = false;
                        }

                        foreach (HtmlNode n in collection)
                        {
                            if (n.Attributes.Count != 1 || !n.Attributes[0].Value.Contains("/title/"))
                            {
                                continue;
                            }
                            MongoCollection mongoCollection = MongoUtils.GetMongoCollection
                                                              (
                                @"mongodb://" + ConfigurationManager.AppSettings["mongoHost"] + @"/",
                                ConfigurationManager.AppSettings["port"],
                                ConfigurationManager.AppSettings["db"],
                                ConfigurationManager.AppSettings["movie_collection"]
                                                              );
                            var mongoMovie = mongoCollection.FindAs <Movie>(Query.EQ("ImdbCode", n.Attributes[0].Value.Replace("/title/", "").Replace("/", ""))).ToList <Movie>();
                            //Check to see if the movie already exists
                            if (mongoMovie.Count == 0)
                            {
                                mongoCollection.Insert(new Movie()
                                {
                                    ImdbCode  = n.Attributes[0].Value.Replace("/title/", "").Replace("/", ""),
                                    ImdbTitle = n.InnerText,
                                    Urls      = new List <string>()
                                    {
                                        "http://www.imdb.com" + n.Attributes[0].Value
                                    },
                                    Downloaded = false
                                });
                            }
                            else
                            {
                                mongoMovie[0].ImdbTitle = n.Attributes[0].Value.Replace("/title/", "").Replace("/", "");
                                mongoMovie[0].Urls.Add("http://www.imdb.com" + n.Attributes[0].Value);
                                mongoCollection.Save(mongoMovie[0]);
                            }
                        }
                        incrementer = incrementer + 250;
                    }
                    else
                    {
                        end = true;
                    }
                }
            }
            catch (Exception e)
            { Log.AppendToLog("Error : FATAL write from IMDB. " + e, ConfigurationManager.AppSettings["log_file"]); }
        }