Example #1
0
        /// <summary>
        /// Gets the metadata associated with the specified channel.
        /// </summary>
        public async ValueTask <Channel> GetAsync(
            ChannelId channelId,
            CancellationToken cancellationToken = default)
        {
            var channelPage = await _controller.GetChannelPageAsync(channelId, cancellationToken);

            var title =
                channelPage.TryGetChannelTitle() ??
                throw new YoutubeExplodeException("Could not extract channel title.");

            var logoUrl =
                channelPage.TryGetChannelLogoUrl() ??
                throw new YoutubeExplodeException("Could not extract channel logo URL.");

            return(new Channel(
                       channelId,
                       title,
                       CreateThumbnails(logoUrl)
                       ));
        }
        /// <summary>
        /// Enumerates videos uploaded by the specified channel.
        /// </summary>
        public IAsyncEnumerable <PlaylistVideo> GetUploadsAsync(ChannelId id)
        {
            var playlistId = "UU" + id.Value.SubstringAfter("UC");

            return(new PlaylistClient(_httpClient).GetVideosAsync(playlistId));
        }
Example #3
0
 /// <summary>
 /// Initializes an instance of <see cref="Channel"/>.
 /// </summary>
 public Channel(ChannelId id, string title, IReadOnlyList <Thumbnail> thumbnails)
 {
     Id         = id;
     Title      = title;
     Thumbnails = thumbnails;
 }