mirror of
https://gitlab.com/foxixus/neomovies_mobile.git
synced 2025-10-28 01:18:50 +05:00
fix api bugs
This commit is contained in:
@@ -31,11 +31,12 @@ class Favorite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String get fullPosterUrl {
|
String get fullPosterUrl {
|
||||||
final baseUrl = dotenv.env['API_URL']!;
|
|
||||||
if (posterPath.isEmpty) {
|
if (posterPath.isEmpty) {
|
||||||
return '$baseUrl/images/w500/placeholder.jpg';
|
return 'https://via.placeholder.com/500x750.png?text=No+Poster';
|
||||||
}
|
}
|
||||||
|
// TMDB CDN base URL
|
||||||
|
const tmdbBaseUrl = 'https://image.tmdb.org/t/p';
|
||||||
final cleanPath = posterPath.startsWith('/') ? posterPath.substring(1) : posterPath;
|
final cleanPath = posterPath.startsWith('/') ? posterPath.substring(1) : posterPath;
|
||||||
return '$baseUrl/images/w500/$cleanPath';
|
return '$tmdbBaseUrl/w500/$cleanPath';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ class Movie extends HiveObject {
|
|||||||
@HiveField(2)
|
@HiveField(2)
|
||||||
final String? posterPath;
|
final String? posterPath;
|
||||||
|
|
||||||
|
final String? backdropPath;
|
||||||
|
|
||||||
@HiveField(3)
|
@HiveField(3)
|
||||||
final String? overview;
|
final String? overview;
|
||||||
|
|
||||||
@@ -51,6 +53,7 @@ class Movie extends HiveObject {
|
|||||||
required this.id,
|
required this.id,
|
||||||
required this.title,
|
required this.title,
|
||||||
this.posterPath,
|
this.posterPath,
|
||||||
|
this.backdropPath,
|
||||||
this.overview,
|
this.overview,
|
||||||
this.releaseDate,
|
this.releaseDate,
|
||||||
this.genres,
|
this.genres,
|
||||||
@@ -68,6 +71,7 @@ class Movie extends HiveObject {
|
|||||||
id: (json['id'] as num).toString(), // Ensure id is a string
|
id: (json['id'] as num).toString(), // Ensure id is a string
|
||||||
title: (json['title'] ?? json['name'] ?? '') as String,
|
title: (json['title'] ?? json['name'] ?? '') as String,
|
||||||
posterPath: json['poster_path'] as String?,
|
posterPath: json['poster_path'] as String?,
|
||||||
|
backdropPath: json['backdrop_path'] as String?,
|
||||||
overview: json['overview'] as String?,
|
overview: json['overview'] as String?,
|
||||||
releaseDate: json['release_date'] != null && json['release_date'].isNotEmpty
|
releaseDate: json['release_date'] != null && json['release_date'].isNotEmpty
|
||||||
? DateTime.tryParse(json['release_date'] as String)
|
? DateTime.tryParse(json['release_date'] as String)
|
||||||
@@ -92,13 +96,24 @@ class Movie extends HiveObject {
|
|||||||
Map<String, dynamic> toJson() => _$MovieToJson(this);
|
Map<String, dynamic> toJson() => _$MovieToJson(this);
|
||||||
|
|
||||||
String get fullPosterUrl {
|
String get fullPosterUrl {
|
||||||
final baseUrl = dotenv.env['API_URL']!;
|
|
||||||
if (posterPath == null || posterPath!.isEmpty) {
|
if (posterPath == null || posterPath!.isEmpty) {
|
||||||
// Use the placeholder from our own backend
|
// Use a generic placeholder
|
||||||
return '$baseUrl/images/w500/placeholder.jpg';
|
return 'https://via.placeholder.com/500x750.png?text=No+Poster';
|
||||||
}
|
}
|
||||||
// Null check is already performed above, so we can use `!`
|
// TMDB CDN base URL
|
||||||
|
const tmdbBaseUrl = 'https://image.tmdb.org/t/p';
|
||||||
final cleanPath = posterPath!.startsWith('/') ? posterPath!.substring(1) : posterPath!;
|
final cleanPath = posterPath!.startsWith('/') ? posterPath!.substring(1) : posterPath!;
|
||||||
return '$baseUrl/images/w500/$cleanPath';
|
return '$tmdbBaseUrl/w500/$cleanPath';
|
||||||
|
}
|
||||||
|
|
||||||
|
String get fullBackdropUrl {
|
||||||
|
if (backdropPath == null || backdropPath!.isEmpty) {
|
||||||
|
// Use a generic placeholder
|
||||||
|
return 'https://via.placeholder.com/1280x720.png?text=No+Backdrop';
|
||||||
|
}
|
||||||
|
// TMDB CDN base URL
|
||||||
|
const tmdbBaseUrl = 'https://image.tmdb.org/t/p';
|
||||||
|
final cleanPath = backdropPath!.startsWith('/') ? backdropPath!.substring(1) : backdropPath!;
|
||||||
|
return '$tmdbBaseUrl/w780/$cleanPath';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ Movie _$MovieFromJson(Map<String, dynamic> json) => Movie(
|
|||||||
id: json['id'] as String,
|
id: json['id'] as String,
|
||||||
title: json['title'] as String,
|
title: json['title'] as String,
|
||||||
posterPath: json['posterPath'] as String?,
|
posterPath: json['posterPath'] as String?,
|
||||||
|
backdropPath: json['backdropPath'] as String?,
|
||||||
overview: json['overview'] as String?,
|
overview: json['overview'] as String?,
|
||||||
releaseDate: json['releaseDate'] == null
|
releaseDate: json['releaseDate'] == null
|
||||||
? null
|
? null
|
||||||
@@ -100,6 +101,7 @@ Map<String, dynamic> _$MovieToJson(Movie instance) => <String, dynamic>{
|
|||||||
'id': instance.id,
|
'id': instance.id,
|
||||||
'title': instance.title,
|
'title': instance.title,
|
||||||
'posterPath': instance.posterPath,
|
'posterPath': instance.posterPath,
|
||||||
|
'backdropPath': instance.backdropPath,
|
||||||
'overview': instance.overview,
|
'overview': instance.overview,
|
||||||
'releaseDate': instance.releaseDate?.toIso8601String(),
|
'releaseDate': instance.releaseDate?.toIso8601String(),
|
||||||
'genres': instance.genres,
|
'genres': instance.genres,
|
||||||
|
|||||||
@@ -33,21 +33,32 @@ class MovieDetailProvider with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Load movie/TV details
|
||||||
if (mediaType == 'movie') {
|
if (mediaType == 'movie') {
|
||||||
_movie = await _movieRepository.getMovieById(mediaId.toString());
|
_movie = await _movieRepository.getMovieById(mediaId.toString());
|
||||||
} else {
|
} else {
|
||||||
_movie = await _movieRepository.getTvById(mediaId.toString());
|
_movie = await _movieRepository.getTvById(mediaId.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
|
// Try to load IMDb ID (non-blocking)
|
||||||
if (_movie != null) {
|
if (_movie != null) {
|
||||||
_imdbId = await _apiClient.getImdbId(mediaId.toString(), mediaType);
|
try {
|
||||||
|
_imdbId = await _apiClient.getImdbId(mediaId.toString(), mediaType);
|
||||||
|
} catch (e) {
|
||||||
|
// IMDb ID loading failed, but don't fail the whole screen
|
||||||
|
print('Failed to load IMDb ID: $e');
|
||||||
|
_imdbId = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
print('Error loading media: $e');
|
||||||
_error = e.toString();
|
_error = e.toString();
|
||||||
} finally {
|
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
|
notifyListeners();
|
||||||
|
} finally {
|
||||||
_isImdbLoading = false;
|
_isImdbLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user