Files
neomovies-mobile/lib/data/models/movie.dart

171 lines
5.3 KiB
Dart
Raw Permalink Normal View History

2025-07-13 14:01:29 +03:00
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:hive/hive.dart';
2025-07-19 18:13:13 +03:00
import 'package:json_annotation/json_annotation.dart';
2025-07-13 14:01:29 +03:00
part 'movie.g.dart';
@HiveType(typeId: 0)
2025-07-19 18:13:13 +03:00
@JsonSerializable()
2025-07-13 14:01:29 +03:00
class Movie extends HiveObject {
@HiveField(0)
final String id;
@HiveField(1)
final String title;
@HiveField(2)
final String? posterPath;
2025-10-02 21:40:20 +00:00
final String? backdropPath;
2025-07-13 14:01:29 +03:00
@HiveField(3)
final String? overview;
@HiveField(4)
final DateTime? releaseDate;
@HiveField(5)
final List<String>? genres;
@HiveField(6)
final double? voteAverage;
// Поле популярности из API (TMDB-style)
@HiveField(9)
final double popularity;
@HiveField(7)
final int? runtime;
// TV specific
@HiveField(10)
final int? seasonsCount;
@HiveField(11)
final int? episodesCount;
@HiveField(8)
final String? tagline;
// not stored in Hive, runtime-only field
final String mediaType;
Movie({
required this.id,
required this.title,
this.posterPath,
2025-10-02 21:40:20 +00:00
this.backdropPath,
2025-07-13 14:01:29 +03:00
this.overview,
this.releaseDate,
this.genres,
this.voteAverage,
this.popularity = 0.0,
this.runtime,
this.seasonsCount,
this.episodesCount,
this.tagline,
this.mediaType = 'movie',
});
factory Movie.fromJson(Map<String, dynamic> json) {
fix: resolve gray screens and add automatic versioning 1. Fix Downloads screen gray screen issue: - Add DownloadsProvider to main.dart providers list - Remove @RoutePage() decorator from DownloadsScreen - Downloads screen now displays torrent list correctly 2. Fix movie detail screen gray screen issue: - Improve Movie.fromJson() with better error handling - Safe parsing of genres field (handles both Map and String formats) - Add fallback 'Untitled' for movies without title - Add detailed logging in MovieDetailProvider - Better error messages with stack traces 3. Add automatic version update from CI/CD tags: - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build - Version format: tag v0.0.18 becomes version 0.0.18+18 - Applies to all build jobs (arm64, arm32, x64) How versioning works: - When you create tag v0.0.18, CI automatically updates pubspec.yaml - Build uses version 0.0.18+18 (version+buildNumber) - APK shows correct version in About screen and Google Play - No manual pubspec.yaml updates needed Example: - Create tag: git tag v0.0.18 && git push origin v0.0.18 - CI reads tag, extracts '0.0.18' - Updates: version: 0.0.18+18 in pubspec.yaml - Builds APK with this version - Release created with proper version number Changes: - lib/main.dart: Add DownloadsProvider - lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage - lib/data/models/movie.dart: Safe JSON parsing with error handling - lib/presentation/providers/movie_detail_provider.dart: Add detailed logging - .gitlab-ci.yml: Add version update script in all build jobs - .github/workflows/release.yml: Add version update step in all build jobs Result: ✅ Downloads screen displays properly ✅ Movie details screen loads correctly ✅ Automatic versioning from tags (0.0.18, 0.0.19, etc.) ✅ No more gray screens!
2025-10-05 16:28:47 +00:00
try {
fix: improve API response parsing with detailed logging Problem: - Gray screens on movie details and downloads - No error messages shown to debug issues - API response structure not fully validated Solution: 1. Enhanced Movie.fromJson() parsing: - Added detailed logging for each parsing step - Safe genre parsing: handles [{id: 18, name: Drama}] - Safe date parsing with null checks - Safe runtime parsing for both movies and TV shows - Better media type detection (movie vs tv) - Comprehensive error logging with stack traces 2. Added detailed API logging: - getMovieById(): Log request URL, response status, body preview - getTvShowById(): Log request URL, response status, body preview - Log API response structure (keys, types, unwrapped data) - Makes debugging much easier 3. Based on backend API structure: Backend returns: {"success": true, "data": {...}} Movie fields from TMDB: - id (number) - title or name (string) - genres: [{"id": int, "name": string}] - release_date or first_air_date (string) - vote_average (number) - runtime or episode_run_time (number/array) - number_of_seasons, number_of_episodes (int, optional) Logging examples: - 'Parsing Movie from JSON: [id, title, genres, ...]' - 'Parsed genres: [Drama, Thriller, Mystery]' - 'Successfully parsed movie: Fight Club' - 'Response status: 200' - 'Movie data keys: [id, title, overview, ...]' Changes: - lib/data/models/movie.dart: Complete rewrite with safe parsing - lib/data/api/neomovies_api_client.dart: Add detailed logging Result: ✅ Safer JSON parsing with null checks ✅ Detailed error logging for debugging ✅ Handles all edge cases from API ✅ Easy to debug gray screen issues via logs Next steps: Test the app and check Flutter debug console for: - API request URLs - Response bodies - Parsing errors (if any) - Successful movie loading messages
2025-10-05 16:34:54 +00:00
print('Parsing Movie from JSON: ${json.keys.toList()}');
// Parse genres safely - API returns: [{"id": 18, "name": "Drama"}]
fix: resolve gray screens and add automatic versioning 1. Fix Downloads screen gray screen issue: - Add DownloadsProvider to main.dart providers list - Remove @RoutePage() decorator from DownloadsScreen - Downloads screen now displays torrent list correctly 2. Fix movie detail screen gray screen issue: - Improve Movie.fromJson() with better error handling - Safe parsing of genres field (handles both Map and String formats) - Add fallback 'Untitled' for movies without title - Add detailed logging in MovieDetailProvider - Better error messages with stack traces 3. Add automatic version update from CI/CD tags: - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build - Version format: tag v0.0.18 becomes version 0.0.18+18 - Applies to all build jobs (arm64, arm32, x64) How versioning works: - When you create tag v0.0.18, CI automatically updates pubspec.yaml - Build uses version 0.0.18+18 (version+buildNumber) - APK shows correct version in About screen and Google Play - No manual pubspec.yaml updates needed Example: - Create tag: git tag v0.0.18 && git push origin v0.0.18 - CI reads tag, extracts '0.0.18' - Updates: version: 0.0.18+18 in pubspec.yaml - Builds APK with this version - Release created with proper version number Changes: - lib/main.dart: Add DownloadsProvider - lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage - lib/data/models/movie.dart: Safe JSON parsing with error handling - lib/presentation/providers/movie_detail_provider.dart: Add detailed logging - .gitlab-ci.yml: Add version update script in all build jobs - .github/workflows/release.yml: Add version update step in all build jobs Result: ✅ Downloads screen displays properly ✅ Movie details screen loads correctly ✅ Automatic versioning from tags (0.0.18, 0.0.19, etc.) ✅ No more gray screens!
2025-10-05 16:28:47 +00:00
List<String> genresList = [];
fix: improve API response parsing with detailed logging Problem: - Gray screens on movie details and downloads - No error messages shown to debug issues - API response structure not fully validated Solution: 1. Enhanced Movie.fromJson() parsing: - Added detailed logging for each parsing step - Safe genre parsing: handles [{id: 18, name: Drama}] - Safe date parsing with null checks - Safe runtime parsing for both movies and TV shows - Better media type detection (movie vs tv) - Comprehensive error logging with stack traces 2. Added detailed API logging: - getMovieById(): Log request URL, response status, body preview - getTvShowById(): Log request URL, response status, body preview - Log API response structure (keys, types, unwrapped data) - Makes debugging much easier 3. Based on backend API structure: Backend returns: {"success": true, "data": {...}} Movie fields from TMDB: - id (number) - title or name (string) - genres: [{"id": int, "name": string}] - release_date or first_air_date (string) - vote_average (number) - runtime or episode_run_time (number/array) - number_of_seasons, number_of_episodes (int, optional) Logging examples: - 'Parsing Movie from JSON: [id, title, genres, ...]' - 'Parsed genres: [Drama, Thriller, Mystery]' - 'Successfully parsed movie: Fight Club' - 'Response status: 200' - 'Movie data keys: [id, title, overview, ...]' Changes: - lib/data/models/movie.dart: Complete rewrite with safe parsing - lib/data/api/neomovies_api_client.dart: Add detailed logging Result: ✅ Safer JSON parsing with null checks ✅ Detailed error logging for debugging ✅ Handles all edge cases from API ✅ Easy to debug gray screen issues via logs Next steps: Test the app and check Flutter debug console for: - API request URLs - Response bodies - Parsing errors (if any) - Successful movie loading messages
2025-10-05 16:34:54 +00:00
if (json['genres'] != null && json['genres'] is List) {
genresList = (json['genres'] as List)
.map((g) {
if (g is Map && g.containsKey('name')) {
return g['name'] as String? ?? '';
}
return '';
})
.where((name) => name.isNotEmpty)
.toList();
print('Parsed genres: $genresList');
}
// Parse dates safely
DateTime? parsedDate;
final releaseDate = json['release_date'];
final firstAirDate = json['first_air_date'];
if (releaseDate != null && releaseDate.toString().isNotEmpty && releaseDate.toString() != 'null') {
parsedDate = DateTime.tryParse(releaseDate.toString());
} else if (firstAirDate != null && firstAirDate.toString().isNotEmpty && firstAirDate.toString() != 'null') {
parsedDate = DateTime.tryParse(firstAirDate.toString());
}
// Parse runtime (movie) or episode_run_time (TV)
int? runtimeValue;
if (json['runtime'] != null && json['runtime'] is num && (json['runtime'] as num) > 0) {
runtimeValue = (json['runtime'] as num).toInt();
} else if (json['episode_run_time'] != null && json['episode_run_time'] is List) {
final episodeRunTime = json['episode_run_time'] as List;
if (episodeRunTime.isNotEmpty && episodeRunTime.first is num) {
runtimeValue = (episodeRunTime.first as num).toInt();
fix: resolve gray screens and add automatic versioning 1. Fix Downloads screen gray screen issue: - Add DownloadsProvider to main.dart providers list - Remove @RoutePage() decorator from DownloadsScreen - Downloads screen now displays torrent list correctly 2. Fix movie detail screen gray screen issue: - Improve Movie.fromJson() with better error handling - Safe parsing of genres field (handles both Map and String formats) - Add fallback 'Untitled' for movies without title - Add detailed logging in MovieDetailProvider - Better error messages with stack traces 3. Add automatic version update from CI/CD tags: - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build - Version format: tag v0.0.18 becomes version 0.0.18+18 - Applies to all build jobs (arm64, arm32, x64) How versioning works: - When you create tag v0.0.18, CI automatically updates pubspec.yaml - Build uses version 0.0.18+18 (version+buildNumber) - APK shows correct version in About screen and Google Play - No manual pubspec.yaml updates needed Example: - Create tag: git tag v0.0.18 && git push origin v0.0.18 - CI reads tag, extracts '0.0.18' - Updates: version: 0.0.18+18 in pubspec.yaml - Builds APK with this version - Release created with proper version number Changes: - lib/main.dart: Add DownloadsProvider - lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage - lib/data/models/movie.dart: Safe JSON parsing with error handling - lib/presentation/providers/movie_detail_provider.dart: Add detailed logging - .gitlab-ci.yml: Add version update script in all build jobs - .github/workflows/release.yml: Add version update step in all build jobs Result: ✅ Downloads screen displays properly ✅ Movie details screen loads correctly ✅ Automatic versioning from tags (0.0.18, 0.0.19, etc.) ✅ No more gray screens!
2025-10-05 16:28:47 +00:00
}
}
fix: improve API response parsing with detailed logging Problem: - Gray screens on movie details and downloads - No error messages shown to debug issues - API response structure not fully validated Solution: 1. Enhanced Movie.fromJson() parsing: - Added detailed logging for each parsing step - Safe genre parsing: handles [{id: 18, name: Drama}] - Safe date parsing with null checks - Safe runtime parsing for both movies and TV shows - Better media type detection (movie vs tv) - Comprehensive error logging with stack traces 2. Added detailed API logging: - getMovieById(): Log request URL, response status, body preview - getTvShowById(): Log request URL, response status, body preview - Log API response structure (keys, types, unwrapped data) - Makes debugging much easier 3. Based on backend API structure: Backend returns: {"success": true, "data": {...}} Movie fields from TMDB: - id (number) - title or name (string) - genres: [{"id": int, "name": string}] - release_date or first_air_date (string) - vote_average (number) - runtime or episode_run_time (number/array) - number_of_seasons, number_of_episodes (int, optional) Logging examples: - 'Parsing Movie from JSON: [id, title, genres, ...]' - 'Parsed genres: [Drama, Thriller, Mystery]' - 'Successfully parsed movie: Fight Club' - 'Response status: 200' - 'Movie data keys: [id, title, overview, ...]' Changes: - lib/data/models/movie.dart: Complete rewrite with safe parsing - lib/data/api/neomovies_api_client.dart: Add detailed logging Result: ✅ Safer JSON parsing with null checks ✅ Detailed error logging for debugging ✅ Handles all edge cases from API ✅ Easy to debug gray screen issues via logs Next steps: Test the app and check Flutter debug console for: - API request URLs - Response bodies - Parsing errors (if any) - Successful movie loading messages
2025-10-05 16:34:54 +00:00
// Determine media type
String mediaTypeValue = 'movie';
if (json.containsKey('media_type') && json['media_type'] != null) {
mediaTypeValue = json['media_type'] as String;
} else if (json.containsKey('name') || json.containsKey('first_air_date')) {
mediaTypeValue = 'tv';
}
final movie = Movie(
id: (json['id'] as num).toString(),
fix: resolve gray screens and add automatic versioning 1. Fix Downloads screen gray screen issue: - Add DownloadsProvider to main.dart providers list - Remove @RoutePage() decorator from DownloadsScreen - Downloads screen now displays torrent list correctly 2. Fix movie detail screen gray screen issue: - Improve Movie.fromJson() with better error handling - Safe parsing of genres field (handles both Map and String formats) - Add fallback 'Untitled' for movies without title - Add detailed logging in MovieDetailProvider - Better error messages with stack traces 3. Add automatic version update from CI/CD tags: - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build - Version format: tag v0.0.18 becomes version 0.0.18+18 - Applies to all build jobs (arm64, arm32, x64) How versioning works: - When you create tag v0.0.18, CI automatically updates pubspec.yaml - Build uses version 0.0.18+18 (version+buildNumber) - APK shows correct version in About screen and Google Play - No manual pubspec.yaml updates needed Example: - Create tag: git tag v0.0.18 && git push origin v0.0.18 - CI reads tag, extracts '0.0.18' - Updates: version: 0.0.18+18 in pubspec.yaml - Builds APK with this version - Release created with proper version number Changes: - lib/main.dart: Add DownloadsProvider - lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage - lib/data/models/movie.dart: Safe JSON parsing with error handling - lib/presentation/providers/movie_detail_provider.dart: Add detailed logging - .gitlab-ci.yml: Add version update script in all build jobs - .github/workflows/release.yml: Add version update step in all build jobs Result: ✅ Downloads screen displays properly ✅ Movie details screen loads correctly ✅ Automatic versioning from tags (0.0.18, 0.0.19, etc.) ✅ No more gray screens!
2025-10-05 16:28:47 +00:00
title: (json['title'] ?? json['name'] ?? 'Untitled') as String,
posterPath: json['poster_path'] as String?,
backdropPath: json['backdrop_path'] as String?,
overview: json['overview'] as String?,
fix: improve API response parsing with detailed logging Problem: - Gray screens on movie details and downloads - No error messages shown to debug issues - API response structure not fully validated Solution: 1. Enhanced Movie.fromJson() parsing: - Added detailed logging for each parsing step - Safe genre parsing: handles [{id: 18, name: Drama}] - Safe date parsing with null checks - Safe runtime parsing for both movies and TV shows - Better media type detection (movie vs tv) - Comprehensive error logging with stack traces 2. Added detailed API logging: - getMovieById(): Log request URL, response status, body preview - getTvShowById(): Log request URL, response status, body preview - Log API response structure (keys, types, unwrapped data) - Makes debugging much easier 3. Based on backend API structure: Backend returns: {"success": true, "data": {...}} Movie fields from TMDB: - id (number) - title or name (string) - genres: [{"id": int, "name": string}] - release_date or first_air_date (string) - vote_average (number) - runtime or episode_run_time (number/array) - number_of_seasons, number_of_episodes (int, optional) Logging examples: - 'Parsing Movie from JSON: [id, title, genres, ...]' - 'Parsed genres: [Drama, Thriller, Mystery]' - 'Successfully parsed movie: Fight Club' - 'Response status: 200' - 'Movie data keys: [id, title, overview, ...]' Changes: - lib/data/models/movie.dart: Complete rewrite with safe parsing - lib/data/api/neomovies_api_client.dart: Add detailed logging Result: ✅ Safer JSON parsing with null checks ✅ Detailed error logging for debugging ✅ Handles all edge cases from API ✅ Easy to debug gray screen issues via logs Next steps: Test the app and check Flutter debug console for: - API request URLs - Response bodies - Parsing errors (if any) - Successful movie loading messages
2025-10-05 16:34:54 +00:00
releaseDate: parsedDate,
fix: resolve gray screens and add automatic versioning 1. Fix Downloads screen gray screen issue: - Add DownloadsProvider to main.dart providers list - Remove @RoutePage() decorator from DownloadsScreen - Downloads screen now displays torrent list correctly 2. Fix movie detail screen gray screen issue: - Improve Movie.fromJson() with better error handling - Safe parsing of genres field (handles both Map and String formats) - Add fallback 'Untitled' for movies without title - Add detailed logging in MovieDetailProvider - Better error messages with stack traces 3. Add automatic version update from CI/CD tags: - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build - Version format: tag v0.0.18 becomes version 0.0.18+18 - Applies to all build jobs (arm64, arm32, x64) How versioning works: - When you create tag v0.0.18, CI automatically updates pubspec.yaml - Build uses version 0.0.18+18 (version+buildNumber) - APK shows correct version in About screen and Google Play - No manual pubspec.yaml updates needed Example: - Create tag: git tag v0.0.18 && git push origin v0.0.18 - CI reads tag, extracts '0.0.18' - Updates: version: 0.0.18+18 in pubspec.yaml - Builds APK with this version - Release created with proper version number Changes: - lib/main.dart: Add DownloadsProvider - lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage - lib/data/models/movie.dart: Safe JSON parsing with error handling - lib/presentation/providers/movie_detail_provider.dart: Add detailed logging - .gitlab-ci.yml: Add version update script in all build jobs - .github/workflows/release.yml: Add version update step in all build jobs Result: ✅ Downloads screen displays properly ✅ Movie details screen loads correctly ✅ Automatic versioning from tags (0.0.18, 0.0.19, etc.) ✅ No more gray screens!
2025-10-05 16:28:47 +00:00
genres: genresList,
voteAverage: (json['vote_average'] as num?)?.toDouble() ?? 0.0,
popularity: (json['popularity'] as num?)?.toDouble() ?? 0.0,
fix: improve API response parsing with detailed logging Problem: - Gray screens on movie details and downloads - No error messages shown to debug issues - API response structure not fully validated Solution: 1. Enhanced Movie.fromJson() parsing: - Added detailed logging for each parsing step - Safe genre parsing: handles [{id: 18, name: Drama}] - Safe date parsing with null checks - Safe runtime parsing for both movies and TV shows - Better media type detection (movie vs tv) - Comprehensive error logging with stack traces 2. Added detailed API logging: - getMovieById(): Log request URL, response status, body preview - getTvShowById(): Log request URL, response status, body preview - Log API response structure (keys, types, unwrapped data) - Makes debugging much easier 3. Based on backend API structure: Backend returns: {"success": true, "data": {...}} Movie fields from TMDB: - id (number) - title or name (string) - genres: [{"id": int, "name": string}] - release_date or first_air_date (string) - vote_average (number) - runtime or episode_run_time (number/array) - number_of_seasons, number_of_episodes (int, optional) Logging examples: - 'Parsing Movie from JSON: [id, title, genres, ...]' - 'Parsed genres: [Drama, Thriller, Mystery]' - 'Successfully parsed movie: Fight Club' - 'Response status: 200' - 'Movie data keys: [id, title, overview, ...]' Changes: - lib/data/models/movie.dart: Complete rewrite with safe parsing - lib/data/api/neomovies_api_client.dart: Add detailed logging Result: ✅ Safer JSON parsing with null checks ✅ Detailed error logging for debugging ✅ Handles all edge cases from API ✅ Easy to debug gray screen issues via logs Next steps: Test the app and check Flutter debug console for: - API request URLs - Response bodies - Parsing errors (if any) - Successful movie loading messages
2025-10-05 16:34:54 +00:00
runtime: runtimeValue,
fix: resolve gray screens and add automatic versioning 1. Fix Downloads screen gray screen issue: - Add DownloadsProvider to main.dart providers list - Remove @RoutePage() decorator from DownloadsScreen - Downloads screen now displays torrent list correctly 2. Fix movie detail screen gray screen issue: - Improve Movie.fromJson() with better error handling - Safe parsing of genres field (handles both Map and String formats) - Add fallback 'Untitled' for movies without title - Add detailed logging in MovieDetailProvider - Better error messages with stack traces 3. Add automatic version update from CI/CD tags: - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build - Version format: tag v0.0.18 becomes version 0.0.18+18 - Applies to all build jobs (arm64, arm32, x64) How versioning works: - When you create tag v0.0.18, CI automatically updates pubspec.yaml - Build uses version 0.0.18+18 (version+buildNumber) - APK shows correct version in About screen and Google Play - No manual pubspec.yaml updates needed Example: - Create tag: git tag v0.0.18 && git push origin v0.0.18 - CI reads tag, extracts '0.0.18' - Updates: version: 0.0.18+18 in pubspec.yaml - Builds APK with this version - Release created with proper version number Changes: - lib/main.dart: Add DownloadsProvider - lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage - lib/data/models/movie.dart: Safe JSON parsing with error handling - lib/presentation/providers/movie_detail_provider.dart: Add detailed logging - .gitlab-ci.yml: Add version update script in all build jobs - .github/workflows/release.yml: Add version update step in all build jobs Result: ✅ Downloads screen displays properly ✅ Movie details screen loads correctly ✅ Automatic versioning from tags (0.0.18, 0.0.19, etc.) ✅ No more gray screens!
2025-10-05 16:28:47 +00:00
seasonsCount: json['number_of_seasons'] as int?,
episodesCount: json['number_of_episodes'] as int?,
tagline: json['tagline'] as String?,
fix: improve API response parsing with detailed logging Problem: - Gray screens on movie details and downloads - No error messages shown to debug issues - API response structure not fully validated Solution: 1. Enhanced Movie.fromJson() parsing: - Added detailed logging for each parsing step - Safe genre parsing: handles [{id: 18, name: Drama}] - Safe date parsing with null checks - Safe runtime parsing for both movies and TV shows - Better media type detection (movie vs tv) - Comprehensive error logging with stack traces 2. Added detailed API logging: - getMovieById(): Log request URL, response status, body preview - getTvShowById(): Log request URL, response status, body preview - Log API response structure (keys, types, unwrapped data) - Makes debugging much easier 3. Based on backend API structure: Backend returns: {"success": true, "data": {...}} Movie fields from TMDB: - id (number) - title or name (string) - genres: [{"id": int, "name": string}] - release_date or first_air_date (string) - vote_average (number) - runtime or episode_run_time (number/array) - number_of_seasons, number_of_episodes (int, optional) Logging examples: - 'Parsing Movie from JSON: [id, title, genres, ...]' - 'Parsed genres: [Drama, Thriller, Mystery]' - 'Successfully parsed movie: Fight Club' - 'Response status: 200' - 'Movie data keys: [id, title, overview, ...]' Changes: - lib/data/models/movie.dart: Complete rewrite with safe parsing - lib/data/api/neomovies_api_client.dart: Add detailed logging Result: ✅ Safer JSON parsing with null checks ✅ Detailed error logging for debugging ✅ Handles all edge cases from API ✅ Easy to debug gray screen issues via logs Next steps: Test the app and check Flutter debug console for: - API request URLs - Response bodies - Parsing errors (if any) - Successful movie loading messages
2025-10-05 16:34:54 +00:00
mediaType: mediaTypeValue,
fix: resolve gray screens and add automatic versioning 1. Fix Downloads screen gray screen issue: - Add DownloadsProvider to main.dart providers list - Remove @RoutePage() decorator from DownloadsScreen - Downloads screen now displays torrent list correctly 2. Fix movie detail screen gray screen issue: - Improve Movie.fromJson() with better error handling - Safe parsing of genres field (handles both Map and String formats) - Add fallback 'Untitled' for movies without title - Add detailed logging in MovieDetailProvider - Better error messages with stack traces 3. Add automatic version update from CI/CD tags: - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build - Version format: tag v0.0.18 becomes version 0.0.18+18 - Applies to all build jobs (arm64, arm32, x64) How versioning works: - When you create tag v0.0.18, CI automatically updates pubspec.yaml - Build uses version 0.0.18+18 (version+buildNumber) - APK shows correct version in About screen and Google Play - No manual pubspec.yaml updates needed Example: - Create tag: git tag v0.0.18 && git push origin v0.0.18 - CI reads tag, extracts '0.0.18' - Updates: version: 0.0.18+18 in pubspec.yaml - Builds APK with this version - Release created with proper version number Changes: - lib/main.dart: Add DownloadsProvider - lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage - lib/data/models/movie.dart: Safe JSON parsing with error handling - lib/presentation/providers/movie_detail_provider.dart: Add detailed logging - .gitlab-ci.yml: Add version update script in all build jobs - .github/workflows/release.yml: Add version update step in all build jobs Result: ✅ Downloads screen displays properly ✅ Movie details screen loads correctly ✅ Automatic versioning from tags (0.0.18, 0.0.19, etc.) ✅ No more gray screens!
2025-10-05 16:28:47 +00:00
);
fix: improve API response parsing with detailed logging Problem: - Gray screens on movie details and downloads - No error messages shown to debug issues - API response structure not fully validated Solution: 1. Enhanced Movie.fromJson() parsing: - Added detailed logging for each parsing step - Safe genre parsing: handles [{id: 18, name: Drama}] - Safe date parsing with null checks - Safe runtime parsing for both movies and TV shows - Better media type detection (movie vs tv) - Comprehensive error logging with stack traces 2. Added detailed API logging: - getMovieById(): Log request URL, response status, body preview - getTvShowById(): Log request URL, response status, body preview - Log API response structure (keys, types, unwrapped data) - Makes debugging much easier 3. Based on backend API structure: Backend returns: {"success": true, "data": {...}} Movie fields from TMDB: - id (number) - title or name (string) - genres: [{"id": int, "name": string}] - release_date or first_air_date (string) - vote_average (number) - runtime or episode_run_time (number/array) - number_of_seasons, number_of_episodes (int, optional) Logging examples: - 'Parsing Movie from JSON: [id, title, genres, ...]' - 'Parsed genres: [Drama, Thriller, Mystery]' - 'Successfully parsed movie: Fight Club' - 'Response status: 200' - 'Movie data keys: [id, title, overview, ...]' Changes: - lib/data/models/movie.dart: Complete rewrite with safe parsing - lib/data/api/neomovies_api_client.dart: Add detailed logging Result: ✅ Safer JSON parsing with null checks ✅ Detailed error logging for debugging ✅ Handles all edge cases from API ✅ Easy to debug gray screen issues via logs Next steps: Test the app and check Flutter debug console for: - API request URLs - Response bodies - Parsing errors (if any) - Successful movie loading messages
2025-10-05 16:34:54 +00:00
print('Successfully parsed movie: ${movie.title}');
return movie;
} catch (e, stackTrace) {
print('❌ Error parsing Movie from JSON: $e');
print('Stack trace: $stackTrace');
fix: resolve gray screens and add automatic versioning 1. Fix Downloads screen gray screen issue: - Add DownloadsProvider to main.dart providers list - Remove @RoutePage() decorator from DownloadsScreen - Downloads screen now displays torrent list correctly 2. Fix movie detail screen gray screen issue: - Improve Movie.fromJson() with better error handling - Safe parsing of genres field (handles both Map and String formats) - Add fallback 'Untitled' for movies without title - Add detailed logging in MovieDetailProvider - Better error messages with stack traces 3. Add automatic version update from CI/CD tags: - GitLab CI: Update pubspec.yaml version from CI_COMMIT_TAG before build - GitHub Actions: Update pubspec.yaml version from GITHUB_REF before build - Version format: tag v0.0.18 becomes version 0.0.18+18 - Applies to all build jobs (arm64, arm32, x64) How versioning works: - When you create tag v0.0.18, CI automatically updates pubspec.yaml - Build uses version 0.0.18+18 (version+buildNumber) - APK shows correct version in About screen and Google Play - No manual pubspec.yaml updates needed Example: - Create tag: git tag v0.0.18 && git push origin v0.0.18 - CI reads tag, extracts '0.0.18' - Updates: version: 0.0.18+18 in pubspec.yaml - Builds APK with this version - Release created with proper version number Changes: - lib/main.dart: Add DownloadsProvider - lib/presentation/screens/downloads/downloads_screen.dart: Remove @RoutePage - lib/data/models/movie.dart: Safe JSON parsing with error handling - lib/presentation/providers/movie_detail_provider.dart: Add detailed logging - .gitlab-ci.yml: Add version update script in all build jobs - .github/workflows/release.yml: Add version update step in all build jobs Result: ✅ Downloads screen displays properly ✅ Movie details screen loads correctly ✅ Automatic versioning from tags (0.0.18, 0.0.19, etc.) ✅ No more gray screens!
2025-10-05 16:28:47 +00:00
print('JSON data: $json');
rethrow;
}
2025-07-13 14:01:29 +03:00
}
2025-07-19 18:13:13 +03:00
Map<String, dynamic> toJson() => _$MovieToJson(this);
2025-07-13 14:01:29 +03:00
String get fullPosterUrl {
if (posterPath == null || posterPath!.isEmpty) {
// Use API placeholder
final apiUrl = dotenv.env['API_URL'] ?? 'https://api.neomovies.ru';
return '$apiUrl/api/v1/images/w500/placeholder.jpg';
2025-07-13 14:01:29 +03:00
}
// Use NeoMovies API images endpoint instead of TMDB directly
final apiUrl = dotenv.env['API_URL'] ?? 'https://api.neomovies.ru';
2025-07-13 14:01:29 +03:00
final cleanPath = posterPath!.startsWith('/') ? posterPath!.substring(1) : posterPath!;
return '$apiUrl/api/v1/images/w500/$cleanPath';
2025-10-02 21:40:20 +00:00
}
String get fullBackdropUrl {
if (backdropPath == null || backdropPath!.isEmpty) {
// Use API placeholder
final apiUrl = dotenv.env['API_URL'] ?? 'https://api.neomovies.ru';
return '$apiUrl/api/v1/images/w780/placeholder.jpg';
2025-10-02 21:40:20 +00:00
}
// Use NeoMovies API images endpoint instead of TMDB directly
final apiUrl = dotenv.env['API_URL'] ?? 'https://api.neomovies.ru';
2025-10-02 21:40:20 +00:00
final cleanPath = backdropPath!.startsWith('/') ? backdropPath!.substring(1) : backdropPath!;
return '$apiUrl/api/v1/images/w780/$cleanPath';
2025-07-13 14:01:29 +03:00
}
}