Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "SimpleMediaBrowser",
"owner": "kallb123",
"slug": "SimpleMediaBrowser",
"version": "1.12.0",
"version": "1.12.1",
"orientation": "default",
"icon": "./assets/images/icon.png",
"scheme": "simplemediabrowser",
Expand All @@ -20,7 +20,7 @@
},
"predictiveBackGestureEnabled": false,
"package": "net.nawt.simplemediabrowser",
"versionCode": 47
"versionCode": 48
},
"web": {
"output": "static",
Expand Down
38 changes: 32 additions & 6 deletions src/app/edititem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ async function downloadPoster(cacheKey: string, posterPath: string): Promise<str
*/
async function downloadTvdbPoster(tvdbId: string, fullUrl: string): Promise<string> {
ensurePostersTvdbDir();
const safeName = tvdbId.replace(/[^a-zA-Z0-9_-]/g, '_');
// Include a URL-derived suffix so that different poster selections for the same
// TVDB ID are cached as separate files instead of colliding on the same key.
const urlKey = (fullUrl.split('/').pop() ?? 'poster')
.replace(/\.[^.]+$/, '')
.replace(/[^a-zA-Z0-9_-]/g, '_');
const safeName = `${tvdbId.replace(/[^a-zA-Z0-9_-]/g, '_')}_${urlKey}`;
const localFile = new File(POSTERS_TVDB_DIR, `${safeName}.jpg`);
if (localFile.exists) {
return localFile.uri;
Expand Down Expand Up @@ -146,7 +151,7 @@ export default function EditItemScreen() {
return mediaLibrary[showName]?.poster ?? '';
} else if (itemType === 'movie') {
const path = itemKey.replace(/^movie:/, '');
return movies.find((m) => m.path === path)?.poster ?? '';
return movies.find((m) => m.parsedPath === path)?.poster ?? '';
}
return '';
})();
Expand Down Expand Up @@ -503,8 +508,8 @@ export default function EditItemScreen() {
};

/**
* Apply a TMDB match — updates the metadata ID and re-enriches episodes (for
* shows). Does NOT change the poster.
* Apply a TMDB match — updates the metadata ID, downloads the poster, and
* re-enriches episodes (for shows).
*/
const handleApplyTmdbRematch = async (result: TmdbResult) => {
setRematchApplying(true);
Expand All @@ -526,6 +531,17 @@ export default function EditItemScreen() {
}
}

// Download and apply the poster from the matched result.
if (result.poster_path) {
try {
const cacheKey = result.poster_path.replace(/^\//, '').replace(/\.[^.]+$/, '');
const localPosterUri = await downloadPoster(cacheKey, result.poster_path);
applyPoster(localPosterUri);
} catch (e) {
logger.warn('EditItem', 'Failed to download poster during TMDB rematch', e);
}
}

setRematchApplied(result.id);
logger.log('EditItem', `TMDB rematch applied: ID ${tmdbId}, year=${year}`);

Expand All @@ -551,8 +567,8 @@ export default function EditItemScreen() {
};

/**
* Apply a TVDB match — updates the metadata ID and re-enriches episodes (for
* shows). Does NOT change the poster.
* Apply a TVDB match — updates the metadata ID, downloads the poster, and
* re-enriches episodes (for shows).
*/
const handleApplyTvdbRematch = async (result: ProviderShowResult) => {
setRematchApplying(true);
Expand All @@ -575,6 +591,16 @@ export default function EditItemScreen() {
override: { tvdbId, year, metadataSourceOverride: 'tvdb' },
}));

// Download and apply the poster from the matched result.
if (result.posterUrl) {
try {
const localPosterUri = await downloadTvdbPoster(tvdbId, result.posterUrl);
applyPoster(localPosterUri);
} catch (e) {
logger.warn('EditItem', 'Failed to download poster during TVDB rematch', e);
}
}

setTvdbRematchApplied(result.id);
logger.log('EditItem', `TVDB rematch applied: ID ${tvdbId}, year=${year}`);

Expand Down
Loading