You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
4.2 KiB
Dart
173 lines
4.2 KiB
Dart
class EpisodeCount {
|
|
int season;
|
|
int cnt;
|
|
|
|
EpisodeCount({
|
|
required this.season,
|
|
required this.cnt,
|
|
});
|
|
|
|
factory EpisodeCount.fromJson(Map<String, dynamic> json) {
|
|
return EpisodeCount(
|
|
season: int.parse(json['seasonNumber']),
|
|
cnt: int.parse(json['cnt']),
|
|
);
|
|
}
|
|
}
|
|
|
|
class Season {
|
|
int seasonNumber;
|
|
int seasonID;
|
|
String state;
|
|
|
|
Season({
|
|
required this.seasonNumber,
|
|
required this.seasonID,
|
|
required this.state,
|
|
});
|
|
|
|
factory Season.fromJson(Map<String, dynamic> json) {
|
|
return Season(
|
|
seasonNumber: int.parse(json['seasonNumber']),
|
|
seasonID: int.parse(json['seasonID']),
|
|
state: json['state']);
|
|
}
|
|
|
|
Map toJson() =>
|
|
{
|
|
'seasonNumber': seasonNumber.toString(),
|
|
'seasonID': seasonID.toString(),
|
|
'state': state,
|
|
};
|
|
}
|
|
|
|
class TVShow {
|
|
int seriesID;
|
|
String seriesName;
|
|
String overview;
|
|
String backdropPath;
|
|
DateTime firstAired;
|
|
int seriesState;
|
|
String resolution;
|
|
int cliffhanger;
|
|
String status;
|
|
String languages;
|
|
String networks;
|
|
String originCountries;
|
|
String productionCompanies;
|
|
double voteAverage;
|
|
int voteCount;
|
|
String cast;
|
|
String crew;
|
|
String genre;
|
|
String download;
|
|
String localPath;
|
|
|
|
List<Season> seasonStatus;
|
|
|
|
TVShow({
|
|
required this.seriesID,
|
|
required this.seriesName,
|
|
required this.overview,
|
|
required this.backdropPath,
|
|
required this.firstAired,
|
|
required this.seriesState,
|
|
required this.resolution,
|
|
required this.cliffhanger,
|
|
required this.status,
|
|
required this.seasonStatus,
|
|
required this.languages,
|
|
required this.networks,
|
|
required this.originCountries,
|
|
required this.productionCompanies,
|
|
required this.voteAverage,
|
|
required this.voteCount,
|
|
required this.cast,
|
|
required this.crew,
|
|
required this.genre,
|
|
required this.download,
|
|
required this.localPath,
|
|
});
|
|
|
|
factory TVShow.fromJson(Map<String, dynamic> json) {
|
|
int seriesState = 0;
|
|
List<String> stateList = json['seriesState'].toString().split(',');
|
|
|
|
bool hasInit = false;
|
|
bool hasProg = false;
|
|
bool hasDone = false;
|
|
|
|
for (String state in stateList) {
|
|
if (state[0] == '1') {
|
|
hasInit = true;
|
|
} else if (state[0] == '2') {
|
|
hasProg = true;
|
|
} else if (state[0] == '3') {
|
|
hasDone = true;
|
|
}
|
|
}
|
|
|
|
if (hasProg) {
|
|
seriesState = 2;
|
|
} else if (hasInit) {
|
|
seriesState = 1;
|
|
} else if (hasDone) {
|
|
seriesState = 3;
|
|
}
|
|
|
|
if (json.containsKey('overview')) {
|
|
return TVShow(
|
|
seriesID: int.parse(json['seriesID']),
|
|
seriesName: json['seriesName'],
|
|
firstAired: DateTime.parse(json['firstAired']),
|
|
seriesState: seriesState,
|
|
resolution: json['resolution'],
|
|
status: json['status'],
|
|
cliffhanger: int.parse(json['cliffhanger']),
|
|
download: json['download'],
|
|
overview: json['overview'],
|
|
backdropPath: json['backdropPath'],
|
|
seasonStatus: json['seasons']
|
|
.map<Season>((json) => Season.fromJson(json))
|
|
.toList(),
|
|
languages: json['languages'],
|
|
networks: json['networks'],
|
|
originCountries: json['originCountries'],
|
|
productionCompanies: json['productionCompanies'],
|
|
voteAverage: double.parse(json['voteAverage']),
|
|
voteCount: int.parse(json['voteCount']),
|
|
cast: json['cast'],
|
|
crew: json['crew'],
|
|
genre: json['genre'],
|
|
localPath: json['localPath'],
|
|
);
|
|
}
|
|
|
|
return TVShow(
|
|
seriesID: int.parse(json['seriesID']),
|
|
seriesName: json['seriesName'],
|
|
firstAired: DateTime.parse(json['firstAired']),
|
|
seriesState: seriesState,
|
|
resolution: json['resolution'],
|
|
status: json['status'],
|
|
cliffhanger: int.parse(json['cliffhanger']),
|
|
download: json['download'],
|
|
overview: '',
|
|
backdropPath: '',
|
|
seasonStatus: json['seasons']
|
|
.map<Season>((json) => Season.fromJson(json))
|
|
.toList(),
|
|
languages: '',
|
|
networks: '',
|
|
originCountries: '',
|
|
productionCompanies: '',
|
|
voteAverage: 0,
|
|
voteCount: 0,
|
|
cast: '',
|
|
crew: '',
|
|
genre: '',
|
|
localPath: '',
|
|
);
|
|
}
|
|
}
|