Hexer10 / youtube_explode_dart

Dart library to interact with many Youtube APIs
https://pub.dev/packages/youtube_explode_dart
BSD 3-Clause "New" or "Revised" License
299 stars 122 forks source link

Fetching multiple videos with videoIDs at once #281

Open triggerfx opened 1 month ago

triggerfx commented 1 month ago

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);

}