sledgehammer
sledgehammer

Reputation: 89

Cannot pull videos from youtube uploads

Can someone enlighten me as to why I cannot pull the user upload videos from a channel? I don't know what else I could be missing in my code, everything seems to be there but I always get back a zero on my playlistresponse.items.

    var youtubeService = new YouTubeService(new BaseClientService.Initializer() { ApiKey = "API-KEY" }); // mypersonal key
    var ChannelSectionRequest = youtubeService.Channels.List("contentDetails");
    ChannelSectionRequest.Id = channelID;
    var ChannelSectionResponse = await ChannelSectionRequest.ExecuteAsync();
    foreach (var ChannelSectionItem in ChannelSectionResponse.Items)
    {
        var uploadsPlaylistID = ChannelSectionItem.ContentDetails.RelatedPlaylists.Uploads;
        var nextPageToken = "";
        while (nextPageToken != null)
        {
            var playlistRequest = youtubeService.PlaylistItems.List("snippet");
            playlistRequest.Id = uploadsPlaylistID;
            playlistRequest.MaxResults = 50;
            playlistRequest.PageToken = nextPageToken;
            var playlistResponse = await playlistRequest.ExecuteAsync();

Thanks...

Upvotes: 2

Views: 46

Answers (1)

Simon Kirsten
Simon Kirsten

Reputation: 2577

You must set the playlistId parameter rather than the id parameter while building playlistRequest:

playlistRequest.PlaylistId = uploadsPlaylistID;

Upvotes: 1

Related Questions