handling false negative on success episde marking
This commit is contained in:
parent
1c2e9f19d8
commit
fd3e793c48
1 changed files with 13 additions and 1 deletions
|
|
@ -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?,
|
||||
|
|
|
|||
Loading…
Reference in a new issue