Thumbnail for playlists
This commit is contained in:
parent
0d16e9613b
commit
6fb757e726
|
@ -1,5 +1,7 @@
|
||||||
## 1.4.0
|
## 1.4.0
|
||||||
- Add ChannelId property to Video class.
|
- Add ChannelId property to Video class.
|
||||||
|
- Implement `thumbnails` for playlists. The playlist's thumbnail is the same as the thumbnail of its first video. If the playlist is empty, then this property is `null`.
|
||||||
|
- Update for age restricted videos.
|
||||||
|
|
||||||
## 1.3.3
|
## 1.3.3
|
||||||
- Error handling when using `getStream` if the connection fails. If it fails more than 5 times on the same request the exception will be thrown anyways.
|
- Error handling when using `getStream` if the connection fails. If it fails more than 5 times on the same request the exception will be thrown anyways.
|
||||||
|
|
|
@ -21,11 +21,16 @@ class Playlist with EquatableMixin {
|
||||||
/// Playlist description.
|
/// Playlist description.
|
||||||
final String description;
|
final String description;
|
||||||
|
|
||||||
|
/// Available thumbnails for this playlist.
|
||||||
|
/// Can be null if the playlist is empty.
|
||||||
|
final ThumbnailSet thumbnails;
|
||||||
|
|
||||||
/// Engagement statistics.
|
/// Engagement statistics.
|
||||||
final Engagement engagement;
|
final Engagement engagement;
|
||||||
|
|
||||||
/// Initializes an instance of [Playlist].
|
/// Initializes an instance of [Playlist].
|
||||||
Playlist(this.id, this.title, this.author, this.description, this.engagement);
|
Playlist(this.id, this.title, this.author, this.description, this.thumbnails,
|
||||||
|
this.engagement);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'Playlist ($title)';
|
String toString() => 'Playlist ($title)';
|
||||||
|
|
|
@ -23,6 +23,7 @@ class PlaylistClient {
|
||||||
response.title,
|
response.title,
|
||||||
response.author,
|
response.author,
|
||||||
response.description ?? '',
|
response.description ?? '',
|
||||||
|
response.thumbnails,
|
||||||
Engagement(response.viewCount ?? 0, response.likeCount ?? 0,
|
Engagement(response.viewCount ?? 0, response.likeCount ?? 0,
|
||||||
response.dislikeCount ?? 0));
|
response.dislikeCount ?? 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:youtube_explode_dart/src/common/common.dart';
|
||||||
|
|
||||||
import '../../channels/channel_id.dart';
|
import '../../channels/channel_id.dart';
|
||||||
import '../../exceptions/exceptions.dart';
|
import '../../exceptions/exceptions.dart';
|
||||||
import '../../extensions/helpers_extension.dart';
|
import '../../extensions/helpers_extension.dart';
|
||||||
|
@ -7,6 +9,8 @@ import '../../retry.dart';
|
||||||
import '../youtube_http_client.dart';
|
import '../youtube_http_client.dart';
|
||||||
|
|
||||||
class PlaylistResponse {
|
class PlaylistResponse {
|
||||||
|
Iterable<_Video> _videos;
|
||||||
|
|
||||||
// Json parsed map
|
// Json parsed map
|
||||||
final Map<String, dynamic> _root;
|
final Map<String, dynamic> _root;
|
||||||
|
|
||||||
|
@ -16,13 +20,15 @@ class PlaylistResponse {
|
||||||
|
|
||||||
String get description => _root['description'];
|
String get description => _root['description'];
|
||||||
|
|
||||||
|
ThumbnailSet get thumbnails => ThumbnailSet(videos.firstOrNull.id);
|
||||||
|
|
||||||
int get viewCount => _root['views'];
|
int get viewCount => _root['views'];
|
||||||
|
|
||||||
int get likeCount => _root['likes'];
|
int get likeCount => _root['likes'];
|
||||||
|
|
||||||
int get dislikeCount => _root['dislikes'];
|
int get dislikeCount => _root['dislikes'];
|
||||||
|
|
||||||
Iterable<_Video> get videos =>
|
Iterable<_Video> get videos => _videos ??=
|
||||||
_root['video']?.map((e) => _Video(e))?.cast<_Video>() ?? const <_Video>[];
|
_root['video']?.map((e) => _Video(e))?.cast<_Video>() ?? const <_Video>[];
|
||||||
|
|
||||||
PlaylistResponse(this._root);
|
PlaylistResponse(this._root);
|
||||||
|
|
Loading…
Reference in New Issue