mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 08:41:57 +00:00
redo how trakt marks stuff as watched to local
This commit is contained in:
parent
e323906083
commit
4603d1dc2a
1 changed files with 44 additions and 36 deletions
|
|
@ -301,52 +301,60 @@ class WatchedService {
|
||||||
* Check if a movie is marked as watched (locally)
|
* Check if a movie is marked as watched (locally)
|
||||||
*/
|
*/
|
||||||
public async isMovieWatched(imdbId: string): Promise<boolean> {
|
public async isMovieWatched(imdbId: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
// First check local watched flag
|
const isAuthed = await this.traktService.isAuthenticated();
|
||||||
const localWatched = await mmkvStorage.getItem(`watched:movie:${imdbId}`);
|
|
||||||
if (localWatched === 'true') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check local progress
|
if (isAuthed) {
|
||||||
const progress = await storageService.getWatchProgress(imdbId, 'movie');
|
const traktWatched =
|
||||||
if (progress) {
|
await this.traktService.isMovieWatchedAccurate(imdbId);
|
||||||
const progressPercent = (progress.currentTime / progress.duration) * 100;
|
if (traktWatched) return true;
|
||||||
if (progressPercent >= 85) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('[WatchedService] Error checking movie watched status:', error);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const local = await mmkvStorage.getItem(`watched:movie:${imdbId}`);
|
||||||
|
return local === 'true';
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an episode is marked as watched (locally)
|
* Check if an episode is marked as watched (locally)
|
||||||
*/
|
*/
|
||||||
public async isEpisodeWatched(showId: string, season: number, episode: number): Promise<boolean> {
|
public async isEpisodeWatched(
|
||||||
try {
|
showId: string,
|
||||||
const episodeId = `${showId}:${season}:${episode}`;
|
season: number,
|
||||||
|
episode: number
|
||||||
|
): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
const isAuthed = await this.traktService.isAuthenticated();
|
||||||
|
|
||||||
// Check local progress
|
if (isAuthed) {
|
||||||
const progress = await storageService.getWatchProgress(showId, 'series', episodeId);
|
const traktWatched =
|
||||||
if (progress) {
|
await this.traktService.isEpisodeWatchedAccurate(
|
||||||
const progressPercent = (progress.currentTime / progress.duration) * 100;
|
showId,
|
||||||
if (progressPercent >= 85) {
|
season,
|
||||||
return true;
|
episode
|
||||||
}
|
);
|
||||||
}
|
if (traktWatched) return true;
|
||||||
|
|
||||||
return false;
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('[WatchedService] Error checking episode watched status:', error);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
const episodeId = `${showId}:${season}:${episode}`;
|
||||||
|
const progress = await storageService.getWatchProgress(
|
||||||
|
showId,
|
||||||
|
'series',
|
||||||
|
episodeId
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!progress) return false;
|
||||||
|
|
||||||
|
const pct = (progress.currentTime / progress.duration) * 100;
|
||||||
|
return pct >= 99;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set local watched status by creating a "completed" progress entry
|
* Set local watched status by creating a "completed" progress entry
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue