Пример #1
0
        /// <summary>
        /// Get information about a channel.
        /// </summary>
        /// <param name="channelID">ID of the channel to get information for</param>
        /// <returns>Information about a channel.</returns>
        public Database.Types.Channel Info(string channelID)
        {
            try {
                // https://developers.google.com/youtube/v3/docs/channels/list
                API.ChannelsResource.ListRequest channelInfo = APIService.Channels.List("id,snippet");
                channelInfo.Id          = channelID;
                channelInfo.MaxResults  = 1;
                channelInfo.PrettyPrint = false;

                API.Data.Channel response = channelInfo.Execute().Items[0];

                Database.Types.Channel channel = new Database.Types.Channel {
                    ID           = response.Id,
                    Title        = response.Snippet.Title,
                    Description  = response.Snippet.Description,
                    ThumbnailURL = GetBestThumbnail(response.Snippet.Thumbnails)
                };

                LoggingManager.Log.Info($"Information processed for '{channel.ID}'.");
                return(channel);
            } catch (Exception ex) {
                LoggingManager.Log.Error(ex, $"Failed to get information for '{channelID}'.");
                return(null);
            }
        }
Пример #2
0
        public YoutubeRequest BuildRequest(YoutubeChannelSearchOption searchOption)
        {
            YouTubeService youtube = new YouTubeService(new BaseClientService.Initializer()
            {
                ApiKey = ApiKey
            });

            YoutubeRequest listRequest = youtube.Channels.List("id");

            listRequest.Id = searchOption.ChannelID;

            return(listRequest);
        }
Пример #3
0
        public override IEnumerable <YoutubeSearchResult> Search(YoutubeChannelSearchOption searchOption)
        {
            YoutubeRequest listRequest = BuildRequest(searchOption);
            var            list        = new List <YoutubeSearchResult>();

            int remain = searchOption.SearchCount;
            int count  = 1;

            string nextToken = string.Empty;

            // TODO : Search 구현
            while (true)
            {
                if (!nextToken.IsNullOrEmpty())
                {
                    listRequest.PageToken = nextToken;
                }
                else
                {
                }
            }

            return(null);
        }