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 1 year ago • 1 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

Here's my 2 cents. Spawn around 4-8 isolates/threads (because it's resource intensive) fetch each one in isolate in parallal. Doubt there's any specific api for your usecase

khaled-0 avatar Apr 03 '25 14:04 khaled-0