Add thumbnail to `SearchVideo`.

Thanks to @shinyford !
This commit is contained in:
Mattia 2020-10-18 11:55:35 +02:00
parent 114fd3580c
commit 32c819f615
9 changed files with 21 additions and 16 deletions

View File

@ -3,6 +3,9 @@
- Only throw custom exceptions from the library. - Only throw custom exceptions from the library.
- `getUploadsFromPage` no longer throws. - `getUploadsFromPage` no longer throws.
## 1.6.1
- Add thumbnail to `SearchVideo` thanks to @shinyford !
## 1.6.0 ## 1.6.0
- BREAKING CHANGE: Renamed `getVideosAsync` to `getVideos`. - BREAKING CHANGE: Renamed `getVideosAsync` to `getVideos`.
- Implemented `getVideosFromPage` which supersedes `queryFromPage`. - Implemented `getVideosFromPage` which supersedes `queryFromPage`.

View File

@ -1,7 +1,7 @@
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'channel_link.dart'; import 'channel_link.dart';
import 'channel_thumbnail.dart'; import '../common/thumbnail.dart';
/// YouTube channel's about page metadata. /// YouTube channel's about page metadata.
class ChannelAbout with EquatableMixin { class ChannelAbout with EquatableMixin {
@ -19,7 +19,7 @@ class ChannelAbout with EquatableMixin {
final String title; final String title;
/// Channel thumbnails. /// Channel thumbnails.
final List<ChannelThumbnail> thumbnails; final List<Thumbnail> thumbnails;
/// Channel country. /// Channel country.
final String country; final String country;

View File

@ -1,8 +1,7 @@
import 'package:youtube_explode_dart/src/channels/channels.dart'; import '../common/common.dart';
import 'package:youtube_explode_dart/src/reverse_engineering/responses/channel_about_page.dart';
import '../extensions/helpers_extension.dart'; import '../extensions/helpers_extension.dart';
import '../playlists/playlists.dart'; import '../playlists/playlists.dart';
import '../reverse_engineering/responses/channel_about_page.dart';
import '../reverse_engineering/responses/channel_upload_page.dart'; import '../reverse_engineering/responses/channel_upload_page.dart';
import '../reverse_engineering/responses/responses.dart'; import '../reverse_engineering/responses/responses.dart';
import '../reverse_engineering/youtube_http_client.dart'; import '../reverse_engineering/youtube_http_client.dart';
@ -11,6 +10,7 @@ import '../videos/video_id.dart';
import 'channel.dart'; import 'channel.dart';
import 'channel_id.dart'; import 'channel_id.dart';
import 'channel_video.dart'; import 'channel_video.dart';
import 'channels.dart';
import 'username.dart'; import 'username.dart';
import 'video_sorting.dart'; import 'video_sorting.dart';
@ -59,7 +59,7 @@ class ChannelClient {
id.title, id.title,
[ [
for (var e in id.avatar) for (var e in id.avatar)
ChannelThumbnail(Uri.parse(e.url), e.height, e.width) Thumbnail(Uri.parse(e.url), e.height, e.width)
], ],
id.country, id.country,
id.channelLinks); id.channelLinks);
@ -82,7 +82,7 @@ class ChannelClient {
id.title, id.title,
[ [
for (var e in id.avatar) for (var e in id.avatar)
ChannelThumbnail(Uri.parse(e.url), e.height, e.width) Thumbnail(Uri.parse(e.url), e.height, e.width)
], ],
id.country, id.country,
id.channelLinks); id.channelLinks);

View File

@ -8,7 +8,6 @@ export 'channel_about.dart';
export 'channel_client.dart'; export 'channel_client.dart';
export 'channel_id.dart'; export 'channel_id.dart';
export 'channel_link.dart'; export 'channel_link.dart';
export 'channel_thumbnail.dart';
export 'channel_video.dart'; export 'channel_video.dart';
export 'username.dart'; export 'username.dart';
export 'video_sorting.dart'; export 'video_sorting.dart';

View File

@ -1,4 +1,5 @@
library youtube_explode.common; library youtube_explode.common;
export 'engagement.dart'; export 'engagement.dart';
export 'thumbnail.dart';
export 'thumbnail_set.dart'; export 'thumbnail_set.dart';

View File

@ -1,7 +1,7 @@
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
/// Represent a channel thumbnail /// Represent a channel thumbnail
class ChannelThumbnail with EquatableMixin { class Thumbnail with EquatableMixin {
/// Image url. /// Image url.
final Uri url; final Uri url;
@ -11,8 +11,8 @@ class ChannelThumbnail with EquatableMixin {
/// Image width. /// Image width.
final int width; final int width;
/// Initialize an instance of [ChannelThumbnail]. /// Initialize an instance of [Thumbnail].
ChannelThumbnail(this.url, this.height, this.width); Thumbnail(this.url, this.height, this.width);
@override @override
List<Object> get props => [url, height, width]; List<Object> get props => [url, height, width];

View File

@ -232,12 +232,13 @@ class _InitialData {
_parseRuns(renderer.title.runs), _parseRuns(renderer.title.runs),
_parseRuns(renderer.ownerText.runs), _parseRuns(renderer.ownerText.runs),
_parseRuns(renderer.descriptionSnippet?.runs), _parseRuns(renderer.descriptionSnippet?.runs),
(renderer.thumbnail.thumbnails ?? [])..sort((a ,b) => a.width.compareTo(b.width));
renderer.lengthText?.simpleText ?? '', renderer.lengthText?.simpleText ?? '',
int.parse(renderer.viewCountText?.simpleText int.parse(renderer.viewCountText?.simpleText
?.stripNonDigits() ?.stripNonDigits()
?.nullIfWhitespace ?? ?.nullIfWhitespace ??
'0')); '0'),
(renderer.thumbnail.thumbnails ?? <ThumbnailElement>[])
.map((e) => Thumbnail(Uri.parse(e.url), e.height, e.width)));
} }
if (content.radioRenderer != null) { if (content.radioRenderer != null) {
var renderer = content.radioRenderer; var renderer = content.radioRenderer;

View File

@ -1,3 +1,4 @@
import '../common/common.dart';
import '../videos/video_id.dart'; import '../videos/video_id.dart';
import 'base_search_content.dart'; import 'base_search_content.dart';
@ -21,8 +22,8 @@ class SearchVideo extends BaseSearchContent {
/// Video View Count /// Video View Count
final int videoViewCount; final int videoViewCount;
/// Video thumbnail uris /// Video thumbnail
final List<String> videoThumbnails; final List<Thumbnail> videoThumbnails;
/// Initialize a [SearchVideo] instance. /// Initialize a [SearchVideo] instance.
const SearchVideo( const SearchVideo(

View File

@ -1,6 +1,6 @@
name: youtube_explode_dart name: youtube_explode_dart
description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key. description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key.
version: 1.6.0 version: 1.6.1
homepage: https://github.com/Hexer10/youtube_explode_dart homepage: https://github.com/Hexer10/youtube_explode_dart
environment: environment: