add Navidrome/Jellyfin image cache invalidation

This commit is contained in:
Kendall Garner 2025-09-24 08:05:22 -07:00
parent eea36f720a
commit 2feef206fb
No known key found for this signature in database
GPG key ID: 9355F387FE765C94
3 changed files with 13 additions and 2 deletions

View file

@ -88,7 +88,8 @@ const getSongCoverArtUrl = (args: {
`/${args.item.Id}` +
'/Images/Primary' +
`?width=${size}` +
'&quality=96'
'&quality=96' +
`&tag=${args.item.ImageTags.Primary}`
);
}

View file

@ -30,6 +30,7 @@ const getCoverArtUrl = (args: {
coverArtId: string;
credential: string | undefined;
size: number;
updated: string;
}) => {
const size = args.size ? args.size : 250;
@ -43,7 +44,10 @@ const getCoverArtUrl = (args: {
`&${args.credential}` +
'&v=1.13.0' +
'&c=Feishin' +
`&size=${size}`
`&size=${size}` +
// A dummy variable to invalidate the cached image if the item is updated
// This is adapted from how Navidrome web does it
`&_=${args.updated}`
);
};
@ -140,6 +144,7 @@ const normalizeSong = (
coverArtId: id,
credential: server?.credential,
size: imageSize || 100,
updated: item.updatedAt,
});
const imagePlaceholderUrl = null;
@ -216,6 +221,7 @@ const normalizeAlbum = (
coverArtId: item.coverArtId || item.id,
credential: server?.credential,
size: imageSize || 300,
updated: item.updatedAt,
});
const imagePlaceholderUrl = null;
@ -282,6 +288,7 @@ const normalizeAlbumArtist = (
coverArtId: `ar-${item.id}`,
credential: server?.credential,
size: 300,
updated: item.updatedAt || '',
});
}
@ -344,6 +351,7 @@ const normalizePlaylist = (
coverArtId: item.id,
credential: server?.credential,
size: imageSize || 300,
updated: item.updatedAt,
});
const imagePlaceholderUrl = null;

View file

@ -80,6 +80,7 @@ const stats = z.object({
const albumArtist = z.object({
albumCount: z.number(),
biography: z.string(),
createdAt: z.string().optional(),
externalInfoUpdatedAt: z.string(),
externalUrl: z.string(),
fullText: z.string(),
@ -99,6 +100,7 @@ const albumArtist = z.object({
starred: z.boolean(),
starredAt: z.string(),
stats: z.record(z.string(), stats).optional(),
updatedAt: z.string().optional(),
});
const albumArtistList = z.array(albumArtist);