DiscordRadioBot/Classes/YoutubeSearchEngine.cs
/// <summary>
/// Searches in YouTube using the given search query and returns a list of parsed data. 
/// Excludes all Channels, Playlists and Broadcasts from the search.
/// </summary>
/// <param name="searchListResponse"> Search Response from YouTube. </param>
/// <returns></returns>
Searches in YouTube using the given search query and returns a list of parsed data.
Excludes all Channels, Playlists and Broadcasts from the search.
Searches in YouTube using the given search query and returns a list of parsed data . Excludes all Channels Playlists and Broadcasts from the search .
private Dictionary<string, string> GetYouTubeSearchResults(SearchListResponse searchListResponse)
        {
            Dictionary<string, string> videos = new Dictionary<string, string>();
            foreach(SearchResult result in searchListResponse.Items)
            {
                if(result.Snippet.LiveBroadcastContent == "none")
                {
                    string title = ParseVideoTitle(result);
                    if(!videos.ContainsKey(title))
                    {
                        videos.Add(title, @$"https://www.youtube.com/watch?v=" + $"{result.Id.VideoId}");
                        WriteLine($"Music video added to the list of Videos. Original music title: {result.Snippet.Title}");
                    }
                    else
                    {
                        WriteLine($"Music video {title} is already in the list! Skipping...");
                    }
                }
            }
            WriteLine($"\nSearch done! I've searched for {_maxSearchResults} and I've found {videos.Count} videos.\n");
            return videos;
        }
private Dictionary < string , string > GetYouTubeSearchResults ( SearchListResponse searchListResponse ) { Dictionary < string , string > videos = new Dictionary < string , string > ( ) ; foreach ( SearchResult result in searchListResponse . Items ) { if ( result . Snippet . LiveBroadcastContent == " " ) { string title = ParseVideoTitle ( result ) ; if ( ! videos . ContainsKey ( title ) ) { videos . Add ( title , @$" https://www.youtube.com/watch?v= " + $" { result . Id . VideoId } " ) ; WriteLine ( $" Music video added to the list of Videos. Original music title:  { result . Snippet . Title } " ) ; } else { WriteLine ( $" Music video  { title }  is already in the list! Skipping... " ) ; } } } WriteLine ( $" \n Search done! I've searched for  { _maxSearchResults }  and I've found  { videos . Count }  videos. \n " ) ; return videos ; }
Searches in YouTube using the given search query and returns a list of parsed data.
Searches in YouTube using the given search query and returns a list of parsed data .
None
searchListResponse
SearchListResponse
Search Response from YouTube.
Search Response from YouTube .