2021-02-09 08:36:29 +01:00
|
|
|
import 'dart:convert';
|
|
|
|
|
2020-10-28 13:10:43 +01:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
2021-02-09 08:36:29 +01:00
|
|
|
import 'package:tsacdop/type/episodebrief.dart';
|
2020-10-28 13:10:43 +01:00
|
|
|
part 'searchepisodes.g.dart';
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class SearchEpisodes<E> {
|
|
|
|
@_ConvertE()
|
|
|
|
final List<E> episodes;
|
|
|
|
@JsonKey(name: 'next_episode_pub_date')
|
|
|
|
final int nextEpisodeDate;
|
|
|
|
SearchEpisodes({this.episodes, this.nextEpisodeDate});
|
|
|
|
factory SearchEpisodes.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$SearchEpisodesFromJson<E>(json);
|
|
|
|
Map<String, dynamic> toJson() => _$SearchEpisodesToJson(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ConvertE<E> implements JsonConverter<E, Object> {
|
|
|
|
const _ConvertE();
|
|
|
|
@override
|
|
|
|
E fromJson(Object json) {
|
|
|
|
return OnlineEpisode.fromJson(json) as E;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Object toJson(E object) {
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable()
|
|
|
|
class OnlineEpisode {
|
|
|
|
final String title;
|
|
|
|
@JsonKey(name: 'pub_date_ms')
|
|
|
|
final int pubDate;
|
|
|
|
@JsonKey(name: 'audio_length_sec')
|
|
|
|
final int length;
|
2021-02-09 08:36:29 +01:00
|
|
|
final String audio;
|
|
|
|
final String thumbnail;
|
|
|
|
|
|
|
|
OnlineEpisode({this.title, this.pubDate, this.length, this.audio, this.thumbnail});
|
2020-10-28 13:10:43 +01:00
|
|
|
factory OnlineEpisode.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$OnlineEpisodeFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$OnlineEpisodeToJson(this);
|
2021-02-09 08:36:29 +01:00
|
|
|
|
|
|
|
EpisodeBrief get toEpisode {
|
|
|
|
return EpisodeBrief(
|
|
|
|
title,
|
|
|
|
audio,
|
|
|
|
0,
|
|
|
|
pubDate,
|
|
|
|
title,
|
2021-02-09 17:40:04 +01:00
|
|
|
'',
|
2021-02-09 08:36:29 +01:00
|
|
|
length ?? 0,
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
mediaId: audio,
|
|
|
|
skipSecondsEnd: 0,
|
|
|
|
skipSecondsStart: 0,
|
|
|
|
chapterLink: '',
|
|
|
|
episodeImage: thumbnail
|
|
|
|
);
|
|
|
|
}
|
2020-10-28 13:10:43 +01:00
|
|
|
}
|