Merge pull request #73 from shinyford/master
Add thumbnails to SearchVideo
This commit is contained in:
commit
114fd3580c
|
@ -232,6 +232,7 @@ class _InitialData {
|
|||
_parseRuns(renderer.title.runs),
|
||||
_parseRuns(renderer.ownerText.runs),
|
||||
_parseRuns(renderer.descriptionSnippet?.runs),
|
||||
(renderer.thumbnail.thumbnails ?? [])..sort((a ,b) => a.width.compareTo(b.width));
|
||||
renderer.lengthText?.simpleText ?? '',
|
||||
int.parse(renderer.viewCountText?.simpleText
|
||||
?.stripNonDigits()
|
||||
|
|
|
@ -21,9 +21,19 @@ class SearchVideo extends BaseSearchContent {
|
|||
/// Video View Count
|
||||
final int videoViewCount;
|
||||
|
||||
/// Video thumbnail uris
|
||||
final List<String> 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)';
|
||||
|
|
|
@ -34,6 +34,14 @@ void main() {
|
|||
expect(nextPage, isNull);
|
||||
});
|
||||
|
||||
test('Search youtube videos have thumbnails', () async {
|
||||
var searchQuery = await yt.search.queryFromPage('hello');
|
||||
expect(searchQuery.content.first, isA<SearchVideo>());
|
||||
|
||||
var video = searchQuery.content.first as SearchVideo;
|
||||
expect(video.videoThumbnails, isNotEmpty);
|
||||
});
|
||||
|
||||
test('Search youtube videos from search page (stream)', () async {
|
||||
var query = await yt.search.getVideosFromPage('hello').take(30).toList();
|
||||
expect(query, hasLength(30));
|
||||
|
|
Loading…
Reference in New Issue