handling false negative on success episde marking

This commit is contained in:
tapframe 2026-03-01 10:55:45 +05:30
parent 1c2e9f19d8
commit fd3e793c48

View file

@ -360,9 +360,13 @@ class TraktProgressService @Inject constructor(
traktApi.addHistory(authHeader, body)
} ?: throw IllegalStateException("Trakt request failed")
if (!response.isSuccessful || !hasSuccessfulHistoryAdd(response.body())) {
val responseBody = response.body()
if (!response.isSuccessful || hasHistoryAddNotFound(responseBody)) {
throw IllegalStateException("Failed to mark watched on Trakt (${response.code()})")
}
if (!hasSuccessfulHistoryAdd(responseBody)) {
trace("markAsWatched: Trakt accepted request with no new history rows (code=${response.code()})")
}
if (progress.contentType.equals("movie", ignoreCase = true)) {
setMovieWatchedInCache(progress.contentId, watched = true)
@ -1082,6 +1086,14 @@ class TraktProgressService @Inject constructor(
return addedCount > 0
}
private fun hasHistoryAddNotFound(body: TraktHistoryAddResponseDto?): Boolean {
val notFound = body?.notFound ?: return false
return !notFound.movies.isNullOrEmpty() ||
!notFound.shows.isNullOrEmpty() ||
!notFound.seasons.isNullOrEmpty() ||
!notFound.episodes.isNullOrEmpty()
}
private fun buildHistoryAddRequest(
progress: WatchProgress,
title: String?,