youtube_explode/lib/src/videos/video.dart

143 lines
3.2 KiB
Dart
Raw Normal View History

import 'package:freezed_annotation/freezed_annotation.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';
2021-07-21 02:06:02 +02:00
import '../reverse_engineering/pages/watch_page.dart';
2020-06-03 23:02:21 +02:00
import 'video_id.dart';
part 'video.freezed.dart';
2020-06-03 23:02:21 +02:00
/// YouTube video metadata.
@freezed
class Video with _$Video {
2020-06-03 23:02:21 +02:00
/// Video URL.
String get url => 'https://www.youtube.com/watch?v=$id';
/// Returns true if the watch page is available for this video.
bool get hasWatchPage => watchPage != null;
2020-06-03 23:02:21 +02:00
factory Video(
2020-06-03 23:02:21 +02:00
/// Video ID.
VideoId id,
2020-06-30 01:00:37 +02:00
/// Video title.
String title,
2020-06-03 23:02:21 +02:00
/// Video author.
String author,
2021-03-24 06:17:49 +01:00
/// Video author Id.
ChannelId channelId,
2020-06-03 23:02:21 +02:00
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
DateTime? uploadDate,
2020-06-03 23:02:21 +02:00
/// Video publish date.
DateTime? publishDate,
2020-06-03 23:02:21 +02:00
/// Video description.
String description,
2020-06-03 23:02:21 +02:00
/// Duration of the video.
Duration? duration,
2020-06-03 23:02:21 +02:00
/// Available thumbnails for this video.
ThumbnailSet thumbnails,
2021-02-27 18:58:42 +01:00
/// Search keywords used for this video.
Iterable<String>? keywords,
2020-06-17 22:14:27 +02:00
/// Engagement statistics for this video.
Engagement engagement,
/// Returns true if this is a live stream.
//ignore: avoid_positional_boolean_parameters
bool isLive,
[
/// Used internally.
/// Shouldn't be used in the code.
@internal WatchPage? watchPage]) {
return Video._internal(
/// Video ID.
id,
/// Video title.
title,
/// Video author.
author,
/// Video author Id.
channelId,
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
uploadDate,
/// Video publish date.
publishDate,
description,
duration,
thumbnails,
UnmodifiableListView(keywords ?? const Iterable.empty()),
engagement,
isLive,
watchPage);
}
2020-06-03 23:02:21 +02:00
/// Initializes an instance of [Video]
const factory Video._internal(
/// Video ID.
VideoId id,
/// Video title.
String title,
/// Video author.
String author,
/// Video author Id.
ChannelId channelId,
/// Video upload date.
/// Note: For search queries it is calculated with:
/// DateTime.now() - how much time is was published.
DateTime? uploadDate,
/// Video publish date.
DateTime? publishDate,
/// Video description.
String description,
/// Duration of the video.
Duration? duration,
/// Available thumbnails for this video.
ThumbnailSet thumbnails,
/// Search keywords used for this video.
UnmodifiableListView<String> keywords,
/// Engagement statistics for this video.
Engagement engagement,
/// Returns true if this is a live stream.
//ignore: avoid_positional_boolean_parameters
bool isLive,
[
2020-06-03 23:02:21 +02:00
/// Used internally.
/// Shouldn't be used in the code.
@internal WatchPage? watchPage]) = _Video;
const Video._();
2020-06-03 23:02:21 +02:00
}