Esempio n. 1
0
        public static void UpdateLatestVideo(ChromeDriver chromeDriver, YoutuberModel youtuber)
        {
            string latestVideo = string.Empty;
            string videoTime   = string.Empty;

            try
            {
                chromeDriver.Navigate().GoToUrl(youtuber.url + "/videos");

                latestVideo = chromeDriver.FindElementByCssSelector("#video-title").Text;
                videoTime   = chromeDriver.FindElementByCssSelector("#metadata-line > span:nth-child(2)").Text;

                if (youtuber.latestVideo != latestVideo)
                {
                    Console.WriteLine("New Post by: " + youtuber.name + " from " + videoTime);
                    Console.WriteLine(latestVideo);
                }

                youtuber.tickersMentioned = ScanForTickersNew(latestVideo);
                youtuber.latestVideo      = latestVideo;
                youtuber.videoTime        = videoTime;

                db.UpdateVideoRecord("Youtubers", youtuber, youtuber);
            }
            catch (AggregateException ex)
            {
                Console.WriteLine("Error: " + ex.InnerException);
            }
        }
Esempio n. 2
0
        public void UpdatePostRecord <T>(string table, YoutuberModel ytr, T record)
        {
            var collection = db.GetCollection <T>(table);
            var filter     = Builders <T> .Filter.Eq("name", ytr.name);

            var update = Builders <T> .Update.Set("latestPost", ytr.latestPost);

            var timeUpdate = Builders <T> .Update.Set("postTime", ytr.postTime);

            var tickersMentioned = Builders <T> .Update.Set("tickersMentioned", ytr.tickersMentioned);

            //Update last post
            collection.UpdateOne(
                filter,
                update,
                new UpdateOptions {
                IsUpsert = true
            });

            //Update last post time
            collection.UpdateOne(
                filter,
                timeUpdate,
                new UpdateOptions {
                IsUpsert = true
            });

            //Update tickers
            collection.UpdateOne(
                filter,
                tickersMentioned,
                new UpdateOptions {
                IsUpsert = true
            });
        }
Esempio n. 3
0
        public static void UpdateLatestPost(ChromeDriver chromeDriver, YoutuberModel youtuber)
        {
            string latestPost = string.Empty;
            string postTime   = string.Empty;

            try
            {
                chromeDriver.Navigate().GoToUrl(youtuber.url + "/community");

                if (!chromeDriver.FindElementByCssSelector("#message").Text.Contains("posted yet"))
                {
                    latestPost = chromeDriver.FindElementByCssSelector("#content-text").Text;
                    postTime   = chromeDriver.FindElementByCssSelector("#published-time-text > a").Text;

                    youtuber.latestPost       = latestPost;
                    youtuber.postTime         = postTime;
                    youtuber.tickersMentioned = ScanForTickersNew(latestPost);

                    if (youtuber.latestPost != latestPost)
                    {
                        Console.WriteLine("New Post by: " + youtuber.name + " from " + postTime);
                        Console.WriteLine(latestPost);
                    }

                    youtuber.latestPost = latestPost;
                    youtuber.postTime   = postTime;

                    db.UpdatePostRecord("Youtubers", youtuber, youtuber);
                }
            }
            catch (AggregateException ex)
            {
                Console.WriteLine("Error: " + ex.InnerException);
            }
        }