Closed TieHaxJan closed 4 years ago
I added the ability to download playlists by using the YouTube Data API to extract a list of URLs when given a playlist URL - here is a code sample.
List<string> videoUrls = new List<string>();
string nextPageToken = "";
//iterate over paginated playlist results from youtube and extract video URLs
while (nextPageToken != null)
{
//prepare a paged playlist request for the given playlist URL
var playlistRequest = _ytService.PlaylistItems.List("snippet,contentDetails");
playlistRequest.PlaylistId = GetPlaylistIdFromUrl(playlistURL);
playlistRequest.MaxResults = 50;
playlistRequest.PageToken = nextPageToken;
var searchListResponse = await playlistRequest.ExecuteAsync();
//iterate over the results and build each video URL
foreach (var item in searchListResponse.Items)
{
string videoUrl = $"http://www.youtube.com/watch?v={item.Snippet.ResourceId.VideoId}";
videoUrls.Add(videoUrl);
}
//index to the next page of results
nextPageToken = searchListResponse.NextPageToken;
}
Thanks a lot :)
You can use or take a reference https://github.com/omansak/YoutubeSharpApi
I wondered if you could add support for YouTube Playlists?