Exemple #1
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);
        }
Exemple #2
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);
        }