youtube_explode/lib/src/videos/video.dart

73 lines
1.6 KiB
Dart
Raw Normal View History

2020-06-03 23:02:21 +02:00
import 'dart:collection';
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';
import '../reverse_engineering/responses/responses.dart';
2020-06-03 23:02:21 +02:00
import 'video_id.dart';
/// YouTube video metadata.
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;
/// Used internally.
2020-06-23 10:12:08 +02:00
/// Shouldn't be used in the code.
final WatchPage watchPage;
2020-06-17 22:14:27 +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,
this.engagement,
[this.watchPage])
2020-06-03 23:02:21 +02:00
: keywords = UnmodifiableListView(keywords);
@override
String toString() => 'Video ($title)';
@override
List<Object> get props => [id];
2020-06-03 23:02:21 +02:00
}