无法从YouTube上传中提取视频

时间:2016-09-02 17:29:13

标签: c# youtube-api

有人可以告诉我为什么我不能拉动用户从频道上传视频?我不知道我的代码中还有什么可能遗漏的东西,似乎一切都在那里,但我总是在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();

...谢谢

1 个答案:

答案 0 :(得分:1)

在构建playlistRequest时,您必须设置playlistId参数而不是id参数:

playlistRequest.PlaylistId = uploadsPlaylistID;