diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c05227..566de6d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,6 +66,14 @@ jobs: channel: 'stable' cache: true + - name: Update version from tag + if: startsWith(github.ref, 'refs/tags/') + run: | + VERSION_NAME=${GITHUB_REF#refs/tags/v} + BUILD_NUMBER=$(echo $VERSION_NAME | sed 's/[^0-9]//g') + echo "Updating version to $VERSION_NAME+$BUILD_NUMBER" + sed -i "s/^version: .*/version: $VERSION_NAME+$BUILD_NUMBER/" pubspec.yaml + - name: Get dependencies run: flutter pub get diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c04500e..2419d8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,6 +57,15 @@ build:apk:arm64: build:apk:arm: stage: build image: ghcr.io/cirruslabs/flutter:${FLUTTER_VERSION} + before_script: + # Update version from tag if present + - | + if [ -n "$CI_COMMIT_TAG" ]; then + VERSION_NAME="${CI_COMMIT_TAG#v}" + BUILD_NUMBER=$(echo $CI_COMMIT_TAG | sed 's/[^0-9]//g') + echo "Updating version to $VERSION_NAME+$BUILD_NUMBER" + sed -i "s/^version: .*/version: $VERSION_NAME+$BUILD_NUMBER/" pubspec.yaml + fi script: - flutter pub get - mkdir -p debug-symbols diff --git a/lib/data/models/movie.dart b/lib/data/models/movie.dart index 0b73279..d85414d 100644 --- a/lib/data/models/movie.dart +++ b/lib/data/models/movie.dart @@ -67,30 +67,47 @@ class Movie extends HiveObject { }); factory Movie.fromJson(Map json) { - return Movie( - id: (json['id'] as num).toString(), // Ensure id is a string - title: (json['title'] ?? json['name'] ?? '') as String, - posterPath: json['poster_path'] as String?, - backdropPath: json['backdrop_path'] as String?, - overview: json['overview'] as String?, - releaseDate: json['release_date'] != null && json['release_date'].isNotEmpty - ? DateTime.tryParse(json['release_date'] as String) - : json['first_air_date'] != null && json['first_air_date'].isNotEmpty - ? DateTime.tryParse(json['first_air_date'] as String) - : null, - genres: List.from(json['genres']?.map((g) => g['name']) ?? []), - voteAverage: (json['vote_average'] as num?)?.toDouble() ?? 0.0, - popularity: (json['popularity'] as num?)?.toDouble() ?? 0.0, - runtime: json['runtime'] is num - ? (json['runtime'] as num).toInt() - : (json['episode_run_time'] is List && (json['episode_run_time'] as List).isNotEmpty) - ? ((json['episode_run_time'] as List).first as num).toInt() - : null, - seasonsCount: json['number_of_seasons'] as int?, - episodesCount: json['number_of_episodes'] as int?, - tagline: json['tagline'] as String?, - mediaType: (json['media_type'] ?? (json['title'] != null ? 'movie' : 'tv')) as String, - ); + try { + // Parse genres safely + List genresList = []; + if (json['genres'] != null) { + if (json['genres'] is List) { + genresList = (json['genres'] as List) + .map((g) => g is Map ? (g['name'] as String?) ?? '' : g.toString()) + .where((name) => name.isNotEmpty) + .toList(); + } + } + + return Movie( + id: (json['id'] as num).toString(), // Ensure id is a string + 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?, + releaseDate: json['release_date'] != null && json['release_date'].toString().isNotEmpty + ? DateTime.tryParse(json['release_date'].toString()) + : json['first_air_date'] != null && json['first_air_date'].toString().isNotEmpty + ? DateTime.tryParse(json['first_air_date'].toString()) + : null, + genres: genresList, + voteAverage: (json['vote_average'] as num?)?.toDouble() ?? 0.0, + popularity: (json['popularity'] as num?)?.toDouble() ?? 0.0, + runtime: json['runtime'] is num + ? (json['runtime'] as num).toInt() + : (json['episode_run_time'] is List && (json['episode_run_time'] as List).isNotEmpty) + ? ((json['episode_run_time'] as List).first as num).toInt() + : null, + seasonsCount: json['number_of_seasons'] as int?, + episodesCount: json['number_of_episodes'] as int?, + tagline: json['tagline'] as String?, + mediaType: (json['media_type'] ?? (json['title'] != null ? 'movie' : 'tv')) as String, + ); + } catch (e) { + print('Error parsing Movie from JSON: $e'); + print('JSON data: $json'); + rethrow; + } } Map toJson() => _$MovieToJson(this); diff --git a/lib/main.dart b/lib/main.dart index c47db94..e2d0aaa 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,6 +19,7 @@ import 'package:neomovies_mobile/presentation/providers/favorites_provider.dart' import 'package:neomovies_mobile/presentation/providers/home_provider.dart'; import 'package:neomovies_mobile/presentation/providers/movie_detail_provider.dart'; import 'package:neomovies_mobile/presentation/providers/reactions_provider.dart'; +import 'package:neomovies_mobile/presentation/providers/downloads_provider.dart'; import 'package:neomovies_mobile/presentation/screens/main_screen.dart'; import 'package:provider/provider.dart'; diff --git a/lib/presentation/providers/movie_detail_provider.dart b/lib/presentation/providers/movie_detail_provider.dart index c5a351b..1a9cbfb 100644 --- a/lib/presentation/providers/movie_detail_provider.dart +++ b/lib/presentation/providers/movie_detail_provider.dart @@ -33,11 +33,15 @@ class MovieDetailProvider with ChangeNotifier { notifyListeners(); try { + print('Loading media: ID=$mediaId, type=$mediaType'); + // Load movie/TV details if (mediaType == 'movie') { _movie = await _movieRepository.getMovieById(mediaId.toString()); + print('Movie loaded successfully: ${_movie?.title}'); } else { _movie = await _movieRepository.getTvById(mediaId.toString()); + print('TV show loaded successfully: ${_movie?.title}'); } _isLoading = false; @@ -46,15 +50,18 @@ class MovieDetailProvider with ChangeNotifier { // Try to load IMDb ID (non-blocking) if (_movie != null) { try { + print('Loading IMDb ID for $mediaType $mediaId'); _imdbId = await _apiClient.getImdbId(mediaId.toString(), mediaType); + print('IMDb ID loaded: $_imdbId'); } 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, stackTrace) { print('Error loading media: $e'); + print('Stack trace: $stackTrace'); _error = e.toString(); _isLoading = false; notifyListeners(); diff --git a/lib/presentation/screens/downloads/downloads_screen.dart b/lib/presentation/screens/downloads/downloads_screen.dart index 2610b60..58679c9 100644 --- a/lib/presentation/screens/downloads/downloads_screen.dart +++ b/lib/presentation/screens/downloads/downloads_screen.dart @@ -3,9 +3,7 @@ import 'package:provider/provider.dart'; import '../../providers/downloads_provider.dart'; import '../../../data/models/torrent_info.dart'; import 'torrent_detail_screen.dart'; -import 'package:auto_route/auto_route.dart'; -@RoutePage() class DownloadsScreen extends StatefulWidget { const DownloadsScreen({super.key});