Only throw custom exceptions.

getUploadsFromPage no longer throws
This commit is contained in:
Mattia 2020-07-16 19:28:49 +02:00
parent c68f8d45f6
commit e107c60581
5 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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<Map<String, dynamic>>();
}
throw Exception('Couldn\'t find the content data');
throw FatalFailureException('Failed to get initial data context.');
}
Map<String, dynamic> getContinuationContext(Map<String, dynamic> root) {

View File

@ -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<Map<String, dynamic>>();
}
throw Exception('Couldn\'t find the content data');
throw FatalFailureException('Failed to get initial data context.');
}
Map<String, dynamic> getContinuationContext(Map<String, dynamic> root) {

View File

@ -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<Comment> 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,

View File

@ -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,