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

[BUG] closedCaptions client does not work consistently #272

Open AnhNgDo opened 5 months ago

AnhNgDo commented 5 months ago

Describe the bug When using closedCaptions client to obtain trackInfo, sometimes it doens't work for certain videos and an empty list of trackInfo is returned.

To Reproduce

// get all data from closedCaptions client
  final trackManifest = await yt.videos.closedCaptions.getManifest(videoId);
  // get data for English tracks
 // ISSUES: some time trackInfo is returned as an empty list. The videos are in English, with transcript available on youtube page. 
  final trackInfo = trackManifest.getByLanguage('en');
  // error if can't get track data
  if (trackInfo.isEmpty) throw StateError('Could not get Caption Track Info');
  // get the first tack based on 1st track data
  final track = await yt.videos.closedCaptions.get(trackInfo.first);
  // combine all texts from track's captions
  final String captionText =
      track.captions.map((caption) => caption.text).join(' ');