Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud and Trakt: do not skip adding a movie if download fails #1097

Merged
merged 5 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Releases marked with 🧪 (or previously with the "beta" suffix) were released o

## Next release

* 🔨 Movies: when connecting Cloud or Trakt, movies might not have been added if downloading them
failed. Any missing movies will be added on the next sync.
* 🔨 Movies: prefer translated title when viewing details.
* 📝 Devices running Android 5.0 and 5.1 will receive no more updates in the future.
* 📝 Import latest user interface translations.

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/battlelancer/seriesguide/SgApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class SgApp : Application() {

const val RELEASE_VERSION_2024_3_5 = 21240305

const val RELEASE_VERSION_2025_1_1 = 21250102

/**
* The content authority used to identify the SeriesGuide [android.content.ContentProvider].
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,13 @@ object HexagonSettings {
}
}

fun getLastMoviesSyncTime(context: Context): Long {
return getLastSyncTime(context, KEY_LAST_SYNC_MOVIES)
fun getLastMoviesSyncTime(context: Context): Long? {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
if (!prefs.contains(KEY_LAST_SYNC_MOVIES)) return null
return prefs.getLong(
KEY_LAST_SYNC_MOVIES,
0 /* Never returned, returning null above if it does not exist */
)
}

fun setLastMoviesSyncTime(context: Context, timeInMs: Long) {
Expand All @@ -222,6 +227,15 @@ object HexagonSettings {
}
}

/**
* Sets [getLastMoviesSyncTime] so that all movies are downloaded on the next sync.
*/
fun resetLastMoviesSyncTime(context: Context) {
PreferenceManager.getDefaultSharedPreferences(context).edit {
remove(KEY_LAST_SYNC_MOVIES)
}
}

fun getLastListsSyncTime(context: Context): Long {
return getLastSyncTime(context, KEY_LAST_SYNC_LISTS)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2023 Uwe Trottmann
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020-2025 Uwe Trottmann

package com.battlelancer.seriesguide.movies

Expand All @@ -11,6 +11,7 @@ import com.battlelancer.seriesguide.provider.SgRoomDatabase.Companion.getInstanc
import com.uwetrottmann.androidutils.GenericSimpleLoader
import com.uwetrottmann.tmdb2.entities.Movie
import com.uwetrottmann.trakt5.entities.Ratings
import kotlinx.coroutines.runBlocking

/**
* Tries to load current movie details from trakt and TMDb, if failing tries to fall back to local
Expand All @@ -24,7 +25,10 @@ internal class MovieLoader(
override fun loadInBackground(): MovieDetails {
// try loading from trakt and tmdb, this might return a cached response
val movieTools = getServicesComponent(context).movieTools()
val details = movieTools.getMovieDetails(tmdbId, true)
// No need to handle InterruptedException as ModernAsyncTask does (see its constructor)
val details = runBlocking {
movieTools.getMovieDetailsWithDefaults(tmdbId, true).movieDetails
}

// Update local database (no-op if movie not in database).
movieTools.updateMovie(details, tmdbId)
Expand Down
Loading