Initial commit.

This commit is contained in:
FireMasterK 2022-02-06 12:22:59 +00:00
commit d0203d7c63
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
39 changed files with 2880 additions and 0 deletions

19
lib/piped_api.dart Normal file
View file

@ -0,0 +1,19 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
export 'package:piped_api/src/api.dart';
export 'package:piped_api/src/auth/api_key_auth.dart';
export 'package:piped_api/src/auth/basic_auth.dart';
export 'package:piped_api/src/auth/oauth.dart';
export 'package:piped_api/src/serializers.dart';
export 'package:piped_api/src/model/date.dart';
export 'package:piped_api/src/api/unauthenticated_api.dart';
export 'package:piped_api/src/model/channel_info.dart';
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/video_info.dart';

73
lib/src/api.dart Normal file
View file

@ -0,0 +1,73 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:dio/dio.dart';
import 'package:built_value/serializer.dart';
import 'package:piped_api/src/serializers.dart';
import 'package:piped_api/src/auth/api_key_auth.dart';
import 'package:piped_api/src/auth/basic_auth.dart';
import 'package:piped_api/src/auth/bearer_auth.dart';
import 'package:piped_api/src/auth/oauth.dart';
import 'package:piped_api/src/api/unauthenticated_api.dart';
class PipedApi {
static const String basePath = r'https://pipedapi.kavin.rocks';
final Dio dio;
final Serializers serializers;
PipedApi({
Dio? dio,
Serializers? serializers,
String? basePathOverride,
List<Interceptor>? interceptors,
}) : this.serializers = serializers ?? standardSerializers,
this.dio = dio ??
Dio(BaseOptions(
baseUrl: basePathOverride ?? basePath,
connectTimeout: 5000,
receiveTimeout: 3000,
)) {
if (interceptors == null) {
this.dio.interceptors.addAll([
OAuthInterceptor(),
BasicAuthInterceptor(),
BearerAuthInterceptor(),
ApiKeyAuthInterceptor(),
]);
} else {
this.dio.interceptors.addAll(interceptors);
}
}
void setOAuthToken(String name, String token) {
if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) {
(this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) as OAuthInterceptor).tokens[name] = token;
}
}
void setBearerAuth(String name, String token) {
if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) {
(this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) as BearerAuthInterceptor).tokens[name] = token;
}
}
void setBasicAuth(String name, String username, String password) {
if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) {
(this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
}
}
void setApiKey(String name, String apiKey) {
if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) {
(this.dio.interceptors.firstWhere((element) => element is ApiKeyAuthInterceptor) as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
}
}
/// Get UnauthenticatedApi instance, base route and serializer can be overridden by a given but be careful,
/// by doing that all interceptors will not be executed
UnauthenticatedApi getUnauthenticatedApi() {
return UnauthenticatedApi(dio, serializers);
}
}

View file

@ -0,0 +1,401 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'dart:async';
import 'package:built_value/serializer.dart';
import 'package:dio/dio.dart';
import 'package:built_collection/built_collection.dart';
import 'package:piped_api/src/api_util.dart';
import 'package:piped_api/src/model/channel_info.dart';
import 'package:piped_api/src/model/exception_error.dart';
import 'package:piped_api/src/model/regions.dart';
import 'package:piped_api/src/model/stream_item.dart';
import 'package:piped_api/src/model/video_info.dart';
class UnauthenticatedApi {
final Dio _dio;
final Serializers _serializers;
const UnauthenticatedApi(this._dio, this._serializers);
/// Gets Channel Information
/// Gets all available Channel information about a channel.
///
/// Parameters:
/// * [channelId] - The channel ID of the YouTube channel you want to get information about.
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [ChannelInfo] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<ChannelInfo>> channelInfoId({
required String channelId,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/channel/{channelId}'.replaceAll('{' r'channelId' '}', channelId.toString());
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_path,
options: _options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
ChannelInfo _responseData;
try {
const _responseType = FullType(ChannelInfo);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as ChannelInfo;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<ChannelInfo>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// Gets Channel Information
/// Gets all available Channel information about a channel.
///
/// Parameters:
/// * [name] - The name of the YouTube channel you want to get information about.
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [ChannelInfo] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<ChannelInfo>> channelInfoName({
required String name,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/c/{name}'.replaceAll('{' r'name' '}', name.toString());
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_path,
options: _options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
ChannelInfo _responseData;
try {
const _responseType = FullType(ChannelInfo);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as ChannelInfo;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<ChannelInfo>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// Gets Channel Information
/// Gets all available Channel information about a channel.
///
/// Parameters:
/// * [username] - The username of the YouTube channel you want to get information about.
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [ChannelInfo] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<ChannelInfo>> channelInfoUsername({
required String username,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/user/{username}'.replaceAll('{' r'username' '}', username.toString());
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_path,
options: _options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
ChannelInfo _responseData;
try {
const _responseType = FullType(ChannelInfo);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as ChannelInfo;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<ChannelInfo>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// Gets Video Information
/// Gets all available Stream information about a video.
///
/// Parameters:
/// * [videoId] - The video ID of the YouTube video you want to get information about.
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [VideoInfo] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<VideoInfo>> streamInfo({
required String videoId,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/streams/{videoId}'.replaceAll('{' r'videoId' '}', videoId.toString());
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _response = await _dio.request<Object>(
_path,
options: _options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
VideoInfo _responseData;
try {
const _responseType = FullType(VideoInfo);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as VideoInfo;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<VideoInfo>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
/// Gets all Trending Videos
/// Gets all Trending Videos in the requested country.
///
/// Parameters:
/// * [region] - The Region to get trending videos from.
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
/// * [headers] - Can be used to add additional headers to the request
/// * [extras] - Can be used to add flags to the request
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
///
/// Returns a [Future] containing a [Response] with a [BuiltList<StreamItem>] as data
/// Throws [DioError] if API call or serialization fails
Future<Response<BuiltList<StreamItem>>> trending({
required Regions region,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/trending';
final _options = Options(
method: r'GET',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[],
...?extra,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
r'region': encodeQueryParameter(_serializers, region, const FullType(Regions)),
};
final _response = await _dio.request<Object>(
_path,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
BuiltList<StreamItem> _responseData;
try {
const _responseType = FullType(BuiltList, [FullType(StreamItem)]);
_responseData = _serializers.deserialize(
_response.data!,
specifiedType: _responseType,
) as BuiltList<StreamItem>;
} catch (error, stackTrace) {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.other,
error: error,
)..stackTrace = stackTrace;
}
return Response<BuiltList<StreamItem>>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}
}

78
lib/src/api_util.dart Normal file
View file

@ -0,0 +1,78 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'dart:convert';
import 'dart:typed_data';
import 'package:built_collection/built_collection.dart';
import 'package:built_value/serializer.dart';
import 'package:dio/dio.dart';
import 'package:dio/src/parameter.dart';
/// Format the given form parameter object into something that Dio can handle.
/// Returns primitive or String.
/// Returns List/Map if the value is BuildList/BuiltMap.
dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) {
if (value == null) {
return '';
}
if (value is String || value is num || value is bool) {
return value;
}
final serialized = serializers.serialize(
value as Object,
specifiedType: type,
);
if (serialized is String) {
return serialized;
}
if (value is BuiltList || value is BuiltSet || value is BuiltMap) {
return serialized;
}
return json.encode(serialized);
}
dynamic encodeQueryParameter(
Serializers serializers,
dynamic value,
FullType type,
) {
if (value == null) {
return '';
}
if (value is String || value is num || value is bool) {
return value;
}
if (value is Uint8List) {
// Currently not sure how to serialize this
return value;
}
final serialized = serializers.serialize(
value as Object,
specifiedType: type,
);
if (serialized == null) {
return '';
}
if (serialized is String) {
return serialized;
}
return serialized;
}
ListParam<T> encodeCollectionQueryParameter<T>(
Serializers serializers,
dynamic value,
FullType type, {
ListFormat format = ListFormat.multi,
}) {
final serialized = serializers.serialize(
value as Object,
specifiedType: type,
);
if (value is BuiltList<T> || value is BuiltSet<T>) {
return ListParam(List.of((serialized as Iterable<Object?>).cast()), format);
}
throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter');
}

View file

@ -0,0 +1,30 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:dio/dio.dart';
import 'package:piped_api/src/auth/auth.dart';
class ApiKeyAuthInterceptor extends AuthInterceptor {
final Map<String, String> apiKeys = {};
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'apiKey');
for (final info in authInfo) {
final authName = info['name'] as String;
final authKeyName = info['keyName'] as String;
final authWhere = info['where'] as String;
final apiKey = apiKeys[authName];
if (apiKey != null) {
if (authWhere == 'query') {
options.queryParameters[authKeyName] = apiKey;
} else {
options.headers[authKeyName] = apiKey;
}
}
}
super.onRequest(options, handler);
}
}

18
lib/src/auth/auth.dart Normal file
View file

@ -0,0 +1,18 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:dio/dio.dart';
abstract class AuthInterceptor extends Interceptor {
/// Get auth information on given route for the given type.
/// Can return an empty list if type is not present on auth data or
/// if route doesn't need authentication.
List<Map<String, String>> getAuthInfo(RequestOptions route, bool Function(Map<String, String> secure) handles) {
if (route.extra.containsKey('secure')) {
final auth = route.extra['secure'] as List<Map<String, String>>;
return auth.where((secure) => handles(secure)).toList();
}
return [];
}
}

View file

@ -0,0 +1,37 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:piped_api/src/auth/auth.dart';
class BasicAuthInfo {
final String username;
final String password;
const BasicAuthInfo(this.username, this.password);
}
class BasicAuthInterceptor extends AuthInterceptor {
final Map<String, BasicAuthInfo> authInfo = {};
@override
void onRequest(
RequestOptions options,
RequestInterceptorHandler handler,
) {
final metadataAuthInfo = getAuthInfo(options, (secure) => (secure['type'] == 'http' && secure['scheme'] == 'basic') || secure['type'] == 'basic');
for (final info in metadataAuthInfo) {
final authName = info['name'] as String;
final basicAuthInfo = authInfo[authName];
if (basicAuthInfo != null) {
final basicAuth = 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}';
options.headers['Authorization'] = basicAuth;
break;
}
}
super.onRequest(options, handler);
}
}

View file

@ -0,0 +1,26 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:dio/dio.dart';
import 'package:piped_api/src/auth/auth.dart';
class BearerAuthInterceptor extends AuthInterceptor {
final Map<String, String> tokens = {};
@override
void onRequest(
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
options.headers['Authorization'] = 'Bearer ${token}';
break;
}
}
super.onRequest(options, handler);
}
}

26
lib/src/auth/oauth.dart Normal file
View file

@ -0,0 +1,26 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:dio/dio.dart';
import 'package:piped_api/src/auth/auth.dart';
class OAuthInterceptor extends AuthInterceptor {
final Map<String, String> tokens = {};
@override
void onRequest(
RequestOptions options,
RequestInterceptorHandler handler,
) {
final authInfo = getAuthInfo(options, (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2');
for (final info in authInfo) {
final token = tokens[info['name']];
if (token != null) {
options.headers['Authorization'] = 'Bearer ${token}';
break;
}
}
super.onRequest(options, handler);
}
}

View file

@ -0,0 +1,31 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:built_collection/built_collection.dart';
import 'package:built_value/serializer.dart';
import 'package:piped_api/src/model/date.dart';
class DateSerializer implements PrimitiveSerializer<Date> {
const DateSerializer();
@override
Iterable<Type> get types => BuiltList.of([Date]);
@override
String get wireName => 'Date';
@override
Date deserialize(Serializers serializers, Object serialized,
{FullType specifiedType = FullType.unspecified}) {
final parsed = DateTime.parse(serialized as String);
return Date(parsed.year, parsed.month, parsed.day);
}
@override
Object serialize(Serializers serializers, Date date,
{FullType specifiedType = FullType.unspecified}) {
return date.toString();
}
}

View file

@ -0,0 +1,201 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:piped_api/src/model/stream_item.dart';
import 'package:built_collection/built_collection.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'channel_info.g.dart';
/// ChannelInfo
///
/// Properties:
/// * [avatarUrl] - The URL of the channel's avatar.
/// * [bannerUrl] - The URL of the channel's banner.
/// * [description] - The channel's description.
/// * [id] - The ID of the channel.
/// * [name] - The name of the channel.
/// * [nextpage] - The parameter used to get the next page of related videos.
/// * [relatedStreams]
/// * [subscriberCount] - The number of subscribers the channel has.
/// * [verified] - Whether the channel is verified.
abstract class ChannelInfo implements Built<ChannelInfo, ChannelInfoBuilder> {
/// The URL of the channel's avatar.
@BuiltValueField(wireName: r'avatarUrl')
String? get avatarUrl;
/// The URL of the channel's banner.
@BuiltValueField(wireName: r'bannerUrl')
String? get bannerUrl;
/// The channel's description.
@BuiltValueField(wireName: r'description')
String? get description;
/// The ID of the channel.
@BuiltValueField(wireName: r'id')
String? get id;
/// The name of the channel.
@BuiltValueField(wireName: r'name')
String? get name;
/// The parameter used to get the next page of related videos.
@BuiltValueField(wireName: r'nextpage')
String? get nextpage;
@BuiltValueField(wireName: r'relatedStreams')
BuiltList<StreamItem>? get relatedStreams;
/// The number of subscribers the channel has.
@BuiltValueField(wireName: r'subscriberCount')
int? get subscriberCount;
/// Whether the channel is verified.
@BuiltValueField(wireName: r'verified')
bool? get verified;
ChannelInfo._();
@BuiltValueHook(initializeBuilder: true)
static void _defaults(ChannelInfoBuilder b) => b;
factory ChannelInfo([void updates(ChannelInfoBuilder b)]) = _$ChannelInfo;
@BuiltValueSerializer(custom: true)
static Serializer<ChannelInfo> get serializer => _$ChannelInfoSerializer();
}
class _$ChannelInfoSerializer implements StructuredSerializer<ChannelInfo> {
@override
final Iterable<Type> types = const [ChannelInfo, _$ChannelInfo];
@override
final String wireName = r'ChannelInfo';
@override
Iterable<Object?> serialize(Serializers serializers, ChannelInfo object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
if (object.avatarUrl != null) {
result
..add(r'avatarUrl')
..add(serializers.serialize(object.avatarUrl,
specifiedType: const FullType(String)));
}
if (object.bannerUrl != null) {
result
..add(r'bannerUrl')
..add(serializers.serialize(object.bannerUrl,
specifiedType: const FullType(String)));
}
if (object.description != null) {
result
..add(r'description')
..add(serializers.serialize(object.description,
specifiedType: const FullType(String)));
}
if (object.id != null) {
result
..add(r'id')
..add(serializers.serialize(object.id,
specifiedType: const FullType(String)));
}
if (object.name != null) {
result
..add(r'name')
..add(serializers.serialize(object.name,
specifiedType: const FullType(String)));
}
if (object.nextpage != null) {
result
..add(r'nextpage')
..add(serializers.serialize(object.nextpage,
specifiedType: const FullType(String)));
}
if (object.relatedStreams != null) {
result
..add(r'relatedStreams')
..add(serializers.serialize(object.relatedStreams,
specifiedType: const FullType(BuiltList, [FullType(StreamItem)])));
}
if (object.subscriberCount != null) {
result
..add(r'subscriberCount')
..add(serializers.serialize(object.subscriberCount,
specifiedType: const FullType(int)));
}
if (object.verified != null) {
result
..add(r'verified')
..add(serializers.serialize(object.verified,
specifiedType: const FullType(bool)));
}
return result;
}
@override
ChannelInfo deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = ChannelInfoBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case r'avatarUrl':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.avatarUrl = valueDes;
break;
case r'bannerUrl':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.bannerUrl = valueDes;
break;
case r'description':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.description = valueDes;
break;
case r'id':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.id = valueDes;
break;
case r'name':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.name = valueDes;
break;
case r'nextpage':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.nextpage = valueDes;
break;
case r'relatedStreams':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(BuiltList, [FullType(StreamItem)])) as BuiltList<StreamItem>;
result.relatedStreams.replace(valueDes);
break;
case r'subscriberCount':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.subscriberCount = valueDes;
break;
case r'verified':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
result.verified = valueDes;
break;
}
}
return result.build();
}
}

70
lib/src/model/date.dart Normal file
View file

@ -0,0 +1,70 @@
/// A gregorian calendar date generated by
/// OpenAPI generator to differentiate
/// between [DateTime] and [Date] formats.
class Date implements Comparable<Date> {
final int year;
/// January is 1.
final int month;
/// First day is 1.
final int day;
Date(this.year, this.month, this.day);
/// The current date
static Date now({bool utc = false}) {
var now = DateTime.now();
if (utc) {
now = now.toUtc();
}
return now.toDate();
}
/// Convert to a [DateTime].
DateTime toDateTime({bool utc = false}) {
if (utc) {
return DateTime.utc(year, month, day);
} else {
return DateTime(year, month, day);
}
}
@override
int compareTo(Date other) {
int d = year.compareTo(other.year);
if (d != 0) {
return d;
}
d = month.compareTo(other.month);
if (d != 0) {
return d;
}
return day.compareTo(other.day);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Date &&
runtimeType == other.runtimeType &&
year == other.year &&
month == other.month &&
day == other.day;
@override
int get hashCode => year.hashCode ^ month.hashCode ^ day.hashCode;
@override
String toString() {
final yyyy = year.toString();
final mm = month.toString().padLeft(2, '0');
final dd = day.toString().padLeft(2, '0');
return '$yyyy-$mm-$dd';
}
}
extension DateTimeToDate on DateTime {
Date toDate() => Date(year, month, day);
}

View file

@ -0,0 +1,84 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'exception_error.g.dart';
/// When a server-side exception takes place.
///
/// Properties:
/// * [error] - The stacktrace provided by the server.
/// * [message] - The error message from the stacktrace.
abstract class ExceptionError implements Built<ExceptionError, ExceptionErrorBuilder> {
/// The stacktrace provided by the server.
@BuiltValueField(wireName: r'error')
String get error;
/// The error message from the stacktrace.
@BuiltValueField(wireName: r'message')
String get message;
ExceptionError._();
@BuiltValueHook(initializeBuilder: true)
static void _defaults(ExceptionErrorBuilder b) => b;
factory ExceptionError([void updates(ExceptionErrorBuilder b)]) = _$ExceptionError;
@BuiltValueSerializer(custom: true)
static Serializer<ExceptionError> get serializer => _$ExceptionErrorSerializer();
}
class _$ExceptionErrorSerializer implements StructuredSerializer<ExceptionError> {
@override
final Iterable<Type> types = const [ExceptionError, _$ExceptionError];
@override
final String wireName = r'ExceptionError';
@override
Iterable<Object?> serialize(Serializers serializers, ExceptionError object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
result
..add(r'error')
..add(serializers.serialize(object.error,
specifiedType: const FullType(String)));
result
..add(r'message')
..add(serializers.serialize(object.message,
specifiedType: const FullType(String)));
return result;
}
@override
ExceptionError deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = ExceptionErrorBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case r'error':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.error = valueDes;
break;
case r'message':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.message = valueDes;
break;
}
}
return result.build();
}
}

243
lib/src/model/regions.dart Normal file
View file

@ -0,0 +1,243 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:built_collection/built_collection.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'regions.g.dart';
class Regions extends EnumClass {
@BuiltValueEnumConst(wireName: r'DZ')
static const Regions DZ = _$DZ;
@BuiltValueEnumConst(wireName: r'AR')
static const Regions AR = _$AR;
@BuiltValueEnumConst(wireName: r'AU')
static const Regions AU = _$AU;
@BuiltValueEnumConst(wireName: r'AT')
static const Regions AT = _$AT;
@BuiltValueEnumConst(wireName: r'AZ')
static const Regions AZ = _$AZ;
@BuiltValueEnumConst(wireName: r'BH')
static const Regions BH = _$BH;
@BuiltValueEnumConst(wireName: r'BD')
static const Regions BD = _$BD;
@BuiltValueEnumConst(wireName: r'BY')
static const Regions BY = _$BY;
@BuiltValueEnumConst(wireName: r'BE')
static const Regions BE = _$BE;
@BuiltValueEnumConst(wireName: r'BO')
static const Regions BO = _$BO;
@BuiltValueEnumConst(wireName: r'BA')
static const Regions BA = _$BA;
@BuiltValueEnumConst(wireName: r'BR')
static const Regions BR = _$BR;
@BuiltValueEnumConst(wireName: r'BG')
static const Regions BG = _$BG;
@BuiltValueEnumConst(wireName: r'CA')
static const Regions CA = _$CA;
@BuiltValueEnumConst(wireName: r'CL')
static const Regions CL = _$CL;
@BuiltValueEnumConst(wireName: r'CO')
static const Regions CO = _$CO;
@BuiltValueEnumConst(wireName: r'CR')
static const Regions CR = _$CR;
@BuiltValueEnumConst(wireName: r'HR')
static const Regions HR = _$HR;
@BuiltValueEnumConst(wireName: r'CY')
static const Regions CY = _$CY;
@BuiltValueEnumConst(wireName: r'CZ')
static const Regions CZ = _$CZ;
@BuiltValueEnumConst(wireName: r'DK')
static const Regions DK = _$DK;
@BuiltValueEnumConst(wireName: r'DO')
static const Regions DO = _$DO;
@BuiltValueEnumConst(wireName: r'EC')
static const Regions EC = _$EC;
@BuiltValueEnumConst(wireName: r'EG')
static const Regions EG = _$EG;
@BuiltValueEnumConst(wireName: r'SV')
static const Regions SV = _$SV;
@BuiltValueEnumConst(wireName: r'EE')
static const Regions EE = _$EE;
@BuiltValueEnumConst(wireName: r'FI')
static const Regions FI = _$FI;
@BuiltValueEnumConst(wireName: r'FR')
static const Regions FR = _$FR;
@BuiltValueEnumConst(wireName: r'GE')
static const Regions GE = _$GE;
@BuiltValueEnumConst(wireName: r'DE')
static const Regions DE = _$DE;
@BuiltValueEnumConst(wireName: r'GH')
static const Regions GH = _$GH;
@BuiltValueEnumConst(wireName: r'GR')
static const Regions GR = _$GR;
@BuiltValueEnumConst(wireName: r'GT')
static const Regions GT = _$GT;
@BuiltValueEnumConst(wireName: r'HN')
static const Regions HN = _$HN;
@BuiltValueEnumConst(wireName: r'HK')
static const Regions HK = _$HK;
@BuiltValueEnumConst(wireName: r'HU')
static const Regions HU = _$HU;
@BuiltValueEnumConst(wireName: r'IS')
static const Regions IS = _$IS;
@BuiltValueEnumConst(wireName: r'IN')
static const Regions IN = _$IN;
@BuiltValueEnumConst(wireName: r'ID')
static const Regions ID = _$ID;
@BuiltValueEnumConst(wireName: r'IQ')
static const Regions IQ = _$IQ;
@BuiltValueEnumConst(wireName: r'IE')
static const Regions IE = _$IE;
@BuiltValueEnumConst(wireName: r'IL')
static const Regions IL = _$IL;
@BuiltValueEnumConst(wireName: r'IT')
static const Regions IT = _$IT;
@BuiltValueEnumConst(wireName: r'JM')
static const Regions JM = _$JM;
@BuiltValueEnumConst(wireName: r'JP')
static const Regions JP = _$JP;
@BuiltValueEnumConst(wireName: r'JO')
static const Regions JO = _$JO;
@BuiltValueEnumConst(wireName: r'KZ')
static const Regions KZ = _$KZ;
@BuiltValueEnumConst(wireName: r'KE')
static const Regions KE = _$KE;
@BuiltValueEnumConst(wireName: r'KW')
static const Regions KW = _$KW;
@BuiltValueEnumConst(wireName: r'LV')
static const Regions LV = _$LV;
@BuiltValueEnumConst(wireName: r'LB')
static const Regions LB = _$LB;
@BuiltValueEnumConst(wireName: r'LY')
static const Regions LY = _$LY;
@BuiltValueEnumConst(wireName: r'LI')
static const Regions LI = _$LI;
@BuiltValueEnumConst(wireName: r'LT')
static const Regions LT = _$LT;
@BuiltValueEnumConst(wireName: r'LU')
static const Regions LU = _$LU;
@BuiltValueEnumConst(wireName: r'MY')
static const Regions MY = _$MY;
@BuiltValueEnumConst(wireName: r'MT')
static const Regions MT = _$MT;
@BuiltValueEnumConst(wireName: r'MX')
static const Regions MX = _$MX;
@BuiltValueEnumConst(wireName: r'ME')
static const Regions ME = _$ME;
@BuiltValueEnumConst(wireName: r'MA')
static const Regions MA = _$MA;
@BuiltValueEnumConst(wireName: r'NP')
static const Regions NP = _$NP;
@BuiltValueEnumConst(wireName: r'NL')
static const Regions NL = _$NL;
@BuiltValueEnumConst(wireName: r'NZ')
static const Regions NZ = _$NZ;
@BuiltValueEnumConst(wireName: r'NI')
static const Regions NI = _$NI;
@BuiltValueEnumConst(wireName: r'NG')
static const Regions NG = _$NG;
@BuiltValueEnumConst(wireName: r'MK')
static const Regions MK = _$MK;
@BuiltValueEnumConst(wireName: r'NO')
static const Regions NO = _$NO;
@BuiltValueEnumConst(wireName: r'OM')
static const Regions OM = _$OM;
@BuiltValueEnumConst(wireName: r'PK')
static const Regions PK = _$PK;
@BuiltValueEnumConst(wireName: r'PA')
static const Regions PA = _$PA;
@BuiltValueEnumConst(wireName: r'PG')
static const Regions PG = _$PG;
@BuiltValueEnumConst(wireName: r'PY')
static const Regions PY = _$PY;
@BuiltValueEnumConst(wireName: r'PE')
static const Regions PE = _$PE;
@BuiltValueEnumConst(wireName: r'PH')
static const Regions PH = _$PH;
@BuiltValueEnumConst(wireName: r'PL')
static const Regions PL = _$PL;
@BuiltValueEnumConst(wireName: r'PT')
static const Regions PT = _$PT;
@BuiltValueEnumConst(wireName: r'PR')
static const Regions PR = _$PR;
@BuiltValueEnumConst(wireName: r'QA')
static const Regions QA = _$QA;
@BuiltValueEnumConst(wireName: r'RO')
static const Regions RO = _$RO;
@BuiltValueEnumConst(wireName: r'RU')
static const Regions RU = _$RU;
@BuiltValueEnumConst(wireName: r'SA')
static const Regions SA = _$SA;
@BuiltValueEnumConst(wireName: r'SN')
static const Regions SN = _$SN;
@BuiltValueEnumConst(wireName: r'RS')
static const Regions RS = _$RS;
@BuiltValueEnumConst(wireName: r'SG')
static const Regions SG = _$SG;
@BuiltValueEnumConst(wireName: r'SK')
static const Regions SK = _$SK;
@BuiltValueEnumConst(wireName: r'SI')
static const Regions SI = _$SI;
@BuiltValueEnumConst(wireName: r'ZA')
static const Regions ZA = _$ZA;
@BuiltValueEnumConst(wireName: r'KR')
static const Regions KR = _$KR;
@BuiltValueEnumConst(wireName: r'ES')
static const Regions ES = _$ES;
@BuiltValueEnumConst(wireName: r'LK')
static const Regions LK = _$LK;
@BuiltValueEnumConst(wireName: r'SE')
static const Regions SE = _$SE;
@BuiltValueEnumConst(wireName: r'CH')
static const Regions CH = _$CH;
@BuiltValueEnumConst(wireName: r'TW')
static const Regions TW = _$TW;
@BuiltValueEnumConst(wireName: r'TZ')
static const Regions TZ = _$TZ;
@BuiltValueEnumConst(wireName: r'TH')
static const Regions TH = _$TH;
@BuiltValueEnumConst(wireName: r'TN')
static const Regions TN = _$TN;
@BuiltValueEnumConst(wireName: r'TR')
static const Regions TR = _$TR;
@BuiltValueEnumConst(wireName: r'UG')
static const Regions UG = _$UG;
@BuiltValueEnumConst(wireName: r'UA')
static const Regions UA = _$UA;
@BuiltValueEnumConst(wireName: r'AE')
static const Regions AE = _$AE;
@BuiltValueEnumConst(wireName: r'GB')
static const Regions GB = _$GB;
@BuiltValueEnumConst(wireName: r'US')
static const Regions US = _$US;
@BuiltValueEnumConst(wireName: r'UY')
static const Regions UY = _$UY;
@BuiltValueEnumConst(wireName: r'VE')
static const Regions VE = _$VE;
@BuiltValueEnumConst(wireName: r'VN')
static const Regions VN = _$VN;
@BuiltValueEnumConst(wireName: r'YE')
static const Regions YE = _$YE;
@BuiltValueEnumConst(wireName: r'ZW')
static const Regions ZW = _$ZW;
static Serializer<Regions> get serializer => _$regionsSerializer;
const Regions._(String name): super(name);
static BuiltSet<Regions> get values => _$values;
static Regions valueOf(String name) => _$valueOf(name);
}
/// Optionally, enum_class can generate a mixin to go with your enum for use
/// with Angular. It exposes your enum constants as getters. So, if you mix it
/// in to your Dart component class, the values become available to the
/// corresponding Angular template.
///
/// Trigger mixin generation by writing a line like this one next to your enum.
abstract class RegionsMixin = Object with _$RegionsMixin;

299
lib/src/model/stream.dart Normal file
View file

@ -0,0 +1,299 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:built_collection/built_collection.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'stream.g.dart';
/// Stream
///
/// Properties:
/// * [url] - The URL of the stream.
/// * [format] - The format of the stream.
/// * [quality] - The quality of the stream.
/// * [mimeType] - The mime type of the stream.
/// * [codec] - The codec of the stream.
/// * [videoOnly]
/// * [bitrate]
/// * [initStart]
/// * [initEnd]
/// * [indexStart]
/// * [indexEnd]
/// * [width]
/// * [height]
/// * [fps]
abstract class Stream implements Built<Stream, StreamBuilder> {
/// The URL of the stream.
@BuiltValueField(wireName: r'url')
String? get url;
/// The format of the stream.
@BuiltValueField(wireName: r'format')
StreamFormatEnum? get format;
// enum formatEnum { MPEG_4, v3GPP, WEBM, M4A, WEBMA_OPUS, };
/// The quality of the stream.
@BuiltValueField(wireName: r'quality')
String? get quality;
/// The mime type of the stream.
@BuiltValueField(wireName: r'mimeType')
String? get mimeType;
/// The codec of the stream.
@BuiltValueField(wireName: r'codec')
String? get codec;
@BuiltValueField(wireName: r'videoOnly')
bool? get videoOnly;
@BuiltValueField(wireName: r'bitrate')
int? get bitrate;
@BuiltValueField(wireName: r'initStart')
int? get initStart;
@BuiltValueField(wireName: r'initEnd')
int? get initEnd;
@BuiltValueField(wireName: r'indexStart')
int? get indexStart;
@BuiltValueField(wireName: r'indexEnd')
int? get indexEnd;
@BuiltValueField(wireName: r'width')
int? get width;
@BuiltValueField(wireName: r'height')
int? get height;
@BuiltValueField(wireName: r'fps')
int? get fps;
Stream._();
@BuiltValueHook(initializeBuilder: true)
static void _defaults(StreamBuilder b) => b;
factory Stream([void updates(StreamBuilder b)]) = _$Stream;
@BuiltValueSerializer(custom: true)
static Serializer<Stream> get serializer => _$StreamSerializer();
}
class _$StreamSerializer implements StructuredSerializer<Stream> {
@override
final Iterable<Type> types = const [Stream, _$Stream];
@override
final String wireName = r'Stream';
@override
Iterable<Object?> serialize(Serializers serializers, Stream object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
if (object.url != null) {
result
..add(r'url')
..add(serializers.serialize(object.url,
specifiedType: const FullType(String)));
}
if (object.format != null) {
result
..add(r'format')
..add(serializers.serialize(object.format,
specifiedType: const FullType(StreamFormatEnum)));
}
if (object.quality != null) {
result
..add(r'quality')
..add(serializers.serialize(object.quality,
specifiedType: const FullType(String)));
}
if (object.mimeType != null) {
result
..add(r'mimeType')
..add(serializers.serialize(object.mimeType,
specifiedType: const FullType(String)));
}
if (object.codec != null) {
result
..add(r'codec')
..add(serializers.serialize(object.codec,
specifiedType: const FullType(String)));
}
if (object.videoOnly != null) {
result
..add(r'videoOnly')
..add(serializers.serialize(object.videoOnly,
specifiedType: const FullType(bool)));
}
if (object.bitrate != null) {
result
..add(r'bitrate')
..add(serializers.serialize(object.bitrate,
specifiedType: const FullType(int)));
}
if (object.initStart != null) {
result
..add(r'initStart')
..add(serializers.serialize(object.initStart,
specifiedType: const FullType(int)));
}
if (object.initEnd != null) {
result
..add(r'initEnd')
..add(serializers.serialize(object.initEnd,
specifiedType: const FullType(int)));
}
if (object.indexStart != null) {
result
..add(r'indexStart')
..add(serializers.serialize(object.indexStart,
specifiedType: const FullType(int)));
}
if (object.indexEnd != null) {
result
..add(r'indexEnd')
..add(serializers.serialize(object.indexEnd,
specifiedType: const FullType(int)));
}
if (object.width != null) {
result
..add(r'width')
..add(serializers.serialize(object.width,
specifiedType: const FullType(int)));
}
if (object.height != null) {
result
..add(r'height')
..add(serializers.serialize(object.height,
specifiedType: const FullType(int)));
}
if (object.fps != null) {
result
..add(r'fps')
..add(serializers.serialize(object.fps,
specifiedType: const FullType(int)));
}
return result;
}
@override
Stream deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = StreamBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case r'url':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.url = valueDes;
break;
case r'format':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(StreamFormatEnum)) as StreamFormatEnum;
result.format = valueDes;
break;
case r'quality':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.quality = valueDes;
break;
case r'mimeType':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.mimeType = valueDes;
break;
case r'codec':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.codec = valueDes;
break;
case r'videoOnly':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
result.videoOnly = valueDes;
break;
case r'bitrate':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.bitrate = valueDes;
break;
case r'initStart':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.initStart = valueDes;
break;
case r'initEnd':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.initEnd = valueDes;
break;
case r'indexStart':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.indexStart = valueDes;
break;
case r'indexEnd':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.indexEnd = valueDes;
break;
case r'width':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.width = valueDes;
break;
case r'height':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.height = valueDes;
break;
case r'fps':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.fps = valueDes;
break;
}
}
return result.build();
}
}
class StreamFormatEnum extends EnumClass {
/// The format of the stream.
@BuiltValueEnumConst(wireName: r'MPEG_4')
static const StreamFormatEnum mPEG4 = _$streamFormatEnum_mPEG4;
/// The format of the stream.
@BuiltValueEnumConst(wireName: r'v3GPP')
static const StreamFormatEnum v3GPP = _$streamFormatEnum_v3GPP;
/// The format of the stream.
@BuiltValueEnumConst(wireName: r'WEBM')
static const StreamFormatEnum WEBM = _$streamFormatEnum_WEBM;
/// The format of the stream.
@BuiltValueEnumConst(wireName: r'M4A')
static const StreamFormatEnum m4A = _$streamFormatEnum_m4A;
/// The format of the stream.
@BuiltValueEnumConst(wireName: r'WEBMA_OPUS')
static const StreamFormatEnum WEBMA_OPUS = _$streamFormatEnum_WEBMA_OPUS;
static Serializer<StreamFormatEnum> get serializer => _$streamFormatEnumSerializer;
const StreamFormatEnum._(String name): super(name);
static BuiltSet<StreamFormatEnum> get values => _$streamFormatEnumValues;
static StreamFormatEnum valueOf(String name) => _$streamFormatEnumValueOf(name);
}

View file

@ -0,0 +1,208 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'stream_item.g.dart';
/// StreamItem
///
/// Properties:
/// * [duration] - The duration of the video in seconds.
/// * [thumbnail] - The thumbnail of the video.
/// * [title] - The title of the video.
/// * [uploadedDate] - The relative date the video was uploaded on.
/// * [uploaderAvatar] - The avatar of the channel of the video.
/// * [uploaderName] - The name of the channel of the video.
/// * [uploaderUrl] - The relative URL of the channel of the video.
/// * [uploaderVerified] - Whether or not the channel has a verified badge.
/// * [url] - The relative URL to the video.
/// * [views] - The number of views the video has.
abstract class StreamItem implements Built<StreamItem, StreamItemBuilder> {
/// The duration of the video in seconds.
@BuiltValueField(wireName: r'duration')
int get duration;
/// The thumbnail of the video.
@BuiltValueField(wireName: r'thumbnail')
String get thumbnail;
/// The title of the video.
@BuiltValueField(wireName: r'title')
String get title;
/// The relative date the video was uploaded on.
@BuiltValueField(wireName: r'uploadedDate')
String? get uploadedDate;
/// The avatar of the channel of the video.
@BuiltValueField(wireName: r'uploaderAvatar')
String? get uploaderAvatar;
/// The name of the channel of the video.
@BuiltValueField(wireName: r'uploaderName')
String? get uploaderName;
/// The relative URL of the channel of the video.
@BuiltValueField(wireName: r'uploaderUrl')
String? get uploaderUrl;
/// Whether or not the channel has a verified badge.
@BuiltValueField(wireName: r'uploaderVerified')
bool? get uploaderVerified;
/// The relative URL to the video.
@BuiltValueField(wireName: r'url')
String get url;
/// The number of views the video has.
@BuiltValueField(wireName: r'views')
int? get views;
StreamItem._();
@BuiltValueHook(initializeBuilder: true)
static void _defaults(StreamItemBuilder b) => b;
factory StreamItem([void updates(StreamItemBuilder b)]) = _$StreamItem;
@BuiltValueSerializer(custom: true)
static Serializer<StreamItem> get serializer => _$StreamItemSerializer();
}
class _$StreamItemSerializer implements StructuredSerializer<StreamItem> {
@override
final Iterable<Type> types = const [StreamItem, _$StreamItem];
@override
final String wireName = r'StreamItem';
@override
Iterable<Object?> serialize(Serializers serializers, StreamItem object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
result
..add(r'duration')
..add(serializers.serialize(object.duration,
specifiedType: const FullType(int)));
result
..add(r'thumbnail')
..add(serializers.serialize(object.thumbnail,
specifiedType: const FullType(String)));
result
..add(r'title')
..add(serializers.serialize(object.title,
specifiedType: const FullType(String)));
if (object.uploadedDate != null) {
result
..add(r'uploadedDate')
..add(serializers.serialize(object.uploadedDate,
specifiedType: const FullType(String)));
}
if (object.uploaderAvatar != null) {
result
..add(r'uploaderAvatar')
..add(serializers.serialize(object.uploaderAvatar,
specifiedType: const FullType(String)));
}
if (object.uploaderName != null) {
result
..add(r'uploaderName')
..add(serializers.serialize(object.uploaderName,
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)));
}
result
..add(r'url')
..add(serializers.serialize(object.url,
specifiedType: const FullType(String)));
if (object.views != null) {
result
..add(r'views')
..add(serializers.serialize(object.views,
specifiedType: const FullType(int)));
}
return result;
}
@override
StreamItem deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = StreamItemBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case r'duration':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.duration = valueDes;
break;
case r'thumbnail':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.thumbnail = valueDes;
break;
case r'title':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.title = valueDes;
break;
case r'uploadedDate':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.uploadedDate = valueDes;
break;
case r'uploaderAvatar':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.uploaderAvatar = valueDes;
break;
case r'uploaderName':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.uploaderName = 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'url':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
result.url = valueDes;
break;
case r'views':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
result.views = valueDes;
break;
}
}
return result.build();
}
}

View file

@ -0,0 +1,89 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
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:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'video_info.g.dart';
/// VideoInfo
///
/// Properties:
/// * [audioStreams]
/// * [relatedStreams]
abstract class VideoInfo implements Built<VideoInfo, VideoInfoBuilder> {
@BuiltValueField(wireName: r'audioStreams')
BuiltList<Stream>? get audioStreams;
@BuiltValueField(wireName: r'relatedStreams')
BuiltList<StreamItem>? get relatedStreams;
VideoInfo._();
@BuiltValueHook(initializeBuilder: true)
static void _defaults(VideoInfoBuilder b) => b;
factory VideoInfo([void updates(VideoInfoBuilder b)]) = _$VideoInfo;
@BuiltValueSerializer(custom: true)
static Serializer<VideoInfo> get serializer => _$VideoInfoSerializer();
}
class _$VideoInfoSerializer implements StructuredSerializer<VideoInfo> {
@override
final Iterable<Type> types = const [VideoInfo, _$VideoInfo];
@override
final String wireName = r'VideoInfo';
@override
Iterable<Object?> serialize(Serializers serializers, VideoInfo object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[];
if (object.audioStreams != null) {
result
..add(r'audioStreams')
..add(serializers.serialize(object.audioStreams,
specifiedType: const FullType(BuiltList, [FullType(Stream)])));
}
if (object.relatedStreams != null) {
result
..add(r'relatedStreams')
..add(serializers.serialize(object.relatedStreams,
specifiedType: const FullType(BuiltList, [FullType(StreamItem)])));
}
return result;
}
@override
VideoInfo deserialize(Serializers serializers, Iterable<Object?> serialized,
{FullType specifiedType = FullType.unspecified}) {
final result = VideoInfoBuilder();
final iterator = serialized.iterator;
while (iterator.moveNext()) {
final key = iterator.current as String;
iterator.moveNext();
final Object? value = iterator.current;
switch (key) {
case r'audioStreams':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(BuiltList, [FullType(Stream)])) as BuiltList<Stream>;
result.audioStreams.replace(valueDes);
break;
case r'relatedStreams':
final valueDes = serializers.deserialize(value,
specifiedType: const FullType(BuiltList, [FullType(StreamItem)])) as BuiltList<StreamItem>;
result.relatedStreams.replace(valueDes);
break;
}
}
return result.build();
}
}

42
lib/src/serializers.dart Normal file
View file

@ -0,0 +1,42 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// ignore_for_file: unused_import
import 'package:built_collection/built_collection.dart';
import 'package:built_value/json_object.dart';
import 'package:built_value/serializer.dart';
import 'package:built_value/standard_json_plugin.dart';
import 'package:built_value/iso_8601_date_time_serializer.dart';
import 'package:piped_api/src/date_serializer.dart';
import 'package:piped_api/src/model/date.dart';
import 'package:piped_api/src/model/channel_info.dart';
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/video_info.dart';
part 'serializers.g.dart';
@SerializersFor([
ChannelInfo,
ExceptionError,
Regions,
Stream,
StreamItem,
VideoInfo,
])
Serializers serializers = (_$serializers.toBuilder()
..addBuilderFactory(
const FullType(BuiltList, [FullType(StreamItem)]),
() => ListBuilder<StreamItem>(),
)
..add(const DateSerializer())
..add(Iso8601DateTimeSerializer()))
.build();
Serializers standardSerializers =
(serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();