mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
fix trakt syncing watched shows/movies back to trakt's recent history
This commit is contained in:
parent
2da03d4931
commit
a079649563
1 changed files with 50 additions and 25 deletions
|
|
@ -559,15 +559,23 @@ export function useTraktIntegration() {
|
||||||
return undefined;
|
return undefined;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
updatePromises.push(
|
// Merge with local progress
|
||||||
storageService.mergeWithTraktProgress(
|
await storageService.mergeWithTraktProgress(
|
||||||
id,
|
id,
|
||||||
type,
|
type,
|
||||||
item.progress,
|
item.progress,
|
||||||
item.paused_at,
|
item.paused_at,
|
||||||
episodeId,
|
episodeId,
|
||||||
exactTime
|
exactTime
|
||||||
)
|
);
|
||||||
|
|
||||||
|
// FIX: Mark as already synced so it won't be re-uploaded to Trakt
|
||||||
|
await storageService.updateTraktSyncStatus(
|
||||||
|
id,
|
||||||
|
type,
|
||||||
|
true, // synced = true
|
||||||
|
item.progress,
|
||||||
|
episodeId
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[useTraktIntegration] Error preparing Trakt progress update:', error);
|
logger.error('[useTraktIntegration] Error preparing Trakt progress update:', error);
|
||||||
|
|
@ -581,19 +589,27 @@ export function useTraktIntegration() {
|
||||||
const id = movie.movie.ids.imdb;
|
const id = movie.movie.ids.imdb;
|
||||||
const watchedAt = movie.last_watched_at;
|
const watchedAt = movie.last_watched_at;
|
||||||
|
|
||||||
updatePromises.push(
|
await storageService.mergeWithTraktProgress(
|
||||||
storageService.mergeWithTraktProgress(
|
id,
|
||||||
id,
|
'movie',
|
||||||
'movie',
|
100,
|
||||||
100, // 100% progress for watched items
|
watchedAt
|
||||||
watchedAt
|
);
|
||||||
)
|
|
||||||
|
// FIX: Mark as already synced
|
||||||
|
await storageService.updateTraktSyncStatus(
|
||||||
|
id,
|
||||||
|
'movie',
|
||||||
|
true,
|
||||||
|
100
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[useTraktIntegration] Error preparing watched movie update:', error);
|
logger.error('[useTraktIntegration] Error preparing watched movie update:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process watched shows (100% completed episodes)
|
||||||
for (const show of watchedShows) {
|
for (const show of watchedShows) {
|
||||||
try {
|
try {
|
||||||
if (show.show?.ids?.imdb && show.seasons) {
|
if (show.show?.ids?.imdb && show.seasons) {
|
||||||
|
|
@ -602,14 +618,22 @@ export function useTraktIntegration() {
|
||||||
for (const season of show.seasons) {
|
for (const season of show.seasons) {
|
||||||
for (const episode of season.episodes) {
|
for (const episode of season.episodes) {
|
||||||
const episodeId = `${showImdbId}:${season.number}:${episode.number}`;
|
const episodeId = `${showImdbId}:${season.number}:${episode.number}`;
|
||||||
updatePromises.push(
|
|
||||||
storageService.mergeWithTraktProgress(
|
await storageService.mergeWithTraktProgress(
|
||||||
showImdbId,
|
showImdbId,
|
||||||
'series',
|
'series',
|
||||||
100,
|
100,
|
||||||
episode.last_watched_at,
|
episode.last_watched_at,
|
||||||
episodeId
|
episodeId
|
||||||
)
|
);
|
||||||
|
|
||||||
|
// FIX: Mark as already synced
|
||||||
|
await storageService.updateTraktSyncStatus(
|
||||||
|
showImdbId,
|
||||||
|
'series',
|
||||||
|
true,
|
||||||
|
100,
|
||||||
|
episodeId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -618,6 +642,7 @@ export function useTraktIntegration() {
|
||||||
logger.error('[useTraktIntegration] Error preparing watched show update:', error);
|
logger.error('[useTraktIntegration] Error preparing watched show update:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute all updates in parallel
|
// Execute all updates in parallel
|
||||||
await Promise.all(updatePromises);
|
await Promise.all(updatePromises);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue