Skip to content

Commit

Permalink
Throw the proper exception when a video requiring purchasing if fetch…
Browse files Browse the repository at this point in the history
…ed and disable comment tests
  • Loading branch information
Hexer10 committed Apr 2, 2024
1 parent 84ef108 commit 5afc6f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/src/videos/comments/comments_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class CommentsClient {

/// Returns a [List<Comment>] containing the first batch of comments or null if the video has comments disabled.
/// You can use [CommentsList.nextPage()] to get the next batch of comments.
///
/// WARNING: As of v2.2.0 this is broken due to yt updates.
Future<CommentsList?> getComments(Video video) async {
if (video.watchPage == null) {
return null;
Expand Down
11 changes: 8 additions & 3 deletions lib/src/videos/streams/stream_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,20 @@ class StreamClient {
{required bool fullManifest}) async* {
try {
// Use await for instead of yield* to catch exceptions
await for (final stream in _getStream(videoId, VideoController.androidTestSuiteClient)) {
await for (final stream
in _getStream(videoId, VideoController.androidTestSuiteClient)) {
yield stream;
}
if (fullManifest) {
await for (final stream in _getStream(videoId, VideoController.androidClient)) {
await for (final stream
in _getStream(videoId, VideoController.androidClient)) {
yield stream;
}
}
} on VideoUnplayableException {
} on VideoUnplayableException catch (e) {
if (e is VideoRequiresPurchaseException) {
rethrow;
}
yield* _getCipherStream(videoId);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/comments_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void main() {
expect(comments.length, greaterThanOrEqualTo(1));
expect(comments.totalLength, greaterThanOrEqualTo(1));
expect(comments.first.isHearted, false);
});
}, skip: 'Currently broken');

test('Comments of video with no comments should be empty', () async {
const videoUrl = 'https://www.youtube.com/watch?v=A3egPTy9hhA';
Expand Down

0 comments on commit 5afc6f0

Please sign in to comment.