getVideos method

Stream<Video> getVideos(
  1. dynamic id
)

Enumerates videos included in the specified playlist.

Implementation

Stream<Video> getVideos(dynamic id) async* {
  id = PlaylistId.fromString(id);
  final encounteredVideoIds = <String>{};

  PlaylistPage? page = await PlaylistPage.get(_httpClient, id.value);

  while (page != null) {
    for (final video in page.videos) {
      var videoId = video.id;

      // Already added
      if (!encounteredVideoIds.add(videoId)) {
        continue;
      }

      if (video.channelId.isEmpty) {
        continue;
      }

      yield Video(
        VideoId(videoId),
        video.title,
        video.author,
        ChannelId(video.channelId),
        null,
        null,
        null,
        video.description,
        video.duration,
        ThumbnailSet(videoId),
        null,
        Engagement(video.viewCount, null, null),
        false,
      );
    }
    page = await page.nextPage(_httpClient);
  }
}