Exemple #1
0
    public async Task <bool> AddYoutubeVideo(string videoURL)
    {
        string videoId = "";

        if (!GetVideoId(videoURL, out videoId))
        {
            return(false);
        }

        if (videoURL.Contains("list="))
        {
            // get entire playlist
            string playlistID = videoURL.Substring(videoURL.IndexOf("list=") + 5);
            int    videoIndex = 1;
            if (playlistID.Contains("&index"))
            {
                videoIndex = int.Parse(playlistID.Substring(playlistID.IndexOf("&index") + 7));
                playlistID = playlistID.Substring(0, playlistID.IndexOf("&index"));
            }

            YoutubeExplode.Models.Playlist playlist = await client.GetPlaylistAsync(playlistID);

            if (playlist != null)
            {
                for (int i = videoIndex - 1; i < playlist.Videos.Count; i++)
                {
                    data.Enqueue(await YoutubeVideoStuff(playlist.Videos[i].Id));
                }
            }
        }
        VideoData newVideo = await YoutubeVideoStuff(videoId);

        if (newVideo != null)
        {
            data.Enqueue(newVideo);
        }
        return(newVideo != null);
    }
Exemple #2
0
 /// <summary>
 /// Gets the regular URL of a playlist.
 /// </summary>
 public static string GetRegularUrl(this Playlist playlist)
 {
     playlist.GuardNotNull(nameof(playlist));
     return($"https://www.youtube.com/playlist?list={playlist.Id}");
 }