Skip to content

Commit 9d50d20

Browse files
committed
Version 1.9.9
Fix Hexer10#134
1 parent d0baedf commit 9d50d20

File tree

4 files changed

+47
-35
lines changed

4 files changed

+47
-35
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.9.9
2+
- Fix issue #134 (Error when getting the hls manifest from a livestream)
3+
14
## 1.9.8+1
25
- Fix example
36

lib/src/videos/streams/streams_client.dart

+10-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class StreamsClient {
8282
final playerConfig = watchPage.playerConfig;
8383

8484
var playerResponse =
85-
playerConfig?.playerResponse ?? watchPage.playerResponse;
85+
watchPage.playerResponse ?? playerConfig?.playerResponse;
8686
if (playerResponse == null) {
8787
throw VideoUnplayableException.unplayable(videoId);
8888
}
@@ -235,9 +235,15 @@ class StreamsClient {
235235
/// Gets the HTTP Live Stream (HLS) manifest URL
236236
/// for the specified video (if it's a live video stream).
237237
Future<String> getHttpLiveStreamUrl(VideoId videoId) async {
238-
var videoInfoResponse =
239-
await VideoInfoResponse.get(_httpClient, videoId.toString());
240-
var playerResponse = videoInfoResponse.playerResponse;
238+
final watchPage = await WatchPage.get(_httpClient, videoId.value);
239+
240+
final playerResponse = watchPage.playerResponse;
241+
242+
if (playerResponse == null) {
243+
throw TransientFailureException(
244+
'Couldn\'t extract the playerResponse from the Watch Page!');
245+
}
246+
241247
if (!playerResponse.isVideoPlayable) {
242248
throw VideoUnplayableException.unplayable(videoId,
243249
reason: playerResponse.videoPlayabilityError ?? '');

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: youtube_explode_dart
22
description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key.
3-
version: 1.9.8+1
3+
version: 1.9.9
44

55
homepage: https://github.com/Hexer10/youtube_explode_dart
66

test/streams_test.dart

+33-30
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ void main() {
1313

1414
group('Get streams manifest of any video', () {
1515
for (final val in {
16-
VideoId('9bZkp7q19f0'), // very popular
17-
VideoId(
18-
'SkRSXFQerZs'), // age restricted (embed allowed) - This is unplayable
19-
VideoId('hySoCSoH-g8'), // age restricted (embed not allowed)
20-
VideoId('_kmeFXjjGfk'), // embed not allowed (type 1)
21-
VideoId('MeJVWBSsPAY'), // embed not allowed (type 2)
22-
VideoId('5VGm0dczmHc'), // rating not allowed
23-
VideoId('ZGdLIwrGHG8'), // unlisted
24-
VideoId('rsAAeyAr-9Y'), // recording of a live stream
25-
VideoId('AI7ULzgf8RU'), // has DASH manifest
16+
VideoId('9bZkp7q19f0'), //Normal
17+
VideoId('ZGdLIwrGHG8'), //Unlisted
18+
VideoId('rsAAeyAr-9Y'), //LiveStreamRecording
19+
VideoId('V5Fsj_sCKdg'), //ContainsHighQualityStreams
20+
VideoId('AI7ULzgf8RU'), //ContainsDashManifest
21+
VideoId('-xNN-bJQ4vI'), //Omnidirectional
22+
VideoId('vX2vsvdq8nw'), //HighDynamicRange
23+
VideoId('YltHGKX80Y8'), //ContainsClosedCaptions
24+
VideoId('_kmeFXjjGfk'), //EmbedRestrictedByYouTube
25+
VideoId('MeJVWBSsPAY'), //EmbedRestrictedByAuthor
26+
VideoId('SkRSXFQerZs'), //AgeRestricted
27+
VideoId('hySoCSoH-g8'), //AgeRestrictedEmbedRestricted
28+
VideoId('5VGm0dczmHc'), //RatingDisabled
2629
VideoId('-xNN-bJQ4vI'), // 360° video
2730
}) {
2831
test('VideoId - ${val.value}', () async {
@@ -37,6 +40,13 @@ void main() {
3740
throwsA(const TypeMatcher<VideoRequiresPurchaseException>()));
3841
});
3942

43+
test('Get the hls manifest of a live stream', () async {
44+
expect(
45+
await yt!.videos.streamsClient
46+
.getHttpLiveStreamUrl(VideoId('5qap5aO4i9A')),
47+
isNotEmpty);
48+
});
49+
4050
group('Stream of unavailable videos throws VideoUnavailableException', () {
4151
for (final val in {VideoId('qld9w0b-1ao'), VideoId('pb_hHv3fByo')}) {
4252
test('VideoId - ${val.value}', () {
@@ -48,26 +58,19 @@ void main() {
4858

4959
group('Get specific stream of any playable video', () {
5060
for (final val in {
51-
VideoId('9bZkp7q19f0'),
52-
// very popular
53-
VideoId(
54-
'SkRSXFQerZs'), // age restricted (embed allowed) - This is unplayable
55-
VideoId('hySoCSoH-g8'),
56-
// age restricted (embed not allowed)
57-
VideoId('_kmeFXjjGfk'),
58-
// embed not allowed (type 1)
59-
VideoId('MeJVWBSsPAY'),
60-
// embed not allowed (type 2)
61-
// VideoId('5VGm0dczmHc'),
62-
// rating not allowed
63-
VideoId('ZGdLIwrGHG8'),
64-
// unlisted
65-
VideoId('rsAAeyAr-9Y'),
66-
// recording of a live stream
67-
VideoId('AI7ULzgf8RU'),
68-
// has DASH manifest
69-
VideoId('-xNN-bJQ4vI'),
70-
// 360° video
61+
VideoId('9bZkp7q19f0'), //Normal
62+
VideoId('ZGdLIwrGHG8'), //Unlisted
63+
VideoId('rsAAeyAr-9Y'), //LiveStreamRecording
64+
VideoId('V5Fsj_sCKdg'), //ContainsHighQualityStreams
65+
VideoId('AI7ULzgf8RU'), //ContainsDashManifest
66+
VideoId('-xNN-bJQ4vI'), //Omnidirectional
67+
VideoId('vX2vsvdq8nw'), //HighDynamicRange
68+
VideoId('YltHGKX80Y8'), //ContainsClosedCaptions
69+
VideoId('_kmeFXjjGfk'), //EmbedRestrictedByYouTube
70+
VideoId('MeJVWBSsPAY'), //EmbedRestrictedByAuthor
71+
VideoId('SkRSXFQerZs'), //AgeRestricted
72+
VideoId('hySoCSoH-g8'), //AgeRestrictedEmbedRestricted
73+
VideoId('5VGm0dczmHc'), //RatingDisabled
7174
}) {
7275
test('VideoId - ${val.value}', () async {
7376
var manifest = await yt!.videos.streamsClient.getManifest(val);

0 commit comments

Comments
 (0)