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.
- `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`.

View File

@ -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<ChannelThumbnail> thumbnails;
final List<Thumbnail> thumbnails;
/// Channel country.
final String country;

View File

@ -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);

View File

@ -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';

View File

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

View File

@ -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<Object> get props => [url, height, width];

View File

@ -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 ?? <ThumbnailElement>[])
.map((e) => Thumbnail(Uri.parse(e.url), e.height, e.width)));
}
if (content.radioRenderer != null) {
var renderer = content.radioRenderer;

View File

@ -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<String> videoThumbnails;
/// Video thumbnail
final List<Thumbnail> videoThumbnails;
/// Initialize a [SearchVideo] instance.
const SearchVideo(

View File

@ -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: