Skip to content

Commit 2b80207

Browse files
authored
Merge pull request #331 from chrisk325/main
fixed tmdb enrichment logic , fixed trakt not syncing watch progress for old seasons
2 parents a794e27 + 0d416f7 commit 2b80207

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

src/hooks/useFeaturedContent.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ export function useFeaturedContent() {
114114
};
115115

116116
try {
117+
if (base.logo && !isTmdbUrl(base.logo)) {
118+
return base;
119+
}
120+
117121
if (!settings.enrichMetadataWithTMDB) {
118122
return { ...base, logo: base.logo || undefined };
119123
}
@@ -150,6 +154,7 @@ export function useFeaturedContent() {
150154
id: item.id,
151155
type: item.type,
152156
name: item.name,
157+
addonId: item.addonId,
153158
poster: item.poster,
154159
banner: (item as any).banner,
155160
logo: (item as any).logo || undefined,

src/hooks/useMetadata.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,8 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
857857

858858
finalMetadata = {
859859
...finalMetadata,
860-
name: localized.title || finalMetadata.name,
861-
description: localized.overview || finalMetadata.description,
860+
name: finalMetadata.name || localized.title,
861+
description: finalMetadata.description || localized.overview,
862862
movieDetails: movieDetailsObj,
863863
...(productionInfo.length > 0 && { networks: productionInfo }),
864864
};
@@ -894,8 +894,8 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
894894

895895
finalMetadata = {
896896
...finalMetadata,
897-
name: localized.name || finalMetadata.name,
898-
description: localized.overview || finalMetadata.description,
897+
name: finalMetadata.name || localized.name,
898+
description: finalMetadata.description || localized.overview,
899899
tvDetails,
900900
...(productionInfo.length > 0 && { networks: productionInfo }),
901901
};
@@ -970,7 +970,7 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
970970
}
971971

972972
// Clear banner field if TMDB banner enrichment is enabled to prevent flash
973-
if (settings.enrichMetadataWithTMDB && settings.tmdbEnrichBanners) {
973+
if (settings.enrichMetadataWithTMDB && settings.tmdbEnrichBanners && !finalMetadata.banner) {
974974
finalMetadata = {
975975
...finalMetadata,
976976
banner: undefined, // Let useMetadataAssets handle banner via TMDB

src/hooks/useMetadataAssets.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,17 @@ export const useMetadataAssets = (
177177
// Only update if request wasn't aborted and component is still mounted
178178
if (!isMountedRef.current) return;
179179

180-
if (details?.backdrop_path) {
180+
if (metadata?.banner) {
181+
finalBanner = metadata.banner;
182+
bannerSourceType = 'default';
183+
} else if (details?.backdrop_path) {
181184
finalBanner = tmdbService.getImageUrl(details.backdrop_path);
182185
bannerSourceType = 'tmdb';
183-
184-
// Preload the image
185186
if (finalBanner) {
186187
FastImage.preload([{ uri: finalBanner }]);
187188
}
188189
} else {
189-
// TMDB has no backdrop, gracefully fall back
190-
finalBanner = metadata?.banner || bannerImage || null;
190+
finalBanner = bannerImage || null;
191191
bannerSourceType = 'default';
192192
}
193193
} catch (error) {
@@ -269,4 +269,4 @@ export const useMetadataAssets = (
269269
logoLoadError: false,
270270
setLogoLoadError: () => { },
271271
};
272-
};
272+
};

src/hooks/useTraktIntegration.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,10 @@ export function useTraktIntegration() {
521521

522522
try {
523523
// Fetch both playback progress and recently watched movies
524-
const [traktProgress, watchedMovies] = await Promise.all([
524+
const [traktProgress, watchedMovies, watchedShows] = await Promise.all([
525525
getTraktPlaybackProgress(),
526526
traktService.getWatchedMovies()
527+
traktService.getWatchedShows()
527528
]);
528529

529530
// Progress retrieval logging removed
@@ -593,6 +594,28 @@ export function useTraktIntegration() {
593594
logger.error('[useTraktIntegration] Error preparing watched movie update:', error);
594595
}
595596
}
597+
for (const show of watchedShows) {
598+
try {
599+
if (show.show?.ids?.imdb && show.seasons) {
600+
const showImdbId = show.show.ids.imdb;
601+
602+
for (const season of show.seasons) {
603+
for (const episode of season.episodes) {
604+
const episodeId = `${showImdbId}:${season.number}:${episode.number}`;
605+
updatePromises.push(
606+
storageService.mergeWithTraktProgress(
607+
showImdbId,
608+
'series',
609+
100,
610+
episode.last_watched_at,
611+
episodeId
612+
)
613+
);
614+
}
615+
}
616+
}
617+
} catch (error) {
618+
logger.error('[useTraktIntegration] Error preparing watched show update:', error);
596619

597620
// Execute all updates in parallel
598621
await Promise.all(updatePromises);
@@ -698,4 +721,4 @@ export function useTraktIntegration() {
698721
isInWatchlist,
699722
isInCollection
700723
};
701-
}
724+
}

src/screens/streams/useStreamsScreen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ export const useStreamsScreen = () => {
410410
episodeId: (type === 'series' || type === 'other') && selectedEpisode ? selectedEpisode : undefined,
411411
imdbId: imdbId || undefined,
412412
availableStreams: streamsToPass,
413-
backdrop: bannerImage || metadata?.banner,
413+
backdrop: metadata?.banner || bannerImage,
414414
videoType,
415415
} as any);
416416
},

0 commit comments

Comments
 (0)