Beispiel #1
0
 //Vergleicht Listenelemente (für's Anzahl zählen)
 public bool Equals(WordCount other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.count.Equals(other.count));
 }
Beispiel #2
0
 public static void AddList(ref List <WordCount> list, WordCount element)
 {
     if (list.Exists(x => x.Name.Equals(element._name)))
     {
         list.Find(x => x.Name.Equals(element._name)).Count += element._count;
     }
     else if (element._name != "")
     {
         list.Add(new WordCount(element._name, element._count));
     }
 }
Beispiel #3
0
 //Vergliecht Listenelemente (für Sortierung)
 public int CompareTo(WordCount compareWordCount)
 {
     if (compareWordCount == null)
     {
         return(1);
     }
     else
     {
         return(this.count.CompareTo(compareWordCount.count));
     }
 }
Beispiel #4
0
        public static List <WordCount> AuslesenYoutube(string messages, List <WordCount> list)
        {
            StreamReader  sr      = new StreamReader(messages);
            string        zeile   = "";
            List <string> videoID = new List <string>();

            while (!sr.EndOfStream)
            {
                string name = "";
                zeile = sr.ReadLine();
                if (zeile.Contains("www.youtube.com") && zeile.Contains("/user"))
                {
                    name = getYoutubeName(zeile);
                }
                else if (zeile.Contains("www.youtube.com") && zeile.Contains("laylist"))
                {
                    Console.WriteLine("Playlist");
                }
                else if (zeile.Contains("www.youtube.com"))
                {
                    videoID.Add(FilterYoutubeID(zeile));
                }
                if (name != "")
                {
                    WordCount.AddList(ref list, name);
                }
            }
            List <WordCount> channelList = YoutubeAPI.get_Channel_from_ID(videoID);

            foreach (var channel in channelList)
            {
                WordCount.AddList(ref list, channel);
            }
            list.Sort((x, y) => y.Count.CompareTo(x.Count));
            sr.Close();
            return(list);
        }
Beispiel #5
0
        public static List <WordCount> get_Channel_from_ID(List <string> videoId)
        {
            List <WordCount> list = new List <WordCount>();
            var youtubeService    = new YouTubeService(new BaseClientService.Initializer()
            {
                ApiKey = "AIzaSyCy1A3OpgVhtGP-rcRFN2Y23NJWnAT8JIY",
            });
            var searchListRequest = youtubeService.Videos.List("snippet");

            searchListRequest.Id = videoId; // Replace with your search term.

            // Call the search.list method to retrieve results matching the specified query term.
            var searchListResponse = searchListRequest.Execute();

            if (searchListResponse.Items.Count != 0)
            {
                for (int i = 0; i < searchListResponse.Items.Count; i++)
                {
                    string name = searchListResponse.Items[i].Snippet.ChannelTitle;
                    WordCount.AddList(ref list, name);
                }
            }
            return(list);
        }