Skip to content

Commit

Permalink
feat(lib): add missing video flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Oct 21, 2024
1 parent 6aaebe6 commit b5df65c
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
54 changes: 52 additions & 2 deletions lib/src/types/video.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
import 'dart:ui';

import 'package:json_annotation/json_annotation.dart';

import 'metadata.dart';
import 'video_assets.dart';
import 'video_source.dart';
import 'metadata.dart';

part 'video.g.dart';

/// The origin of the last update on the video's `language` attribute.
enum LanguageOrigin {
/// The language was set by the API.
@JsonValue("api")
api,

/// The language was done automatically by the API.
@JsonValue("auto")
auto
}

/// Json converter for [Locale] objects.
class _JsonLocaleConverter extends JsonConverter<Locale, String> {
const _JsonLocaleConverter();

@override
Locale fromJson(String json) {
return Locale(json);
}

@override
String toJson(Locale object) {
return object.toLanguageTag();
}
}

/// A video from api.video
@JsonSerializable()
class Video {
Expand All @@ -26,6 +55,22 @@ class Video {
/// The date and time the video was updated. Date and time are provided using ISO-8601 UTC format.
final DateTime? updatedAt;

/// The date and time the video was discarded.
final DateTime? discardedAt;

/// The date and time the video will be permanently deleted.
final DateTime? deletedAt;

/// Returns `true` for videos you discarded.
final bool? discarded;

/// Returns the language of a video in [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format.
@_JsonLocaleConverter()
final Locale? language;

/// Returns the origin of the last update on the video's `language` attribute.
final LanguageOrigin? languageOrigin;

/// One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces.
final List<String>? tags;

Expand All @@ -52,12 +97,17 @@ class Video {
final bool? mp4Support;

/// Creates a [Video].
Video(this.videoId,
const Video(this.videoId,
{this.createdAt,
this.title,
this.description,
this.publishedAt,
this.updatedAt,
this.discardedAt,
this.deletedAt,
this.discarded,
this.language,
this.languageOrigin,
this.tags,
this.metadata,
this.source,
Expand Down
34 changes: 34 additions & 0 deletions lib/src/types/video.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5df65c

Please sign in to comment.