47 lines
1.2 KiB
Dart
47 lines
1.2 KiB
Dart
import 'dart:convert';
|
|
import '../../../core/status.dart';
|
|
|
|
class Movie {
|
|
final int id; // DB-ID
|
|
final int tmdbId;
|
|
final String title;
|
|
final int? releaseYear;
|
|
final String? posterPath;
|
|
final ItemStatus status;
|
|
final String? resolution;
|
|
final String? overview;
|
|
|
|
Movie({
|
|
required this.id,
|
|
required this.tmdbId,
|
|
required this.title,
|
|
this.releaseYear,
|
|
this.posterPath,
|
|
this.status = ItemStatus.Init,
|
|
this.resolution,
|
|
this.overview,
|
|
});
|
|
|
|
factory Movie.fromJson(Map<String, dynamic> j) {
|
|
String? ov;
|
|
if (j['overview'] is String) {
|
|
ov = j['overview'] as String?;
|
|
} else if (j['json'] is String) {
|
|
try {
|
|
final m = jsonDecode(j['json'] as String);
|
|
if (m is Map && m['overview'] is String) ov = m['overview'] as String;
|
|
} catch (_) {}
|
|
}
|
|
return Movie(
|
|
id: j['id'] as int,
|
|
tmdbId: j['tmdb_id'] as int,
|
|
title: j['title'] as String,
|
|
releaseYear: j['release_year'] as int?,
|
|
posterPath: j['poster_path'] as String?,
|
|
status: j['status'] != null ? statusFromString(j['status'] as String) : ItemStatus.Init,
|
|
resolution: j['resolution'] as String?,
|
|
overview: ov,
|
|
);
|
|
}
|
|
}
|