mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
Support album and artist detail pages for subsonic
This commit is contained in:
@@ -333,6 +333,7 @@ const getAlbumList = async (args: AlbumListArgs): Promise<AlbumListResponse> =>
|
|||||||
AlbumArtistIds: query.artistIds
|
AlbumArtistIds: query.artistIds
|
||||||
? formatCommaDelimitedString(query.artistIds)
|
? formatCommaDelimitedString(query.artistIds)
|
||||||
: undefined,
|
: undefined,
|
||||||
|
ContributingArtistIds: query.isCompilation ? query.artistIds?.[0] : undefined,
|
||||||
IncludeItemTypes: 'MusicAlbum',
|
IncludeItemTypes: 'MusicAlbum',
|
||||||
Limit: query.limit,
|
Limit: query.limit,
|
||||||
ParentId: query.musicFolderId,
|
ParentId: query.musicFolderId,
|
||||||
|
|||||||
@@ -233,6 +233,8 @@ const getAlbumList = async (args: AlbumListArgs): Promise<AlbumListResponse> =>
|
|||||||
_sort: albumListSortMap.navidrome[query.sortBy],
|
_sort: albumListSortMap.navidrome[query.sortBy],
|
||||||
_start: query.startIndex,
|
_start: query.startIndex,
|
||||||
artist_id: query.artistIds?.[0],
|
artist_id: query.artistIds?.[0],
|
||||||
|
compilation: query.isCompilation,
|
||||||
|
genre_id: query.genre,
|
||||||
name: query.searchTerm,
|
name: query.searchTerm,
|
||||||
...query._custom?.navidrome,
|
...query._custom?.navidrome,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -332,6 +332,45 @@ export const SubsonicController: ControllerEndpoint = {
|
|||||||
[AlbumListSort.SONG_COUNT]: undefined,
|
[AlbumListSort.SONG_COUNT]: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (query.isCompilation) {
|
||||||
|
return {
|
||||||
|
items: [],
|
||||||
|
startIndex: 0,
|
||||||
|
totalRecordCount: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.artistIds) {
|
||||||
|
const promises = [];
|
||||||
|
|
||||||
|
for (const artistId of query.artistIds) {
|
||||||
|
promises.push(
|
||||||
|
subsonicApiClient(apiClientProps).getArtist({
|
||||||
|
query: {
|
||||||
|
id: artistId,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const artistResult = await Promise.all(promises);
|
||||||
|
|
||||||
|
const albums = artistResult.flatMap((artist) => {
|
||||||
|
if (artist.status !== 200) {
|
||||||
|
fsLog.warn('Failed to get artist detail', { context: { artist } });
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return artist.body['subsonic-response'].artist.album;
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
items: albums.map((album) => subsonicNormalize.album(album, apiClientProps.server)),
|
||||||
|
startIndex: 0,
|
||||||
|
totalRecordCount: albums.length,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const res = await subsonicApiClient(apiClientProps).getAlbumList2({
|
const res = await subsonicApiClient(apiClientProps).getAlbumList2({
|
||||||
query: {
|
query: {
|
||||||
fromYear: query.minYear,
|
fromYear: query.minYear,
|
||||||
|
|||||||
@@ -377,6 +377,7 @@ export type AlbumListQuery = {
|
|||||||
};
|
};
|
||||||
artistIds?: string[];
|
artistIds?: string[];
|
||||||
genre?: string;
|
genre?: string;
|
||||||
|
isCompilation?: boolean;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
maxYear?: number;
|
maxYear?: number;
|
||||||
minYear?: number;
|
minYear?: number;
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ export const AlbumArtistDetailContent = ({ background }: AlbumArtistDetailConten
|
|||||||
: undefined),
|
: undefined),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
artistIds: [albumArtistId],
|
||||||
limit: 15,
|
limit: 15,
|
||||||
sortBy: AlbumListSort.RELEASE_DATE,
|
sortBy: AlbumListSort.RELEASE_DATE,
|
||||||
sortOrder: SortOrder.DESC,
|
sortOrder: SortOrder.DESC,
|
||||||
@@ -122,6 +123,8 @@ export const AlbumArtistDetailContent = ({ background }: AlbumArtistDetailConten
|
|||||||
: undefined),
|
: undefined),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
artistIds: [albumArtistId],
|
||||||
|
isCompilation: true,
|
||||||
limit: 15,
|
limit: 15,
|
||||||
sortBy: AlbumListSort.RELEASE_DATE,
|
sortBy: AlbumListSort.RELEASE_DATE,
|
||||||
sortOrder: SortOrder.DESC,
|
sortOrder: SortOrder.DESC,
|
||||||
|
|||||||
Reference in New Issue
Block a user