首页 > 解决方案 > 获取从使用 Youtube api 的帐户管理的频道列表?

问题描述

我正在尝试使用 Youtube api 和 oath2.0 检索从 1 个帐户管理的频道列表。我正在创建一个控制台应用程序,以设置 oath2.0 我在开发人员控制台中创建了其他应用程序类型。现在,当我第一次运行该应用程序时,它会启动浏览器并要求我进行身份验证并选择一个频道。这是我用于身份验证的代码:'''

            CancellationTokenSource cts = new CancellationTokenSource();
            cts.CancelAfter(TimeSpan.FromSeconds(20));
            CancellationToken ct = cts.Token;
            UserCredential credential;
            credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(

                new ClientSecrets
                {
                    ClientId = "XXXXXX",
                    ClientSecret = "XXXXX"
                },               
                new[] { YouTubeService.Scope.YoutubeForceSsl, YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeUpload, YouTubeService.Scope.YoutubepartnerChannelAudit, YouTubeService.Scope.Youtubepartner },
                "<UserID>",
                ct,
                new FileDataStore(this.GetType().ToString())
            );

            var youtubeService = new YouTubeService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = this.GetType().ToString()
            });

'''

由于我只选择了 1 个频道,因此我无法获取帐户中管理的所有频道的列表。
我正在尝试使用以下 api 访问频道:

'''

            var channelsinStream = youtubeService.Channels.List("snippet,contentDetails,statistics");

            channelsinStream.Mine = true;

            var channelresponse = await channelsinStream.ExecuteAsync(); 

'''

这样做的主要座右铭是在添加频道后删除频道中的所有实时视频。我们有接近 100 个频道,因此每次都很难通过每个频道来删除它们。

标签: youtube-apiyoutube-data-api

解决方案


推荐阅读