feat(SearchCSDbNG): enhance image fetching by resolving links and updating file extension handling
This commit is contained in:
parent
30c96b8428
commit
588895d851
|
|
@ -175,11 +175,13 @@ export default function SearchCSDbNG({ config, setConfig, onClose }: SearchCSDbN
|
|||
if (release?.ScreenShot?.[0]) {
|
||||
setMountProgress(p => p && { ...p, phase: 'image' });
|
||||
try {
|
||||
const imgRes = await fetch(release.ScreenShot[0]);
|
||||
let imgPath = release.ScreenShot[0];
|
||||
try { imgPath = new URL(imgPath).pathname; } catch { /* already a path */ }
|
||||
const imgRes = await fetch(resolveLink(imgPath));
|
||||
if (imgRes.ok) {
|
||||
const imgData = await imgRes.arrayBuffer();
|
||||
const mainBase = fname.replace(/\.[^.]+$/, '');
|
||||
const imgExt = release.ScreenShot[0].split('.').pop()?.split('?')[0]?.toLowerCase() ?? 'png';
|
||||
const imgExt = imgPath.split('.').pop()?.split('?')[0]?.toLowerCase() ?? 'png';
|
||||
await putFileContents(joinPath(DOWNLOAD_DIR, `${mainBase}.${imgExt}`), imgData);
|
||||
}
|
||||
} catch { /* non-fatal */ }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user