diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index b4a4fa0..cf2ddd9 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,5 +1,4 @@ .gitignore -.openapi-generator-ignore README.md analysis_options.yaml doc/ChannelInfo.md @@ -7,6 +6,7 @@ doc/ExceptionError.md doc/Regions.md doc/Stream.md doc/StreamItem.md +doc/Subtitle.md doc/UnauthenticatedApi.md doc/VideoInfo.md lib/piped_api.dart @@ -25,13 +25,7 @@ lib/src/model/exception_error.dart lib/src/model/regions.dart lib/src/model/stream.dart lib/src/model/stream_item.dart +lib/src/model/subtitle.dart lib/src/model/video_info.dart lib/src/serializers.dart pubspec.yaml -test/channel_info_test.dart -test/exception_error_test.dart -test/regions_test.dart -test/stream_item_test.dart -test/stream_test.dart -test/unauthenticated_api_test.dart -test/video_info_test.dart diff --git a/README.md b/README.md index 0730021..a3914c1 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Class | Method | HTTP request | Description - [Regions](doc/Regions.md) - [Stream](doc/Stream.md) - [StreamItem](doc/StreamItem.md) + - [Subtitle](doc/Subtitle.md) - [VideoInfo](doc/VideoInfo.md) diff --git a/doc/Subtitle.md b/doc/Subtitle.md new file mode 100644 index 0000000..05714e4 --- /dev/null +++ b/doc/Subtitle.md @@ -0,0 +1,18 @@ +# piped_api.model.Subtitle + +## Load the model package +```dart +import 'package:piped_api/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**autoGenerated** | **bool** | Whether the subtitle is auto generated. | [optional] +**code** | **String** | The language code of the subtitle. | [optional] +**mimeType** | **String** | The mime type of the subtitle. | [optional] +**url** | **String** | The URL of the subtitle. | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/doc/VideoInfo.md b/doc/VideoInfo.md index 8491c25..955199f 100644 --- a/doc/VideoInfo.md +++ b/doc/VideoInfo.md @@ -9,6 +9,24 @@ import 'package:piped_api/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **audioStreams** | [**BuiltList<Stream>**](Stream.md) | | [optional] +**videoStreams** | [**BuiltList<Stream>**](Stream.md) | | [optional] +**description** | **String** | The video's description. | [optional] +**dislikes** | **int** | The number of dislikes the video has. | [optional] +**duration** | **int** | The video's duration in seconds. | [optional] +**hls** | **String** | The stream of the video in a HLS manifest. | [optional] +**lbryId** | **String** | The LBRY ID of the video. | [optional] +**likes** | **int** | The number of likes the video has. | [optional] +**livestream** | **bool** | Whether the video is a livestream. | [optional] +**proxyUrl** | **String** | The base URL of the backend instance's proxy. | [optional] +**subtitles** | [**BuiltList<Subtitle>**](Subtitle.md) | | [optional] +**dash** | **String** | The URL of the DASH manifest. | [optional] +**thumbnailUrl** | **String** | The URL of the video's thumbnail. | [optional] +**title** | **String** | The video's title. | [optional] +**uploadDate** | **String** | The date the video was uploaded. | [optional] +**uploader** | **String** | The video's uploader. | [optional] +**uploaderAvatar** | **String** | The URL of the video's uploader's avatar. | [optional] +**uploaderUrl** | **String** | The relative URL of the video's uploader. | [optional] +**uploaderVerified** | **bool** | Whether the video's uploader is verified. | [optional] **relatedStreams** | [**BuiltList<StreamItem>**](StreamItem.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/lib/piped_api.dart b/lib/piped_api.dart index dcbad6c..f34e011 100644 --- a/lib/piped_api.dart +++ b/lib/piped_api.dart @@ -16,4 +16,5 @@ export 'package:piped_api/src/model/exception_error.dart'; export 'package:piped_api/src/model/regions.dart'; export 'package:piped_api/src/model/stream.dart'; export 'package:piped_api/src/model/stream_item.dart'; +export 'package:piped_api/src/model/subtitle.dart'; export 'package:piped_api/src/model/video_info.dart'; diff --git a/lib/src/model/subtitle.dart b/lib/src/model/subtitle.dart new file mode 100644 index 0000000..c6130eb --- /dev/null +++ b/lib/src/model/subtitle.dart @@ -0,0 +1,120 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'subtitle.g.dart'; + +/// Subtitle +/// +/// Properties: +/// * [autoGenerated] - Whether the subtitle is auto generated. +/// * [code] - The language code of the subtitle. +/// * [mimeType] - The mime type of the subtitle. +/// * [url] - The URL of the subtitle. +abstract class Subtitle implements Built { + /// Whether the subtitle is auto generated. + @BuiltValueField(wireName: r'autoGenerated') + bool? get autoGenerated; + + /// The language code of the subtitle. + @BuiltValueField(wireName: r'code') + String? get code; + + /// The mime type of the subtitle. + @BuiltValueField(wireName: r'mimeType') + String? get mimeType; + + /// The URL of the subtitle. + @BuiltValueField(wireName: r'url') + String? get url; + + Subtitle._(); + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(SubtitleBuilder b) => b; + + factory Subtitle([void updates(SubtitleBuilder b)]) = _$Subtitle; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$SubtitleSerializer(); +} + +class _$SubtitleSerializer implements StructuredSerializer { + @override + final Iterable types = const [Subtitle, _$Subtitle]; + + @override + final String wireName = r'Subtitle'; + + @override + Iterable serialize(Serializers serializers, Subtitle object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + if (object.autoGenerated != null) { + result + ..add(r'autoGenerated') + ..add(serializers.serialize(object.autoGenerated, + specifiedType: const FullType(bool))); + } + if (object.code != null) { + result + ..add(r'code') + ..add(serializers.serialize(object.code, + specifiedType: const FullType(String))); + } + if (object.mimeType != null) { + result + ..add(r'mimeType') + ..add(serializers.serialize(object.mimeType, + specifiedType: const FullType(String))); + } + if (object.url != null) { + result + ..add(r'url') + ..add(serializers.serialize(object.url, + specifiedType: const FullType(String))); + } + return result; + } + + @override + Subtitle deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = SubtitleBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + + switch (key) { + case r'autoGenerated': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + result.autoGenerated = valueDes; + break; + case r'code': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.code = valueDes; + break; + case r'mimeType': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.mimeType = valueDes; + break; + case r'url': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.url = valueDes; + break; + } + } + return result.build(); + } +} + diff --git a/lib/src/model/video_info.dart b/lib/src/model/video_info.dart index 5368a47..b7fe3b7 100644 --- a/lib/src/model/video_info.dart +++ b/lib/src/model/video_info.dart @@ -5,6 +5,7 @@ import 'package:piped_api/src/model/stream_item.dart'; import 'package:built_collection/built_collection.dart'; import 'package:piped_api/src/model/stream.dart'; +import 'package:piped_api/src/model/subtitle.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; @@ -14,11 +15,99 @@ part 'video_info.g.dart'; /// /// Properties: /// * [audioStreams] +/// * [videoStreams] +/// * [description] - The video's description. +/// * [dislikes] - The number of dislikes the video has. +/// * [duration] - The video's duration in seconds. +/// * [hls] - The stream of the video in a HLS manifest. +/// * [lbryId] - The LBRY ID of the video. +/// * [likes] - The number of likes the video has. +/// * [livestream] - Whether the video is a livestream. +/// * [proxyUrl] - The base URL of the backend instance's proxy. +/// * [subtitles] +/// * [dash] - The URL of the DASH manifest. +/// * [thumbnailUrl] - The URL of the video's thumbnail. +/// * [title] - The video's title. +/// * [uploadDate] - The date the video was uploaded. +/// * [uploader] - The video's uploader. +/// * [uploaderAvatar] - The URL of the video's uploader's avatar. +/// * [uploaderUrl] - The relative URL of the video's uploader. +/// * [uploaderVerified] - Whether the video's uploader is verified. /// * [relatedStreams] abstract class VideoInfo implements Built { @BuiltValueField(wireName: r'audioStreams') BuiltList? get audioStreams; + @BuiltValueField(wireName: r'videoStreams') + BuiltList? get videoStreams; + + /// The video's description. + @BuiltValueField(wireName: r'description') + String? get description; + + /// The number of dislikes the video has. + @BuiltValueField(wireName: r'dislikes') + int? get dislikes; + + /// The video's duration in seconds. + @BuiltValueField(wireName: r'duration') + int? get duration; + + /// The stream of the video in a HLS manifest. + @BuiltValueField(wireName: r'hls') + String? get hls; + + /// The LBRY ID of the video. + @BuiltValueField(wireName: r'lbryId') + String? get lbryId; + + /// The number of likes the video has. + @BuiltValueField(wireName: r'likes') + int? get likes; + + /// Whether the video is a livestream. + @BuiltValueField(wireName: r'livestream') + bool? get livestream; + + /// The base URL of the backend instance's proxy. + @BuiltValueField(wireName: r'proxyUrl') + String? get proxyUrl; + + @BuiltValueField(wireName: r'subtitles') + BuiltList? get subtitles; + + /// The URL of the DASH manifest. + @BuiltValueField(wireName: r'dash') + String? get dash; + + /// The URL of the video's thumbnail. + @BuiltValueField(wireName: r'thumbnailUrl') + String? get thumbnailUrl; + + /// The video's title. + @BuiltValueField(wireName: r'title') + String? get title; + + /// The date the video was uploaded. + @BuiltValueField(wireName: r'uploadDate') + String? get uploadDate; + + /// The video's uploader. + @BuiltValueField(wireName: r'uploader') + String? get uploader; + + /// The URL of the video's uploader's avatar. + @BuiltValueField(wireName: r'uploaderAvatar') + String? get uploaderAvatar; + + /// The relative URL of the video's uploader. + @BuiltValueField(wireName: r'uploaderUrl') + String? get uploaderUrl; + + /// Whether the video's uploader is verified. + @BuiltValueField(wireName: r'uploaderVerified') + bool? get uploaderVerified; + @BuiltValueField(wireName: r'relatedStreams') BuiltList? get relatedStreams; @@ -50,6 +139,114 @@ class _$VideoInfoSerializer implements StructuredSerializer { ..add(serializers.serialize(object.audioStreams, specifiedType: const FullType(BuiltList, [FullType(Stream)]))); } + if (object.videoStreams != null) { + result + ..add(r'videoStreams') + ..add(serializers.serialize(object.videoStreams, + specifiedType: const FullType(BuiltList, [FullType(Stream)]))); + } + if (object.description != null) { + result + ..add(r'description') + ..add(serializers.serialize(object.description, + specifiedType: const FullType(String))); + } + if (object.dislikes != null) { + result + ..add(r'dislikes') + ..add(serializers.serialize(object.dislikes, + specifiedType: const FullType(int))); + } + if (object.duration != null) { + result + ..add(r'duration') + ..add(serializers.serialize(object.duration, + specifiedType: const FullType(int))); + } + if (object.hls != null) { + result + ..add(r'hls') + ..add(serializers.serialize(object.hls, + specifiedType: const FullType(String))); + } + if (object.lbryId != null) { + result + ..add(r'lbryId') + ..add(serializers.serialize(object.lbryId, + specifiedType: const FullType(String))); + } + if (object.likes != null) { + result + ..add(r'likes') + ..add(serializers.serialize(object.likes, + specifiedType: const FullType(int))); + } + if (object.livestream != null) { + result + ..add(r'livestream') + ..add(serializers.serialize(object.livestream, + specifiedType: const FullType(bool))); + } + if (object.proxyUrl != null) { + result + ..add(r'proxyUrl') + ..add(serializers.serialize(object.proxyUrl, + specifiedType: const FullType(String))); + } + if (object.subtitles != null) { + result + ..add(r'subtitles') + ..add(serializers.serialize(object.subtitles, + specifiedType: const FullType(BuiltList, [FullType(Subtitle)]))); + } + if (object.dash != null) { + result + ..add(r'dash') + ..add(serializers.serialize(object.dash, + specifiedType: const FullType(String))); + } + if (object.thumbnailUrl != null) { + result + ..add(r'thumbnailUrl') + ..add(serializers.serialize(object.thumbnailUrl, + specifiedType: const FullType(String))); + } + if (object.title != null) { + result + ..add(r'title') + ..add(serializers.serialize(object.title, + specifiedType: const FullType(String))); + } + if (object.uploadDate != null) { + result + ..add(r'uploadDate') + ..add(serializers.serialize(object.uploadDate, + specifiedType: const FullType(String))); + } + if (object.uploader != null) { + result + ..add(r'uploader') + ..add(serializers.serialize(object.uploader, + specifiedType: const FullType(String))); + } + if (object.uploaderAvatar != null) { + result + ..add(r'uploaderAvatar') + ..add(serializers.serialize(object.uploaderAvatar, + specifiedType: const FullType(String))); + } + if (object.uploaderUrl != null) { + result + ..add(r'uploaderUrl') + ..add(serializers.serialize(object.uploaderUrl, + specifiedType: const FullType(String))); + } + if (object.uploaderVerified != null) { + result + ..add(r'uploaderVerified') + ..add(serializers.serialize(object.uploaderVerified, + specifiedType: const FullType(bool))); + } if (object.relatedStreams != null) { result ..add(r'relatedStreams') @@ -76,6 +273,96 @@ class _$VideoInfoSerializer implements StructuredSerializer { specifiedType: const FullType(BuiltList, [FullType(Stream)])) as BuiltList; result.audioStreams.replace(valueDes); break; + case r'videoStreams': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(Stream)])) as BuiltList; + result.videoStreams.replace(valueDes); + break; + case r'description': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.description = valueDes; + break; + case r'dislikes': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + result.dislikes = valueDes; + break; + case r'duration': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + result.duration = valueDes; + break; + case r'hls': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.hls = valueDes; + break; + case r'lbryId': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.lbryId = valueDes; + break; + case r'likes': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + result.likes = valueDes; + break; + case r'livestream': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + result.livestream = valueDes; + break; + case r'proxyUrl': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.proxyUrl = valueDes; + break; + case r'subtitles': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(Subtitle)])) as BuiltList; + result.subtitles.replace(valueDes); + break; + case r'dash': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.dash = valueDes; + break; + case r'thumbnailUrl': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.thumbnailUrl = valueDes; + break; + case r'title': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.title = valueDes; + break; + case r'uploadDate': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.uploadDate = valueDes; + break; + case r'uploader': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.uploader = valueDes; + break; + case r'uploaderAvatar': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.uploaderAvatar = valueDes; + break; + case r'uploaderUrl': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + result.uploaderUrl = valueDes; + break; + case r'uploaderVerified': + final valueDes = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + result.uploaderVerified = valueDes; + break; case r'relatedStreams': final valueDes = serializers.deserialize(value, specifiedType: const FullType(BuiltList, [FullType(StreamItem)])) as BuiltList; diff --git a/lib/src/serializers.dart b/lib/src/serializers.dart index 6264f7f..dba8cc0 100644 --- a/lib/src/serializers.dart +++ b/lib/src/serializers.dart @@ -17,6 +17,7 @@ import 'package:piped_api/src/model/exception_error.dart'; import 'package:piped_api/src/model/regions.dart'; import 'package:piped_api/src/model/stream.dart'; import 'package:piped_api/src/model/stream_item.dart'; +import 'package:piped_api/src/model/subtitle.dart'; import 'package:piped_api/src/model/video_info.dart'; part 'serializers.g.dart'; @@ -27,6 +28,7 @@ part 'serializers.g.dart'; Regions, Stream, StreamItem, + Subtitle, VideoInfo, ]) Serializers serializers = (_$serializers.toBuilder() diff --git a/test/subtitle_test.dart b/test/subtitle_test.dart new file mode 100644 index 0000000..9257a1c --- /dev/null +++ b/test/subtitle_test.dart @@ -0,0 +1,35 @@ +import 'package:test/test.dart'; +import 'package:piped_api/piped_api.dart'; + +// tests for Subtitle +void main() { + final instance = SubtitleBuilder(); + // TODO add properties to the builder and call build() + + group(Subtitle, () { + // Whether the subtitle is auto generated. + // bool autoGenerated + test('to test the property `autoGenerated`', () async { + // TODO + }); + + // The language code of the subtitle. + // String code + test('to test the property `code`', () async { + // TODO + }); + + // The mime type of the subtitle. + // String mimeType + test('to test the property `mimeType`', () async { + // TODO + }); + + // The URL of the subtitle. + // String url + test('to test the property `url`', () async { + // TODO + }); + + }); +}