Only throw custom exceptions.
getUploadsFromPage no longer throws
This commit is contained in:
parent
c68f8d45f6
commit
e107c60581
|
@ -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
|
## 1.4.1+1
|
||||||
- Bug fixes
|
- Bug fixes
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:html/dom.dart';
|
import 'package:html/dom.dart';
|
||||||
import 'package:html/parser.dart' as parser;
|
import 'package:html/parser.dart' as parser;
|
||||||
|
import 'package:youtube_explode_dart/src/exceptions/exceptions.dart';
|
||||||
|
|
||||||
import '../../channels/channel_video.dart';
|
import '../../channels/channel_video.dart';
|
||||||
import '../../extensions/helpers_extension.dart';
|
import '../../extensions/helpers_extension.dart';
|
||||||
|
@ -106,7 +107,7 @@ class _InitialData {
|
||||||
['items']
|
['items']
|
||||||
.cast<Map<String, dynamic>>();
|
.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) {
|
Map<String, dynamic> getContinuationContext(Map<String, dynamic> root) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
||||||
import 'package:html/dom.dart';
|
import 'package:html/dom.dart';
|
||||||
import 'package:html/parser.dart' as parser;
|
import 'package:html/parser.dart' as parser;
|
||||||
|
|
||||||
|
import '../../../youtube_explode_dart.dart';
|
||||||
import '../../extensions/helpers_extension.dart';
|
import '../../extensions/helpers_extension.dart';
|
||||||
import '../../playlists/playlist_id.dart';
|
import '../../playlists/playlist_id.dart';
|
||||||
import '../../retry.dart';
|
import '../../retry.dart';
|
||||||
|
@ -131,7 +132,7 @@ class _InitialData {
|
||||||
['itemSectionContinuation']['contents']
|
['itemSectionContinuation']['contents']
|
||||||
.cast<Map<String, dynamic>>();
|
.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) {
|
Map<String, dynamic> getContinuationContext(Map<String, dynamic> root) {
|
||||||
|
|
|
@ -44,12 +44,10 @@ class CommentsClient {
|
||||||
/// a page contains at most 20 comments, use .take if you want to limit
|
/// a page contains at most 20 comments, use .take if you want to limit
|
||||||
/// the results.
|
/// the results.
|
||||||
///
|
///
|
||||||
/// Throws an exception if the given video has not a watch page available.
|
/// The streams doesn't emit any data if [Video.hasWatchPage] is false.
|
||||||
/// this happens for the videos from playlist or search queries.
|
|
||||||
Stream<Comment> getComments(Video video) async* {
|
Stream<Comment> getComments(Video video) async* {
|
||||||
if (video.watchPage == null) {
|
if (video.watchPage == null) {
|
||||||
//TODO: Implement custom exception.
|
return;
|
||||||
throw Exception('Watch page not available for this video');
|
|
||||||
}
|
}
|
||||||
yield* _getComments(
|
yield* _getComments(
|
||||||
video.watchPage.initialData.continuation,
|
video.watchPage.initialData.continuation,
|
||||||
|
|
|
@ -46,6 +46,9 @@ class Video with EquatableMixin {
|
||||||
/// Shouldn't be used in the code.
|
/// Shouldn't be used in the code.
|
||||||
final WatchPage watchPage;
|
final WatchPage watchPage;
|
||||||
|
|
||||||
|
/// Returns true if the watch page is available for this video.
|
||||||
|
bool get hasWatchPage => watchPage != null;
|
||||||
|
|
||||||
/// Initializes an instance of [Video]
|
/// Initializes an instance of [Video]
|
||||||
Video(
|
Video(
|
||||||
this.id,
|
this.id,
|
||||||
|
|
Loading…
Reference in New Issue