youtube_explode/lib/src/videos/video.dart

80 lines
1.9 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.
2021-02-27 18:58:42 +01:00
/// Note: null if the video is from a search query.
2021-03-11 14:20:10 +01:00
final ChannelId? channelId;
2020-06-30 01:00:37 +02:00
2020-06-03 23:02:21 +02:00
/// Video upload date.
2021-02-27 18:58:42 +01:00
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
2021-03-04 12:20:00 +01:00
final DateTime? uploadDate;
2020-06-03 23:02:21 +02:00
/// Video description.
final String description;
/// Duration of the video.
2021-03-11 14:20:10 +01:00
final Duration? duration;
2020-06-03 23:02:21 +02:00
/// 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;
2021-02-27 18:58:42 +01:00
/// Returns true if this is a live stream.
2021-03-04 12:20:00 +01:00
final bool? isLive;
2021-02-27 18:58:42 +01:00
/// Used internally.
2020-06-23 10:12:08 +02:00
/// Shouldn't be used in the code.
2021-03-04 12:20:00 +01:00
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,
2021-03-04 12:20:00 +01:00
Iterable<String>? keywords,
this.engagement,
2021-02-27 18:58:42 +01:00
this.isLive, // ignore: avoid_positional_boolean_parameters
[this.watchPage])
2021-03-04 12:20:00 +01:00
: keywords = UnmodifiableListView(keywords ?? []);
2020-06-03 23:02:21 +02:00
@override
String toString() => 'Video ($title)';
@override
List<Object> get props => [id];
2020-06-03 23:02:21 +02:00
}