diff --git a/src/renderer/api/subsonic/subsonic-controller.ts b/src/renderer/api/subsonic/subsonic-controller.ts index 23a818fa..f80df62e 100644 --- a/src/renderer/api/subsonic/subsonic-controller.ts +++ b/src/renderer/api/subsonic/subsonic-controller.ts @@ -125,7 +125,7 @@ export const SubsonicController: ControllerEndpoint = { } return { - id: res.body.playlist.id, + id: res.body.playlist.id.toString(), name: res.body.playlist.name, }; }, @@ -570,7 +570,10 @@ export const SubsonicController: ControllerEndpoint = { } return { - items: res.body.musicFolders.musicFolder, + items: res.body.musicFolders.musicFolder.map((folder) => ({ + id: folder.id.toString(), + name: folder.name, + })), startIndex: 0, totalRecordCount: res.body.musicFolders.musicFolder.length, }; @@ -902,7 +905,7 @@ export const SubsonicController: ControllerEndpoint = { fromAlbumPromises.push( ssApiClient(apiClientProps).getAlbum({ query: { - id: albumId, + id: albumId.toString(), }, }), ); diff --git a/src/renderer/api/subsonic/subsonic-normalize.ts b/src/renderer/api/subsonic/subsonic-normalize.ts index ca667397..f3cfc2b5 100644 --- a/src/renderer/api/subsonic/subsonic-normalize.ts +++ b/src/renderer/api/subsonic/subsonic-normalize.ts @@ -54,16 +54,16 @@ const normalizeSong = ( album: item.album || '', albumArtists: [ { - id: item.artistId || '', + id: item.artistId?.toString() || '', imageUrl: null, name: item.artist || '', }, ], - albumId: item.albumId || '', + albumId: item.albumId?.toString() || '', artistName: item.artist || '', artists: [ { - id: item.artistId || '', + id: item.artistId?.toString() || '', imageUrl: null, name: item.artist || '', }, @@ -95,7 +95,7 @@ const normalizeSong = ( }, ] : [], - id: item.id, + id: item.id.toString(), imagePlaceholderUrl: null, imageUrl, itemType: LibraryItem.SONG, @@ -146,7 +146,7 @@ const normalizeAlbumArtist = ( biography: null, duration: null, genres: [], - id: item.id, + id: item.id.toString(), imageUrl, itemType: LibraryItem.ALBUM_ARTIST, lastPlayedAt: null, @@ -178,9 +178,11 @@ const normalizeAlbum = ( return { albumArtist: item.artist, albumArtists: item.artistId - ? [{ id: item.artistId, imageUrl: null, name: item.artist }] + ? [{ id: item.artistId.toString(), imageUrl: null, name: item.artist }] + : [], + artists: item.artistId + ? [{ id: item.artistId.toString(), imageUrl: null, name: item.artist }] : [], - artists: item.artistId ? [{ id: item.artistId, imageUrl: null, name: item.artist }] : [], backdropImageUrl: null, comment: null, createdAt: item.created, @@ -195,7 +197,7 @@ const normalizeAlbum = ( }, ] : [], - id: item.id, + id: item.id.toString(), imagePlaceholderUrl: null, imageUrl, isCompilation: null, @@ -232,7 +234,7 @@ const normalizePlaylist = ( description: item.comment || null, duration: item.duration, genres: [], - id: item.id, + id: item.id.toString(), imagePlaceholderUrl: null, imageUrl: getCoverArtUrl({ baseUrl: server?.url, diff --git a/src/renderer/api/subsonic/subsonic-types.ts b/src/renderer/api/subsonic/subsonic-types.ts index 3ac3c81e..d3922d31 100644 --- a/src/renderer/api/subsonic/subsonic-types.ts +++ b/src/renderer/api/subsonic/subsonic-types.ts @@ -19,6 +19,8 @@ const authenticateParameters = z.object({ v: z.string(), }); +const id = z.number().or(z.string()); + const createFavoriteParameters = z.object({ albumId: z.array(z.string()).optional(), artistId: z.array(z.string()).optional(), @@ -43,7 +45,7 @@ const setRatingParameters = z.object({ const setRating = z.null(); const musicFolder = z.object({ - id: z.string(), + id, name: z.string(), }); @@ -66,9 +68,9 @@ const genreItem = z.object({ const song = z.object({ album: z.string().optional(), - albumId: z.string().optional(), + albumId: id.optional(), artist: z.string().optional(), - artistId: z.string().optional(), + artistId: id.optional(), averageRating: z.number().optional(), bitRate: z.number().optional(), bpm: z.number().optional(), @@ -79,7 +81,7 @@ const song = z.object({ duration: z.number().optional(), genre: z.string().optional(), genres: z.array(genreItem).optional(), - id: z.string(), + id, isDir: z.boolean(), isVideo: z.boolean(), musicBrainzId: z.string().optional(), @@ -100,12 +102,12 @@ const song = z.object({ const album = z.object({ album: z.string(), artist: z.string(), - artistId: z.string(), + artistId: id, coverArt: z.string(), created: z.string(), duration: z.number(), genre: z.string().optional(), - id: z.string(), + id, isCompilation: z.boolean().optional(), isDir: z.boolean(), isVideo: z.boolean(), @@ -140,7 +142,7 @@ const albumArtist = z.object({ albumCount: z.string(), artistImageUrl: z.string().optional(), coverArt: z.string().optional(), - id: z.string(), + id, name: z.string(), starred: z.string().optional(), }); @@ -398,7 +400,7 @@ const playlist = z.object({ created: z.string(), duration: z.number(), entry: z.array(song).optional(), - id: z.string(), + id, name: z.string(), owner: z.string(), public: z.boolean(),