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
294 stars 120 forks source link

[BUG] VideoUnavailableException even though the video is available on youtube #271

Open MxD-js opened 6 months ago

MxD-js commented 6 months ago

Describe the bug YoutubeExplode library throws a VideoUnavailableException but when I go to youtube.com the video is available and has multiple streams. 1080, 720, 360 and so on. This usually happens when a stream was live and then the live stream ended and video is available on youtube after the live stream. If I wait long enough, or the following day the issue resolves it self, but this can be reproduced everytime a stream transitions from live to not live.

image

To Reproduce Try to stream a live video then end the stream and attempt to play back the video after it's posted to youtube channel.

Future<Uri> _getYTMetadata(
    String videoId, YoutubeExplode ytXplode, bool isLive) async {
  if (isLive) {
    final liveStreamUrl =
        await ytXplode.videos.streams.getHttpLiveStreamUrl(VideoId(videoId));
    return Uri.parse(liveStreamUrl);
  } else {
    try {
      var manifest = await ytXplode.videos.streamsClient.getManifest(videoId);
      var muxedInfo = manifest.muxed.bestQuality;
      var videoUri = muxedInfo.url;
      return videoUri;
    } catch (e, stack) {
      print(e);
      print(stack);

      throw e;
    }
    // var streamInfo = manifest.video.withHighestBitrate();
  }
}

Youtube screenshot showing the video is available image

Stacktrace

I/flutter ( 5847): VideoUnavailableException: Video "n39W2uq4aXw" does not contain any playable streams.
I/flutter ( 5847): #0      StreamClient.getManifest.<anonymous closure> (package:youtube_explode_dart/src/videos/streams/stream_client.dart:178:9)
I/flutter ( 5847): <asynchronous suspension>
I/flutter ( 5847): #1      retry (package:youtube_explode_dart/src/retry.dart:16:14)
I/flutter ( 5847): <asynchronous suspension>
I/flutter ( 5847): #2      _getYTMetadata (package:scc_mobile_app_v2/src/features/video_player/presentation/video_player_item_controller.dart:66:22)
I/flutter ( 5847): <asynchronous suspension>
I/flutter ( 5847): #3      videoPlayerItemController (package:scc_mobile_app_v2/src/features/video_player/presentation/video_player_item_controller.dart:23:15)
I/flutter ( 5847): <asynchronous suspension>
I/flutter ( 5847): #4      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:348:9)
I/flutter ( 5847): <asynchronous suspension>

Enviroment: (please complete the following information):

Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.9, on macOS 14.3 23D56 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.2)
[✓] VS Code (version 1.86.0)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
Hexer10 commented 5 months ago

Hi, sorry for the late reply, do you still get this error? I've just tried with the video id you provided any I could get all the streams correctly.

MxD-js commented 5 months ago

No worries we're all busy, I appreciate you getting this library out there, super helpful.

So, I don't get the error on the video I posted anymore.

The error can be reproduced when a youtube live stream end and the live stream video is available on youtube as a video. The error usually fixes it self in a day or so, like youtube needs to process the video? not sure.. but I do still get the error.