2020-06-03 23:02:21 +02:00
|
|
|
import 'dart:collection';
|
|
|
|
|
2020-06-17 19:11:52 +02:00
|
|
|
import 'package:equatable/equatable.dart';
|
|
|
|
|
2020-06-30 01:00:37 +02:00
|
|
|
import '../channels/channel_id.dart';
|
2020-06-05 16:17:08 +02:00
|
|
|
import '../common/common.dart';
|
2020-06-21 16:23:19 +02:00
|
|
|
import '../reverse_engineering/responses/responses.dart';
|
2020-06-03 23:02:21 +02:00
|
|
|
import 'video_id.dart';
|
|
|
|
|
|
|
|
/// YouTube video metadata.
|
2020-06-17 19:11:52 +02:00
|
|
|
class Video with EquatableMixin {
|
2020-06-03 23:02:21 +02:00
|
|
|
/// Video ID.
|
|
|
|
final VideoId id;
|
|
|
|
|
|
|
|
/// Video URL.
|
|
|
|
String get url => 'https://www.youtube.com/watch?v=$id';
|
|
|
|
|
|
|
|
/// Video title.
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
/// Video author.
|
|
|
|
final String author;
|
|
|
|
|
2020-06-30 01:00:37 +02:00
|
|
|
/// Video author Id.
|
|
|
|
final ChannelId channelId;
|
|
|
|
|
2020-06-03 23:02:21 +02:00
|
|
|
/// Video upload date.
|
|
|
|
final DateTime uploadDate;
|
|
|
|
|
|
|
|
/// Video description.
|
|
|
|
final String description;
|
|
|
|
|
|
|
|
/// Duration of the video.
|
|
|
|
final Duration duration;
|
|
|
|
|
|
|
|
/// Available thumbnails for this video.
|
|
|
|
final ThumbnailSet thumbnails;
|
|
|
|
|
|
|
|
/// Search keywords used for this video.
|
|
|
|
final UnmodifiableListView<String> keywords;
|
|
|
|
|
|
|
|
/// Engagement statistics for this video.
|
|
|
|
final Engagement engagement;
|
|
|
|
|
2020-06-21 16:23:19 +02:00
|
|
|
/// Used internally.
|
2020-06-23 10:12:08 +02:00
|
|
|
/// Shouldn't be used in the code.
|
2020-06-21 16:23:19 +02:00
|
|
|
final WatchPage watchPage;
|
2020-06-17 22:14:27 +02:00
|
|
|
|
2020-07-16 19:28:49 +02:00
|
|
|
/// Returns true if the watch page is available for this video.
|
|
|
|
bool get hasWatchPage => watchPage != null;
|
|
|
|
|
2020-06-03 23:02:21 +02:00
|
|
|
/// Initializes an instance of [Video]
|
|
|
|
Video(
|
|
|
|
this.id,
|
|
|
|
this.title,
|
|
|
|
this.author,
|
2020-06-30 01:00:37 +02:00
|
|
|
this.channelId,
|
2020-06-03 23:02:21 +02:00
|
|
|
this.uploadDate,
|
|
|
|
this.description,
|
|
|
|
this.duration,
|
|
|
|
this.thumbnails,
|
|
|
|
Iterable<String> keywords,
|
2020-06-21 16:23:19 +02:00
|
|
|
this.engagement,
|
|
|
|
[this.watchPage])
|
2020-06-03 23:02:21 +02:00
|
|
|
: keywords = UnmodifiableListView(keywords);
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => 'Video ($title)';
|
2020-06-17 19:11:52 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
List<Object> get props => [id];
|
2020-06-03 23:02:21 +02:00
|
|
|
}
|