more fields

This commit is contained in:
2024-12-05 20:40:21 +01:00
parent 67aca796d9
commit d512452bc9
2 changed files with 162 additions and 11 deletions
+89
View File
@@ -1,3 +1,6 @@
import 'package:logger/logger.dart';
import 'package:multimedia/log_printer.dart';
class Movie {
int movieID;
String movieTitle;
@@ -7,6 +10,7 @@ class Movie {
int state;
String resolution;
String backdropPath;
String posterPath;
String languages;
String productionCountries;
String productionCompanies;
@@ -16,6 +20,18 @@ class Movie {
String crew;
String genre;
String localPath;
String imdbID;
String originalLanguage;
double popularity;
bool adult;
String belongsToCollection;
double budget;
String homepage;
double revenue;
int runtime;
String tagline;
Logger logger = getLogger();
Movie({
required this.movieID,
@@ -26,6 +42,7 @@ class Movie {
required this.state,
required this.resolution,
required this.backdropPath,
required this.posterPath, //NEW STRING
required this.languages,
required this.productionCountries,
required this.productionCompanies,
@@ -35,6 +52,16 @@ class Movie {
required this.crew,
required this.genre,
required this.localPath,
required this.imdbID, //NEW STRING
required this.originalLanguage, //NEW STRING
required this.popularity, //NEW FLOAT
required this.adult, //NEW BOOL/INT
required this.belongsToCollection, //NEW STRING
required this.budget, //NEW FLOAT
required this.homepage, //NEW STRING
required this.revenue, //NEW FLOAT
required this.runtime, //NEW INT
required this.tagline, //NEW STRING
});
factory Movie.fromJson(Map<String, dynamic> json) {
@@ -48,6 +75,7 @@ class Movie {
state: int.parse(json['state']),
resolution: json['resolution'] as String,
backdropPath: json['backdropPath'] as String,
posterPath: json['posterPath'] as String,
languages: json['languages'],
productionCountries: json['productionCountries'],
productionCompanies: json['productionCompanies'],
@@ -57,6 +85,16 @@ class Movie {
crew: json['crew'],
genre: json['genre'],
localPath: json['localpath'],
imdbID: json['imdbid'],
originalLanguage: json['originalLanguage'],
popularity: double.parse(json['popularity']),
adult: int.parse(json['adult']) == 0 ? false : true,
belongsToCollection: json['belongsToCollection'],
budget: double.parse(json['budget']),
homepage: json['homepage'],
revenue: double.parse(json['revenue']),
runtime: int.parse(json['runtime']),
tagline: json['tagline'],
);
}
return Movie(
@@ -68,6 +106,7 @@ class Movie {
state: int.parse(json['state']),
resolution: json['resolution'] as String,
backdropPath: '',
posterPath: '',
languages: '',
productionCountries: '',
productionCompanies: '',
@@ -77,6 +116,56 @@ class Movie {
crew: '',
genre: '',
localPath: '',
imdbID: '',
originalLanguage: '',
popularity: 0,
adult: false,
belongsToCollection: '',
budget: 0,
homepage: '',
revenue: 0,
runtime: 0,
tagline: '',
);
}
factory Movie.fromJsonDynamic(Map<dynamic, dynamic> json) {
// dynamic languages = json['languages'];
// dynamic productionCountries = json['productionCountries'];
// dynamic productionCompanies = json['productionCompanies'];
// dynamic cast = json['cast'];
// dynamic crew = json['crew'];
// dynamic genre = json['genre'];
return Movie(
movieID: json['id'],
movieTitle: json['title'],
originalTitle: json['original_title'],
overview: json['overview'],
releaseDate: DateTime.parse(json['release_date'].toString()),
state: int.tryParse(['status'].toString()) ?? 0,
resolution: '',
backdropPath: json['backdrop_path'],
posterPath: '',
languages: '',
productionCountries: '',
productionCompanies: '',
voteAverage: double.tryParse(['vote_average'].toString()) ?? 0,
voteCount: int.tryParse(['vote_count'].toString()) ?? 0,
cast: '',
crew: '',
genre: '',
localPath: '',
imdbID: '',
originalLanguage: '',
popularity: 0,
adult: false,
belongsToCollection: '',
budget: 0,
homepage: '',
revenue: 0,
runtime: 0,
tagline: '',
);
}
}