Fix #194: allow malformed utf8

Version 1.10.10+2
This commit is contained in:
Mattia 2022-03-03 12:11:02 +01:00
parent 51ba543deb
commit 0ce24bf017
3 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,6 @@
## 1.10.10+2
- Fix #194: Now closed-captions allow malformed utf8 as well.
## 1.10.10+1
- Deprecated `withHighestBitrate()` in favour of `bestQuality`.

View File

@ -1,3 +1,5 @@
import 'dart:convert';
import '../../extensions/helpers_extension.dart';
import '../../reverse_engineering/clients/closed_caption_client.dart' as re
show ClosedCaptionClient;
@ -28,7 +30,8 @@ class ClosedCaptionClient {
]}) async {
videoId = VideoId.fromString(videoId);
var tracks = <ClosedCaptionTrackInfo>{};
var watchPage = await WatchPage.get(_httpClient, (videoId as VideoId).value);
var watchPage =
await WatchPage.get(_httpClient, (videoId as VideoId).value);
var playerResponse = watchPage.playerResponse!;
for (final track in playerResponse.closedCaptionTrack) {
@ -56,7 +59,9 @@ class ClosedCaptionClient {
return ClosedCaptionTrack(captions);
}
/// Returns the subtitles as a string.
Future<String> getSubTitles(ClosedCaptionTrackInfo trackInfo) =>
_httpClient.getString(trackInfo.url);
/// Returns the subtitles as a string. In XML format.
Future<String> getSubTitles(ClosedCaptionTrackInfo trackInfo) async {
final r = await _httpClient.get(trackInfo.url);
return utf8.decode(r.bodyBytes, allowMalformed: true);
}
}

View File

@ -1,6 +1,6 @@
name: youtube_explode_dart
description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key.
version: 1.10.10+1
version: 1.10.10+2
homepage: https://github.com/Hexer10/youtube_explode_dart