mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
refactor Genre domain type to include serverType and serverId
This commit is contained in:
@@ -370,7 +370,7 @@ export const NavidromeController: InternalControllerEndpoint = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: res.body.data.map((genre) => ndNormalize.genre(genre)),
|
items: res.body.data.map((genre) => ndNormalize.genre(genre, apiClientProps.server)),
|
||||||
startIndex: query.startIndex || 0,
|
startIndex: query.startIndex || 0,
|
||||||
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
totalRecordCount: Number(res.body.headers.get('x-total-count') || 0),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -647,7 +647,7 @@ export const SubsonicController: InternalControllerEndpoint = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const genres = results.map(ssNormalize.genre);
|
const genres = results.map((genre) => ssNormalize.genre(genre, apiClientProps.server));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: genres,
|
items: genres,
|
||||||
|
|||||||
@@ -504,6 +504,8 @@ const normalizeGenre = (
|
|||||||
server: null | ServerListItem,
|
server: null | ServerListItem,
|
||||||
): Genre => {
|
): Genre => {
|
||||||
return {
|
return {
|
||||||
|
_serverId: server?.id || '',
|
||||||
|
_serverType: ServerType.JELLYFIN,
|
||||||
albumCount: undefined,
|
albumCount: undefined,
|
||||||
id: item.Id,
|
id: item.Id,
|
||||||
imageUrl: getGenreCoverArtUrl({ baseUrl: server?.url || '', item, size: 200 }),
|
imageUrl: getGenreCoverArtUrl({ baseUrl: server?.url || '', item, size: 200 }),
|
||||||
|
|||||||
@@ -430,8 +430,13 @@ const normalizePlaylist = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeGenre = (item: z.infer<typeof ndType._response.genre>): Genre => {
|
const normalizeGenre = (
|
||||||
|
item: z.infer<typeof ndType._response.genre>,
|
||||||
|
server: null | ServerListItem,
|
||||||
|
): Genre => {
|
||||||
return {
|
return {
|
||||||
|
_serverId: server?.id || 'unknown',
|
||||||
|
_serverType: ServerType.NAVIDROME,
|
||||||
albumCount: undefined,
|
albumCount: undefined,
|
||||||
id: item.id,
|
id: item.id,
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
|
|||||||
@@ -94,9 +94,12 @@ const getGenres = (
|
|||||||
| z.infer<typeof ssType._response.album>
|
| z.infer<typeof ssType._response.album>
|
||||||
| z.infer<typeof ssType._response.albumListEntry>
|
| z.infer<typeof ssType._response.albumListEntry>
|
||||||
| z.infer<typeof ssType._response.song>,
|
| z.infer<typeof ssType._response.song>,
|
||||||
|
server?: null | ServerListItemWithCredential,
|
||||||
): Genre[] => {
|
): Genre[] => {
|
||||||
return item.genres
|
return item.genres
|
||||||
? item.genres.map((genre) => ({
|
? item.genres.map((genre) => ({
|
||||||
|
_serverId: server?.id || 'unknown',
|
||||||
|
_serverType: ServerType.SUBSONIC,
|
||||||
id: genre.name,
|
id: genre.name,
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
itemType: LibraryItem.GENRE,
|
itemType: LibraryItem.GENRE,
|
||||||
@@ -105,6 +108,8 @@ const getGenres = (
|
|||||||
: item.genre
|
: item.genre
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
|
_serverId: server?.id || 'unknown',
|
||||||
|
_serverType: ServerType.SUBSONIC,
|
||||||
id: item.genre,
|
id: item.genre,
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
itemType: LibraryItem.GENRE,
|
itemType: LibraryItem.GENRE,
|
||||||
@@ -161,7 +166,7 @@ const normalizeSong = (
|
|||||||
track: item.replayGain.trackGain,
|
track: item.replayGain.trackGain,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
genres: getGenres(item),
|
genres: getGenres(item, server),
|
||||||
id: item.id.toString(),
|
id: item.id.toString(),
|
||||||
imagePlaceholderUrl: null,
|
imagePlaceholderUrl: null,
|
||||||
imageUrl,
|
imageUrl,
|
||||||
@@ -260,7 +265,7 @@ const normalizeAlbum = (
|
|||||||
: item.explicitStatus === 'clean'
|
: item.explicitStatus === 'clean'
|
||||||
? ExplicitStatus.CLEAN
|
? ExplicitStatus.CLEAN
|
||||||
: null,
|
: null,
|
||||||
genres: getGenres(item),
|
genres: getGenres(item, server),
|
||||||
id: item.id.toString(),
|
id: item.id.toString(),
|
||||||
imagePlaceholderUrl: null,
|
imagePlaceholderUrl: null,
|
||||||
imageUrl,
|
imageUrl,
|
||||||
@@ -320,8 +325,13 @@ const normalizePlaylist = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeGenre = (item: z.infer<typeof ssType._response.genre>): Genre => {
|
const normalizeGenre = (
|
||||||
|
item: z.infer<typeof ssType._response.genre>,
|
||||||
|
server: null | ServerListItemWithCredential,
|
||||||
|
): Genre => {
|
||||||
return {
|
return {
|
||||||
|
_serverId: server?.id || 'unknown',
|
||||||
|
_serverType: ServerType.SUBSONIC,
|
||||||
albumCount: item.albumCount,
|
albumCount: item.albumCount,
|
||||||
id: item.value,
|
id: item.value,
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
|
|||||||
@@ -262,6 +262,8 @@ export type GainInfo = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type Genre = {
|
export type Genre = {
|
||||||
|
_serverId: string;
|
||||||
|
_serverType: ServerType;
|
||||||
albumCount?: number;
|
albumCount?: number;
|
||||||
id: string;
|
id: string;
|
||||||
imageUrl: null | string;
|
imageUrl: null | string;
|
||||||
|
|||||||
Reference in New Issue
Block a user