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
322 stars 141 forks source link

FormatException (FormatException: Unexpected extension byte (at offset 3912)) #194

Closed tuanbs closed 2 years ago

tuanbs commented 2 years ago

Describe the bug I got error FormatException (FormatException: Unexpected extension byte (at offset 3912)) when trying to get the auto translations of Vietnamese and Bulgarian languages from this YouTube video: https://www.youtube.com/watch?v=LUBNGJZP8m4

To Reproduce

Screen Shot 2022-03-02 at 11 28 57 pm

Enviroment:

Hexer10 commented 2 years ago

Seems like the Vietnamese translation sends some content that is not valid UTF8 encoding, so that produces an error. (You can even see it if you try to navigate directly to the url trackInfo.url ).

I've fixed this in v1.10.10+2 by allowing malformed UTF8 as well, if would be nice if you could test if the text is correct, I cannot speak neither language so I can't help, thank you!

tuanbs commented 2 years ago

Hi @Hexer10 , thanks for the quick update. I've just tested with version 1.10.10+2 and got the same error when trying to get the translation of Vietnamese:

Screen Shot 2022-03-04 at 8 33 01 am

And when I tried to get the Bulgarian translation I got another error FormatException (FormatException: Missing extension byte (at offset 7506)):

Screen Shot 2022-03-04 at 1 21 54 am

And when I tried to navigate directly to the url trackInfo.url as you suggested, I got the Encoding error for both Vietnamese and Bulgarian translations:

Screen Shot 2022-03-04 at 8 51 05 am Screen Shot 2022-03-04 at 8 51 14 am
tuanbs commented 2 years ago

@Hexer10 I see you speak Italian language, so I tried to find a YouTube video, that has this same error when getting the Italian translation, to see if you can help to fix this issue. When I get to this YouTube video and navigate directly to its trackInfo.url, then I got the Encoding error for Italian translation:

Screen Shot 2022-03-11 at 8 29 10 am
Hexer10 commented 2 years ago

Could you send me the code that are you running? I've just tried this and the subtitles were fetched correctly:

  final yt = YoutubeExplode();
  var manifest = await yt.videos.closedCaptions
      .getManifest('https://www.youtube.com/watch?v=0D3oqL6Boew');
  var trackInfo = manifest.tracks.first.autoTranslate('it');
  print(trackInfo.url);

  var track = await yt.videos.closedCaptions.getSubTitles(trackInfo);
  print(track);

  yt.close();

Also make sure you have the latest version.

Hexer10 commented 2 years ago

Closing due to inactivity, please reopen if this still happens.