mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-16 23:12:12 +00:00
fix: add shouldSyncToTraktHistory method to prevent sending whole season marked to trakt while marking ep
This commit is contained in:
parent
5e65881716
commit
cbbe65aab3
1 changed files with 15 additions and 13 deletions
|
|
@ -107,6 +107,8 @@ object TraktWatchedSyncAdapter : WatchedSyncAdapter {
|
|||
val shows = mutableListOf<TraktHistoryShowRequestDto>()
|
||||
|
||||
items.forEach { item ->
|
||||
if (!item.shouldSyncToTraktHistory()) return@forEach
|
||||
|
||||
val ids = parseIds(item.id) ?: return@forEach
|
||||
val normalizedType = item.type.trim().lowercase()
|
||||
|
||||
|
|
@ -161,16 +163,11 @@ object TraktWatchedSyncAdapter : WatchedSyncAdapter {
|
|||
),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// Series-level mark (no season/episode) → mark entire show
|
||||
shows += TraktHistoryShowRequestDto(
|
||||
title = item.name.takeIf { it.isNotBlank() },
|
||||
year = parseYear(item.releaseInfo),
|
||||
ids = ids,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (movies.isEmpty() && shows.isEmpty()) return
|
||||
|
||||
val body = json.encodeToString(
|
||||
TraktHistoryAddRequestDto(
|
||||
movies = movies.takeIf { it.isNotEmpty() },
|
||||
|
|
@ -202,6 +199,8 @@ object TraktWatchedSyncAdapter : WatchedSyncAdapter {
|
|||
val shows = mutableListOf<TraktHistoryShowRequestDto>()
|
||||
|
||||
items.forEach { item ->
|
||||
if (!item.shouldSyncToTraktHistory()) return@forEach
|
||||
|
||||
val ids = parseIds(item.id) ?: return@forEach
|
||||
val normalizedType = item.type.trim().lowercase()
|
||||
|
||||
|
|
@ -225,15 +224,11 @@ object TraktWatchedSyncAdapter : WatchedSyncAdapter {
|
|||
),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
shows += TraktHistoryShowRequestDto(
|
||||
title = item.name.takeIf { it.isNotBlank() },
|
||||
year = parseYear(item.releaseInfo),
|
||||
ids = ids,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (movies.isEmpty() && shows.isEmpty()) return
|
||||
|
||||
val body = json.encodeToString(
|
||||
TraktHistoryRemoveRequestDto(
|
||||
movies = movies.takeIf { it.isNotEmpty() },
|
||||
|
|
@ -348,6 +343,13 @@ object TraktWatchedSyncAdapter : WatchedSyncAdapter {
|
|||
private fun Int.pad4(): String = "$this".padStart(4, '0')
|
||||
}
|
||||
|
||||
internal fun WatchedItem.shouldSyncToTraktHistory(): Boolean {
|
||||
val normalizedType = type.trim().lowercase()
|
||||
return normalizedType == "movie" ||
|
||||
normalizedType == "film" ||
|
||||
(season != null && episode != null)
|
||||
}
|
||||
|
||||
// ── DTOs for pull (GET /sync/watched) ───────────────────────────────────
|
||||
|
||||
@Serializable
|
||||
|
|
|
|||
Loading…
Reference in a new issue