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
326 stars 144 forks source link

[BUG] Closing curly brace in description results in json parsing error #109

Closed ghost closed 3 years ago

ghost commented 3 years ago

Describe the bug When a video has a closing curly brace } in the description, JSON parsing will fail.

To Reproduce Include the code which doesn't work in the code markdown..

var yt = YoutubeExplode();
var video = await yt.videos.streamsClient.getManifest('https://www.youtube.com/watch?v=9Jg_Fwc0QOY');

print('Manifest: $video');

Stacktrace

Unhandled exception:
FormatException: Unterminated string (at character 26832)
...746bXg","isOwnerViewing":false,"shortDescription":"I love breaking json } }
                                                                              ^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1404:5)
#1      _ChunkedJsonParser.close (dart:convert-patch/convert_patch.dart:515:9)
#2      _parseJson (dart:convert-patch/convert_patch.dart:41:10)
#3      JsonDecoder.convert (dart:convert/json.dart:506:36)
#4      JsonCodec.decode (dart:convert/json.dart:157:41)
#5      new PlayerResponse.parse (package:youtube_explode_dart/src/reverse_engineering/responses/player_response.dart:127:50)
#6      WatchPage.getPlayerResponse (package:youtube_explode_dart/src/reverse_engineering/responses/watch_page.dart:150:27)
#7      WatchPage.playerResponse (package:youtube_explode_dart/src/reverse_engineering/responses/watch_page.dart:137:47)
#8      WatchPage.playerResponse (package:youtube_explode_dart/src/reverse_engineering/responses/watch_page.dart)
#9      StreamsClient._getStreamContextFromWatchPage (package:youtube_explode_dart/src/videos/streams/streams_client.dart:89:51)
<asynchronous suspension>
#10     StreamsClient.getManifest (package:youtube_explode_dart/src/videos/streams/streams_client.dart:234:21)
<asynchronous suspension>
#11     main (file:///home/***/Projects/ytexplode_test/bin/ytexplode_test.dart:5:15)
<asynchronous suspension>

Enviroment:

Additional context This only fails with yt.videos.streamClient.getManifest. yt.videos.get works fine.

Hexer10 commented 3 years ago

Thanks for filing an issue! There must be some major issue in the code that extracts the json part from the video page, I'll look into it.

burkard commented 3 years ago

I'm having the same issue