import 'package:freezed_annotation/freezed_annotation.dart'; import '../channels/channel_id.dart'; import '../common/common.dart'; import '../reverse_engineering/pages/watch_page.dart'; import 'video_id.dart'; part 'video.freezed.dart'; /// YouTube video metadata. @freezed class Video with _$Video { /// 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; factory Video( /// 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. Iterable? keywords, /// 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); } /// 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 keywords, /// 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]) = _Video; const Video._(); }