diff --git a/CHANGELOG.md b/CHANGELOG.md index ae501fd..0f29abd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.4.2 +- Implement `getSrt` a video closed captions in srt format. +- Only throw custom exceptions from the library. + ## 1.4.1+1 - Bug fixes diff --git a/lib/src/reverse_engineering/responses/channel_upload_page.dart b/lib/src/reverse_engineering/responses/channel_upload_page.dart index 5b3bf2a..6af906a 100644 --- a/lib/src/reverse_engineering/responses/channel_upload_page.dart +++ b/lib/src/reverse_engineering/responses/channel_upload_page.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:html/dom.dart'; import 'package:html/parser.dart' as parser; +import 'package:youtube_explode_dart/src/exceptions/exceptions.dart'; import '../../channels/channel_video.dart'; import '../../extensions/helpers_extension.dart'; @@ -106,7 +107,7 @@ class _InitialData { ['items'] .cast>(); } - throw Exception('Couldn\'t find the content data'); + throw FatalFailureException('Failed to get initial data context.'); } Map getContinuationContext(Map root) { diff --git a/lib/src/reverse_engineering/responses/search_page.dart b/lib/src/reverse_engineering/responses/search_page.dart index 4e9f538..767b8b5 100644 --- a/lib/src/reverse_engineering/responses/search_page.dart +++ b/lib/src/reverse_engineering/responses/search_page.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:html/dom.dart'; import 'package:html/parser.dart' as parser; +import '../../../youtube_explode_dart.dart'; import '../../extensions/helpers_extension.dart'; import '../../playlists/playlist_id.dart'; import '../../retry.dart'; @@ -131,7 +132,7 @@ class _InitialData { ['itemSectionContinuation']['contents'] .cast>(); } - throw Exception('Couldn\'t find the content data'); + throw FatalFailureException('Failed to get initial data context.'); } Map getContinuationContext(Map root) { diff --git a/lib/src/videos/comments/comments_client.dart b/lib/src/videos/comments/comments_client.dart index 07bb723..d4cd5a3 100644 --- a/lib/src/videos/comments/comments_client.dart +++ b/lib/src/videos/comments/comments_client.dart @@ -44,12 +44,10 @@ class CommentsClient { /// a page contains at most 20 comments, use .take if you want to limit /// the results. /// - /// Throws an exception if the given video has not a watch page available. - /// this happens for the videos from playlist or search queries. + /// The streams doesn't emit any data if [Video.hasWatchPage] is false. Stream getComments(Video video) async* { if (video.watchPage == null) { - //TODO: Implement custom exception. - throw Exception('Watch page not available for this video'); + return; } yield* _getComments( video.watchPage.initialData.continuation, diff --git a/lib/src/videos/video.dart b/lib/src/videos/video.dart index 0c5050b..27eba3a 100644 --- a/lib/src/videos/video.dart +++ b/lib/src/videos/video.dart @@ -46,6 +46,9 @@ class Video with EquatableMixin { /// Shouldn't be used in the code. final WatchPage watchPage; + /// Returns true if the watch page is available for this video. + bool get hasWatchPage => watchPage != null; + /// Initializes an instance of [Video] Video( this.id,