Add video thumbnails to SearchVideo
This commit is contained in:
parent
4646f484b8
commit
4047117eba
|
@ -205,6 +205,11 @@ class _InitialData {
|
||||||
}
|
}
|
||||||
if (content.containsKey('videoRenderer')) {
|
if (content.containsKey('videoRenderer')) {
|
||||||
Map<String, dynamic> renderer = content['videoRenderer'];
|
Map<String, dynamic> renderer = content['videoRenderer'];
|
||||||
|
|
||||||
|
final thumbnails = List<Map<String, dynamic>>.from(
|
||||||
|
renderer.get('thumbnail')?.getValue('thumbnails') ?? []
|
||||||
|
)..sort((a, b) => a['width'].compareTo(b['width']));
|
||||||
|
|
||||||
//TODO: Add if it's a live
|
//TODO: Add if it's a live
|
||||||
return SearchVideo(
|
return SearchVideo(
|
||||||
VideoId(renderer['videoId']),
|
VideoId(renderer['videoId']),
|
||||||
|
@ -215,8 +220,9 @@ class _InitialData {
|
||||||
int.parse(renderer['viewCountText']['simpleText']
|
int.parse(renderer['viewCountText']['simpleText']
|
||||||
.toString()
|
.toString()
|
||||||
.stripNonDigits()
|
.stripNonDigits()
|
||||||
.nullIfWhitespace ??
|
.nullIfWhitespace ?? '0'),
|
||||||
'0'));
|
thumbnails.map<String>((thumb) => thumb['url']).toList(growable: false)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (content.containsKey('radioRenderer')) {
|
if (content.containsKey('radioRenderer')) {
|
||||||
var renderer = content['radioRenderer'];
|
var renderer = content['radioRenderer'];
|
||||||
|
|
|
@ -20,9 +20,19 @@ class SearchVideo {
|
||||||
/// Video View Count
|
/// Video View Count
|
||||||
final int videoViewCount;
|
final int videoViewCount;
|
||||||
|
|
||||||
|
/// Video thumbnail uris
|
||||||
|
final List<String> videoThumbnails;
|
||||||
|
|
||||||
/// Initialize a [SearchVideo] instance.
|
/// Initialize a [SearchVideo] instance.
|
||||||
const SearchVideo(this.videoId, this.videoTitle, this.videoAuthor,
|
const SearchVideo(
|
||||||
this.videoDescriptionSnippet, this.videoDuration, this.videoViewCount);
|
this.videoId,
|
||||||
|
this.videoTitle,
|
||||||
|
this.videoAuthor,
|
||||||
|
this.videoDescriptionSnippet,
|
||||||
|
this.videoDuration,
|
||||||
|
this.videoViewCount,
|
||||||
|
this.videoThumbnails,
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '(Video) $videoTitle ($videoId)';
|
String toString() => '(Video) $videoTitle ($videoId)';
|
||||||
|
|
Loading…
Reference in New Issue