Esempio n. 1
0
        public static string Validate(string clientid, string url)
        {
            var hubContext = GlobalHost.ConnectionManager.GetHubContext <ProgressHub>();

            //hubContext.Clients.User(clientid).progress("Called from Controller");
            hubContext.Clients.Client(clientid).progress("getting video info..");
            string    uid    = GetYid(url);
            WebClient client = new WebClient();
            string    json   = client.DownloadString("https://www.googleapis.com/youtube/v3/videos?part=statistics&key=AIzaSyBRhULlCbQcdBk_HLFrpP-UU6VlyXInAPQ&id=" + uid);
            YtVideo   jo1    = JsonConvert.DeserializeObject <YtVideo>(json);

            hubContext.Clients.Client(clientid).progress("getting video comments...");
            json = client.DownloadString("https://www.googleapis.com/youtube/v3/commentThreads?key=AIzaSyBRhULlCbQcdBk_HLFrpP-UU6VlyXInAPQ&textFormat=plainText&part=snippet&maxResults=100&videoId=" + uid);
            YtComment jo = JsonConvert.DeserializeObject <YtComment>(json);

            hubContext.Clients.Client(clientid).progress("validating the feed...");
            var rest = GetWordCheck(jo);

            hubContext.Clients.Client(clientid).progress("Completed...");
            return(GetRating(rest, jo1));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string url = "https://www.youtube.com/watch?v=rWSSSzM7Nbg";

            //url = "https://www.youtube.com/embed/BmOpD46eZoA?start=36&end=65";
            url = "https://www.youtube.com/watch?v=2Vv-BfVoq4g&list=PLx0sYbCqOb8TBPRdmBHs5Iftvv9TPboYG";
            //url = "http://immanuel.co/";
            //url = "";
            url = "rWSSSzM7Nbg";
            //var uid = Regex.Match(url, @"(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&amp;]v=)|youtu\.be\/)([^""&amp;?\/ ]{11})").Groups[1].Value;

            //var uid1 = Regex.Match(url, @"(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&amp;]v=)|youtu\.be\/)([^""&amp;?\/ ]{11})").Groups[1].Value;

            //Works fine
            var regexString = @"^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*";
            var vvvl        = Regex.Match(url, regexString);
            var uid3        = vvvl.Groups[2].Value;

            uid3 = string.IsNullOrEmpty(uid3) ? url : uid3;

            WebClient client = new WebClient();
            string    json   = client.DownloadString("https://www.googleapis.com/youtube/v3/commentThreads?key=AIzaSyBRhULlCbQcdBk_HLFrpP-UU6VlyXInAPQ&textFormat=plainText&part=snippet&maxResults=100&videoId=" + uid3);
            YtComment jo     = JsonConvert.DeserializeObject <YtComment>(json);

            json = client.DownloadString("https://www.googleapis.com/youtube/v3/videos?part=statistics&key=AIzaSyBRhULlCbQcdBk_HLFrpP-UU6VlyXInAPQ&id=" + uid3);
            YtVideo jo1 = JsonConvert.DeserializeObject <YtVideo>(json);

            Console.WriteLine(uid3);


            //HtmlDocument doc = new HtmlDocument();
            //WebClient client = new WebClient();
            //string html = client.DownloadString("https://www.googleapis.com/youtube/v3/commentThreads?key=AIzaSyBRhULlCbQcdBk_HLFrpP-UU6VlyXInAPQ&textFormat=plainText&part=snippet&videoId=9EVeC7jmdtc");
            //doc.LoadHtml(html);

            //HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("//div");

            //YtComment jo = JsonConvert.DeserializeObject<YtComment>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Test.Scrape\YT_Comment_1.json"));
            //YtVideo jo1 = JsonConvert.DeserializeObject<YtVideo>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Test.Scrape\YT_Vid.json"));

            //JObject dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Vulgar.json"));
            //List<string> vulgar = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("vulgar").ToString());

            //dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Ugly.json"));
            //List<string> ugly = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("ugly").ToString());

            //dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Positive.json"));
            //List<string> positive = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("positive").ToString());

            //dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Offensive.json"));
            //List<string> offensive = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("offensive").ToString());

            //dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Negative.json"));
            //List<string> negative = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("negative").ToString());

            //dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Insult.json"));
            //List<string> insult = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("insult").ToString());

            //dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Harsh.json"));
            //List<string> harsh = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("harsh").ToString());

            ////dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Complaint.json"));
            ////List<string> complaint = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("complaint").ToString());

            //dd = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(@"C:\Immi\Personal\MyProjects\you-dl\Immanuel.Ydl\Immanuel.Yt.Cmments.Feedback\Immanuel.Yt.Cmments.Feedback\App_Data\en-EN\Apologizing.json"));
            //List<string> apologize = JsonConvert.DeserializeObject<List<string>>(dd.GetValue("apologize").ToString());

            //string text = "Why pay 400 for 3 instruments when you can get all 3 for 400 each! oh wait....";
            //var sents = text.Split('.').ToList();
            //List<string> wrds = new List<string>();
            //sents.ForEach(t => wrds.AddRange(t.Split(' ')));

            //var vulgarinter = vulgar.Intersect(wrds, StringComparer.OrdinalIgnoreCase).ToList();
            //vulgarinter = vulgar.Intersect(sents, StringComparer.OrdinalIgnoreCase).ToList();

            //var uglyinter = ugly.Intersect(wrds, StringComparer.OrdinalIgnoreCase).ToList();
            //uglyinter = ugly.Intersect(sents, StringComparer.OrdinalIgnoreCase).ToList();

            //var positiveinter = positive.Intersect(wrds, StringComparer.OrdinalIgnoreCase).ToList();
            //positiveinter = positive.Intersect(sents, StringComparer.OrdinalIgnoreCase).ToList();

            //var offensiveinter = offensive.Intersect(wrds, StringComparer.OrdinalIgnoreCase).ToList();
            //offensiveinter = offensive.Intersect(sents, StringComparer.OrdinalIgnoreCase).ToList();

            //var negativeinter = negative.Intersect(wrds, StringComparer.OrdinalIgnoreCase).ToList();
            //negativeinter = negative.Intersect(sents, StringComparer.OrdinalIgnoreCase).ToList();

            //var insultinter = insult.Intersect(wrds, StringComparer.OrdinalIgnoreCase).ToList();
            //insultinter = insult.Intersect(sents, StringComparer.OrdinalIgnoreCase).ToList();

            //var harshinter = harsh.Intersect(wrds, StringComparer.OrdinalIgnoreCase).ToList();
            //harshinter = harsh.Intersect(sents, StringComparer.OrdinalIgnoreCase).ToList();

            //var apologizeinter = apologize.Intersect(wrds, StringComparer.OrdinalIgnoreCase).ToList();
            //apologizeinter = apologize.Intersect(sents, StringComparer.OrdinalIgnoreCase).ToList();

            Console.ReadKey();
        }
Esempio n. 3
0
        static string GetRating(string str, YtVideo vid)
        {
            StringBuilder          repp = new StringBuilder();
            List <Models.TextRank> lst  = JsonConvert.DeserializeObject <List <Models.TextRank> >(str);
            var ll = from l in lst
                     group l by new
            {
                l.ProfaneRate,
                l.WordPercentage
            } into gcs
            //select gcs;
                select new TextRank()
            {
                ProfaneRate    = gcs.Key.ProfaneRate,
                WordPercentage = gcs.Key.WordPercentage,
                Count          = gcs.Count()
            };
            var      lw = ll.ToList();
            TextRank tot0 = null, tot3 = null, tot10 = null, tot20 = null, tot30 = null, tot40 = null,
                     tot50 = null, tot60 = null, tot70 = null, tot80 = null, tot90 = null, tot100 = null;

            lw.ForEach(t1 =>
            {
                Console.WriteLine(t1.Count);
                if (t1.WordPercentage == 0)
                {
                    tot0 = t1;
                }
                else if (t1.WordPercentage == 3)
                {
                    tot3 = t1;
                }
                else if (t1.WordPercentage == 10)
                {
                    tot10 = t1;
                }
                else if (t1.WordPercentage == 20)
                {
                    tot20 = t1;
                }
                else if (t1.WordPercentage == 30)
                {
                    tot30 = t1;
                }
                else if (t1.WordPercentage == 40)
                {
                    tot40 = t1;
                }
                else if (t1.WordPercentage == 50)
                {
                    tot50 = t1;
                }
                else if (t1.WordPercentage == 60)
                {
                    tot60 = t1;
                }
                else if (t1.WordPercentage == 70)
                {
                    tot70 = t1;
                }
                else if (t1.WordPercentage == 80)
                {
                    tot80 = t1;
                }
                else if (t1.WordPercentage == 90)
                {
                    tot90 = t1;
                }
                else if (t1.WordPercentage == 100)
                {
                    tot100 = t1;
                }
            });
            Item itm = null;

            if (vid.items != null && vid.items.Count > 0)
            {
                itm = vid.items[0];
            }
            if (tot0 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot0.Count / iu * 100;
                    //repp += tot0.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed." + Environment.NewLine;
                    repp.AppendLine(tot0.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    //repp += tot0.ProfaneRate + Environment.NewLine;
                    repp.AppendLine(tot0.ProfaneRate);
                }
            }
            if (tot3 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot3.Count / iu * 100;
                    //repp += tot3.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed." + Environment.NewLine;
                    repp.AppendLine(tot3.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    //repp += tot3.ProfaneRate + Environment.NewLine;
                    repp.AppendLine(tot3.ProfaneRate);
                }
            }
            if (tot10 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot10.Count / iu * 100;
                    repp.AppendLine(tot10.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot10.ProfaneRate);
                }
            }
            if (tot20 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot20.Count / iu * 100;
                    repp.AppendLine(tot20.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot20.ProfaneRate);
                }
            }
            if (tot30 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot30.Count / iu * 100;
                    repp.AppendLine(tot30.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot30.ProfaneRate);
                }
            }
            if (tot40 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot40.Count / iu * 100;
                    repp.AppendLine(tot40.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot40.ProfaneRate);
                }
            }
            if (tot50 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot50.Count / iu * 100;
                    repp.AppendLine(tot50.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot50.ProfaneRate);
                }
            }
            if (tot60 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot60.Count / iu * 100;
                    repp.AppendLine(tot60.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot60.ProfaneRate);
                }
            }
            if (tot70 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot70.Count / iu * 100;
                    repp.AppendLine(tot70.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot70.ProfaneRate);
                }
            }
            if (tot80 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot80.Count / iu * 100;
                    repp.AppendLine(tot80.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot80.ProfaneRate);
                }
            }
            if (tot90 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot90.Count / iu * 100;
                    repp.AppendLine(tot90.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot90.ProfaneRate);
                }
            }
            if (tot100 != null)
            {
                if (itm != null)
                {
                    //int iu = Convert.ToInt32(itm.statistics.commentCount);
                    int    iu   = 100;
                    double pcnt = (double)tot100.Count / iu * 100;
                    repp.AppendLine(tot100.ProfaneRate + " Comments recieved, " + Math.Round(pcnt, 2).ToString() + "% - Of Initial 100 Comments assessed.");
                }
                else
                {
                    repp.AppendLine(tot100.ProfaneRate);
                }
            }

            return(repp.ToString());
        }