youtube_explode_dart icon indicating copy to clipboard operation
youtube_explode_dart copied to clipboard

Fetching multiple videos with videoIDs at once

Open triggerfx opened this issue 6 months ago • 0 comments

Hi guys, I don't know if I'm not doing it right, but I have a list with videoIDs where I want to get information such as title, channel name, thumbnail. With increasing numbers of ids it takes a long time to fetch these, thats my issue. When doing a search request with a specific term, it is MUCH faster. I can get this information very quick. I want to fetch multiple IDs because I want them in batches (like playlists in-app), but it really takes too much time. Is there a way to do this faster?

example:

Future fetchVideoDetails() async { var yt = YoutubeExplode();

var futures = videoIds.map((videoId) async {
  var video = await yt.videos.get('$videoId');
  return {
    'title': video.title,
    'channel': video.author,
  };
}).toList();

var results = await Future.wait(futures);

_videoDetails.addAll(results);

}

triggerfx avatar Aug 06 '24 19:08 triggerfx