【问题标题】:Cannot pull videos from youtube uploads无法从 youtube 上传中提取视频
【发布时间】:2017-01-10 21:27:32
【问题描述】:

有人可以告诉我为什么我不能从频道中提取用户上传的视频吗?我不知道我的代码中还缺少什么,一切似乎都在那里,但我的 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();

谢谢...

【问题讨论】:

    标签: c# youtube-api


    【解决方案1】:

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

    playlistRequest.PlaylistId = uploadsPlaylistID;
    

    【讨论】:

    • 你是个天才。我已经盯着那个代码两天了。
    • @sledgehammer 很高兴能帮上忙! :D
    猜你喜欢
    • 2012-03-22
    • 2017-09-11
    • 2020-06-26
    • 1970-01-01
    • 1970-01-01
    • 2012-06-07
    • 1970-01-01
    • 2023-04-03
    • 2012-07-19
    相关资源
    最近更新 更多