diff --git a/lib/src/reverse_engineering/responses/search_page.dart b/lib/src/reverse_engineering/responses/search_page.dart index 84043e2..a56be93 100644 --- a/lib/src/reverse_engineering/responses/search_page.dart +++ b/lib/src/reverse_engineering/responses/search_page.dart @@ -205,6 +205,11 @@ class _InitialData { } if (content.containsKey('videoRenderer')) { Map renderer = content['videoRenderer']; + + final thumbnails = List>.from( + renderer.get('thumbnail')?.getValue('thumbnails') ?? [] + )..sort((a, b) => a['width'].compareTo(b['width'])); + //TODO: Add if it's a live return SearchVideo( VideoId(renderer['videoId']), @@ -215,8 +220,9 @@ class _InitialData { int.parse(renderer['viewCountText']['simpleText'] .toString() .stripNonDigits() - .nullIfWhitespace ?? - '0')); + .nullIfWhitespace ?? '0'), + thumbnails.map((thumb) => thumb['url']).toList(growable: false) + ); } if (content.containsKey('radioRenderer')) { var renderer = content['radioRenderer']; diff --git a/lib/src/search/search_video.dart b/lib/src/search/search_video.dart index ba5e5b2..7a409f9 100644 --- a/lib/src/search/search_video.dart +++ b/lib/src/search/search_video.dart @@ -20,9 +20,19 @@ class SearchVideo { /// Video View Count final int videoViewCount; + /// Video thumbnail uris + final List videoThumbnails; + /// Initialize a [SearchVideo] instance. - const SearchVideo(this.videoId, this.videoTitle, this.videoAuthor, - this.videoDescriptionSnippet, this.videoDuration, this.videoViewCount); + const SearchVideo( + this.videoId, + this.videoTitle, + this.videoAuthor, + this.videoDescriptionSnippet, + this.videoDuration, + this.videoViewCount, + this.videoThumbnails, + ); @override String toString() => '(Video) $videoTitle ($videoId)';