diff --git a/CHANGELOG.md b/CHANGELOG.md index ae434d2..7f0c34e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ - Only throw custom exceptions from the library. - `getUploadsFromPage` no longer throws. +## 1.6.1 +- Add thumbnail to `SearchVideo` thanks to @shinyford ! + ## 1.6.0 - BREAKING CHANGE: Renamed `getVideosAsync` to `getVideos`. - Implemented `getVideosFromPage` which supersedes `queryFromPage`. diff --git a/lib/src/channels/channel_about.dart b/lib/src/channels/channel_about.dart index b55929f..59c2d5e 100644 --- a/lib/src/channels/channel_about.dart +++ b/lib/src/channels/channel_about.dart @@ -1,7 +1,7 @@ import 'package:equatable/equatable.dart'; import 'channel_link.dart'; -import 'channel_thumbnail.dart'; +import '../common/thumbnail.dart'; /// YouTube channel's about page metadata. class ChannelAbout with EquatableMixin { @@ -19,7 +19,7 @@ class ChannelAbout with EquatableMixin { final String title; /// Channel thumbnails. - final List thumbnails; + final List thumbnails; /// Channel country. final String country; diff --git a/lib/src/channels/channel_client.dart b/lib/src/channels/channel_client.dart index c8106a4..01931ad 100644 --- a/lib/src/channels/channel_client.dart +++ b/lib/src/channels/channel_client.dart @@ -1,8 +1,7 @@ -import 'package:youtube_explode_dart/src/channels/channels.dart'; -import 'package:youtube_explode_dart/src/reverse_engineering/responses/channel_about_page.dart'; - +import '../common/common.dart'; import '../extensions/helpers_extension.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/responses.dart'; import '../reverse_engineering/youtube_http_client.dart'; @@ -11,6 +10,7 @@ import '../videos/video_id.dart'; import 'channel.dart'; import 'channel_id.dart'; import 'channel_video.dart'; +import 'channels.dart'; import 'username.dart'; import 'video_sorting.dart'; @@ -59,7 +59,7 @@ class ChannelClient { id.title, [ 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.channelLinks); @@ -82,7 +82,7 @@ class ChannelClient { id.title, [ 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.channelLinks); diff --git a/lib/src/channels/channels.dart b/lib/src/channels/channels.dart index cfbbce6..2640c72 100644 --- a/lib/src/channels/channels.dart +++ b/lib/src/channels/channels.dart @@ -8,7 +8,6 @@ export 'channel_about.dart'; export 'channel_client.dart'; export 'channel_id.dart'; export 'channel_link.dart'; -export 'channel_thumbnail.dart'; export 'channel_video.dart'; export 'username.dart'; export 'video_sorting.dart'; diff --git a/lib/src/common/common.dart b/lib/src/common/common.dart index 7a2a987..e3468e4 100644 --- a/lib/src/common/common.dart +++ b/lib/src/common/common.dart @@ -1,4 +1,5 @@ library youtube_explode.common; export 'engagement.dart'; +export 'thumbnail.dart'; export 'thumbnail_set.dart'; diff --git a/lib/src/channels/channel_thumbnail.dart b/lib/src/common/thumbnail.dart similarity index 62% rename from lib/src/channels/channel_thumbnail.dart rename to lib/src/common/thumbnail.dart index df55e2e..7711377 100644 --- a/lib/src/channels/channel_thumbnail.dart +++ b/lib/src/common/thumbnail.dart @@ -1,7 +1,7 @@ import 'package:equatable/equatable.dart'; /// Represent a channel thumbnail -class ChannelThumbnail with EquatableMixin { +class Thumbnail with EquatableMixin { /// Image url. final Uri url; @@ -11,8 +11,8 @@ class ChannelThumbnail with EquatableMixin { /// Image width. final int width; - /// Initialize an instance of [ChannelThumbnail]. - ChannelThumbnail(this.url, this.height, this.width); + /// Initialize an instance of [Thumbnail]. + Thumbnail(this.url, this.height, this.width); @override List get props => [url, height, width]; diff --git a/lib/src/reverse_engineering/responses/search_page.dart b/lib/src/reverse_engineering/responses/search_page.dart index 56be9c5..bb8845e 100644 --- a/lib/src/reverse_engineering/responses/search_page.dart +++ b/lib/src/reverse_engineering/responses/search_page.dart @@ -232,12 +232,13 @@ 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() ?.nullIfWhitespace ?? - '0')); + '0'), + (renderer.thumbnail.thumbnails ?? []) + .map((e) => Thumbnail(Uri.parse(e.url), e.height, e.width))); } if (content.radioRenderer != null) { var renderer = content.radioRenderer; diff --git a/lib/src/search/search_video.dart b/lib/src/search/search_video.dart index 6997718..7cd7762 100644 --- a/lib/src/search/search_video.dart +++ b/lib/src/search/search_video.dart @@ -1,3 +1,4 @@ +import '../common/common.dart'; import '../videos/video_id.dart'; import 'base_search_content.dart'; @@ -21,8 +22,8 @@ class SearchVideo extends BaseSearchContent { /// Video View Count final int videoViewCount; - /// Video thumbnail uris - final List videoThumbnails; + /// Video thumbnail + final List videoThumbnails; /// Initialize a [SearchVideo] instance. const SearchVideo( diff --git a/pubspec.yaml b/pubspec.yaml index c4ad89d..7f0cb33 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ 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. -version: 1.6.0 +version: 1.6.1 homepage: https://github.com/Hexer10/youtube_explode_dart environment: