mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-13 20:10:07 +02:00
support navidrome artist image upload/delete
This commit is contained in:
@@ -18,14 +18,20 @@ import {
|
||||
} from '/@/shared/types/domain-types';
|
||||
import { ServerListItem, ServerType } from '/@/shared/types/types';
|
||||
|
||||
const getImageUrl = (args: { url: null | string }) => {
|
||||
const { url } = args;
|
||||
if (url === '/app/artist-placeholder.webp') {
|
||||
return null;
|
||||
}
|
||||
// const getImageUrl = (args: { url: null | string }) => {
|
||||
// const { url } = args;
|
||||
// if (url === '/app/artist-placeholder.webp') {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
return url;
|
||||
};
|
||||
// return url;
|
||||
// };
|
||||
|
||||
const navidromeImageIdWithCacheBust = (
|
||||
id: string,
|
||||
uploadedImage: string | undefined,
|
||||
updatedAt: string | undefined,
|
||||
): string => (!uploadedImage ? id : `${id}&_=${updatedAt ?? ''}`);
|
||||
|
||||
interface WithDate {
|
||||
playDate?: string;
|
||||
@@ -397,7 +403,7 @@ const normalizeAlbumArtist = (
|
||||
},
|
||||
server?: null | ServerListItem,
|
||||
): AlbumArtist => {
|
||||
const imageUrl = getImageUrl({ url: item?.largeImageUrl?.replace(/\?size=\d+/, '') || null });
|
||||
// const imageUrl = getImageUrl({ url: item?.largeImageUrl?.replace(/\?size=\d+/, '') || null });
|
||||
|
||||
let albumCount: number;
|
||||
let songCount: number;
|
||||
@@ -416,6 +422,12 @@ const normalizeAlbumArtist = (
|
||||
songCount = item.songCount;
|
||||
}
|
||||
|
||||
const imageId = navidromeImageIdWithCacheBust(
|
||||
item.id,
|
||||
item.uploadedImage,
|
||||
item.updatedAt ?? item.externalInfoUpdatedAt,
|
||||
);
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.ALBUM_ARTIST,
|
||||
_serverId: server?.id || 'unknown',
|
||||
@@ -435,8 +447,8 @@ const normalizeAlbumArtist = (
|
||||
songCount: null,
|
||||
})),
|
||||
id: item.id,
|
||||
imageId: item.id,
|
||||
imageUrl: imageUrl || null,
|
||||
imageId,
|
||||
imageUrl: null,
|
||||
lastPlayedAt: normalizePlayDate(item),
|
||||
mbz: item.mbzArtistId || null,
|
||||
name: item.name,
|
||||
@@ -451,6 +463,7 @@ const normalizeAlbumArtist = (
|
||||
userRating: artist.userRating || null,
|
||||
})) || [],
|
||||
songCount,
|
||||
uploadedImage: item.uploadedImage,
|
||||
userFavorite: item.starred || false,
|
||||
userRating: item.rating || null,
|
||||
};
|
||||
@@ -460,7 +473,7 @@ const normalizePlaylist = (
|
||||
item: z.infer<typeof ndType._response.playlist>,
|
||||
server?: null | ServerListItem,
|
||||
): Playlist => {
|
||||
const imageId = !item.uploadedImage ? item.id : `${item.id}&_=${item.updatedAt}`;
|
||||
const imageId = navidromeImageIdWithCacheBust(item.id, item.uploadedImage, item.updatedAt);
|
||||
|
||||
return {
|
||||
_itemType: LibraryItem.PLAYLIST,
|
||||
@@ -517,7 +530,7 @@ const normalizeInternetRadioStation = (
|
||||
item: z.infer<typeof ndType._response.radioStation>,
|
||||
): InternetRadioStation => {
|
||||
const homepageUrl = item.homePageUrl?.trim() ? item.homePageUrl : null;
|
||||
const imageId = item.uploadedImage ? `${item.id}&_=${item.updatedAt}` : item.id;
|
||||
const imageId = navidromeImageIdWithCacheBust(item.id, item.uploadedImage, item.updatedAt);
|
||||
|
||||
return {
|
||||
homepageUrl,
|
||||
|
||||
@@ -428,6 +428,7 @@ const albumArtist = z.object({
|
||||
starredAt: z.string(),
|
||||
stats: z.record(z.string(), stats).optional(),
|
||||
updatedAt: z.string().optional(),
|
||||
uploadedImage: z.string().optional(),
|
||||
});
|
||||
|
||||
const albumArtistList = z.array(albumArtist);
|
||||
@@ -683,6 +684,9 @@ const deletePlaylistImage = z.object({
|
||||
|
||||
const uploadInternetRadioStationImage = uploadPlaylistImage;
|
||||
const uploadInternetRadioStationImageParameters = uploadPlaylistImageParameters;
|
||||
const uploadArtistImage = uploadPlaylistImage;
|
||||
const uploadArtistImageParameters = uploadPlaylistImageParameters;
|
||||
const deleteArtistImage = deletePlaylistImage;
|
||||
const deleteInternetRadioStationImage = deletePlaylistImage;
|
||||
|
||||
const deletePlaylist = z.null();
|
||||
@@ -813,6 +817,7 @@ export const ndType = {
|
||||
tagList: tagListParameters,
|
||||
updateInternetRadioStation: updateInternetRadioStationParameters,
|
||||
updatePlaylist: updatePlaylistParameters,
|
||||
uploadArtistImage: uploadArtistImageParameters,
|
||||
uploadInternetRadioStationImage: uploadInternetRadioStationImageParameters,
|
||||
uploadPlaylistImage: uploadPlaylistImageParameters,
|
||||
userList: userListParameters,
|
||||
@@ -825,6 +830,7 @@ export const ndType = {
|
||||
albumList,
|
||||
authenticate,
|
||||
createPlaylist,
|
||||
deleteArtistImage,
|
||||
deleteInternetRadioStation,
|
||||
deleteInternetRadioStationImage,
|
||||
deletePlaylist,
|
||||
@@ -848,6 +854,7 @@ export const ndType = {
|
||||
tagList,
|
||||
updateInternetRadioStation,
|
||||
updatePlaylist,
|
||||
uploadArtistImage,
|
||||
uploadInternetRadioStationImage,
|
||||
uploadPlaylistImage,
|
||||
user,
|
||||
|
||||
@@ -225,6 +225,7 @@ export type AlbumArtist = {
|
||||
playCount: null | number;
|
||||
similarArtists: null | RelatedArtist[];
|
||||
songCount: null | number;
|
||||
uploadedImage?: string;
|
||||
userFavorite: boolean;
|
||||
userRating: null | number;
|
||||
};
|
||||
@@ -957,6 +958,16 @@ export type CreatePlaylistBody = {
|
||||
// Create Playlist
|
||||
export type CreatePlaylistResponse = undefined | { id: string };
|
||||
|
||||
export type DeleteArtistImageArgs = BaseEndpointArgs & {
|
||||
query: DeleteArtistImageQuery;
|
||||
};
|
||||
|
||||
export type DeleteArtistImageQuery = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type DeleteArtistImageResponse = boolean;
|
||||
|
||||
export type DeleteInternetRadioStationArgs = BaseEndpointArgs & {
|
||||
query: DeleteInternetRadioStationQuery;
|
||||
};
|
||||
@@ -1132,6 +1143,21 @@ export type UpdatePlaylistQuery = {
|
||||
// Update Playlist
|
||||
export type UpdatePlaylistResponse = null | undefined;
|
||||
|
||||
export type UploadArtistImageArgs = BaseEndpointArgs & {
|
||||
body: UploadArtistImageBody;
|
||||
query: UploadArtistImageQuery;
|
||||
};
|
||||
|
||||
export type UploadArtistImageBody = {
|
||||
image: Uint8Array;
|
||||
};
|
||||
|
||||
export type UploadArtistImageQuery = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type UploadArtistImageResponse = boolean;
|
||||
|
||||
export type UploadInternetRadioStationImageArgs = BaseEndpointArgs & {
|
||||
body: UploadInternetRadioStationImageBody;
|
||||
query: UploadInternetRadioStationImageQuery;
|
||||
@@ -1441,6 +1467,7 @@ export type ControllerEndpoint = {
|
||||
args: CreateInternetRadioStationArgs,
|
||||
) => Promise<CreateInternetRadioStationResponse>;
|
||||
createPlaylist: (args: CreatePlaylistArgs) => Promise<CreatePlaylistResponse>;
|
||||
deleteArtistImage?: (args: DeleteArtistImageArgs) => Promise<DeleteArtistImageResponse>;
|
||||
deleteFavorite: (args: FavoriteArgs) => Promise<FavoriteResponse>;
|
||||
deleteInternetRadioStation: (
|
||||
args: DeleteInternetRadioStationArgs,
|
||||
@@ -1503,6 +1530,7 @@ export type ControllerEndpoint = {
|
||||
args: UpdateInternetRadioStationArgs,
|
||||
) => Promise<UpdateInternetRadioStationResponse>;
|
||||
updatePlaylist: (args: UpdatePlaylistArgs) => Promise<UpdatePlaylistResponse>;
|
||||
uploadArtistImage?: (args: UploadArtistImageArgs) => Promise<UploadArtistImageResponse>;
|
||||
uploadInternetRadioStationImage?: (
|
||||
args: UploadInternetRadioStationImageArgs,
|
||||
) => Promise<UploadInternetRadioStationImageResponse>;
|
||||
@@ -1572,6 +1600,9 @@ export type InternalControllerEndpoint = {
|
||||
createPlaylist: (
|
||||
args: ReplaceApiClientProps<CreatePlaylistArgs>,
|
||||
) => Promise<CreatePlaylistResponse>;
|
||||
deleteArtistImage?: (
|
||||
args: ReplaceApiClientProps<DeleteArtistImageArgs>,
|
||||
) => Promise<DeleteArtistImageResponse>;
|
||||
deleteFavorite: (args: ReplaceApiClientProps<FavoriteArgs>) => Promise<FavoriteResponse>;
|
||||
deleteInternetRadioStation: (
|
||||
args: ReplaceApiClientProps<DeleteInternetRadioStationArgs>,
|
||||
@@ -1669,6 +1700,9 @@ export type InternalControllerEndpoint = {
|
||||
updatePlaylist: (
|
||||
args: ReplaceApiClientProps<UpdatePlaylistArgs>,
|
||||
) => Promise<UpdatePlaylistResponse>;
|
||||
uploadArtistImage?: (
|
||||
args: ReplaceApiClientProps<UploadArtistImageArgs>,
|
||||
) => Promise<UploadArtistImageResponse>;
|
||||
uploadInternetRadioStationImage?: (
|
||||
args: ReplaceApiClientProps<UploadInternetRadioStationImageArgs>,
|
||||
) => Promise<UploadInternetRadioStationImageResponse>;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// For example: <FEATURE GROUP>: "Playlists", <FEATURE NAME>: "Smart" = "PLAYLISTS_SMART"
|
||||
export enum ServerFeature {
|
||||
ALBUM_YES_NO_RATING_FILTER = 'albumYesNoRatingFilter',
|
||||
ARTIST_IMAGE_UPLOAD = 'artistImageUpload',
|
||||
BFR = 'bfr',
|
||||
INTERNET_RADIO_IMAGE_UPLOAD = 'internetRadioImageUpload',
|
||||
LYRICS_MULTIPLE_STRUCTURED = 'lyricsMultipleStructured',
|
||||
|
||||
Reference in New Issue
Block a user