Adjust jellyfin playlist fetch

This commit is contained in:
jeffvli 2023-08-24 18:04:01 -07:00
parent 877b2e9f3b
commit a8bd53b757

View file

@ -529,6 +529,20 @@ const getPlaylistList = async (args: PlaylistListArgs): Promise<PlaylistListResp
throw new Error('No userId found');
}
const musicFoldersRes = await jfApiClient(apiClientProps).getMusicFolderList({
params: {
userId: apiClientProps.server?.userId,
},
});
if (musicFoldersRes.status !== 200) {
throw new Error('Failed playlist folder');
}
const playlistFolder = musicFoldersRes.body.Items.filter(
(folder) => folder.CollectionType === jfType._enum.collection.PLAYLISTS,
)?.[0];
const res = await jfApiClient(apiClientProps).getPlaylistList({
params: {
userId: apiClientProps.server?.userId,
@ -537,8 +551,7 @@ const getPlaylistList = async (args: PlaylistListArgs): Promise<PlaylistListResp
Fields: 'ChildCount, Genres, DateCreated, ParentId, Overview',
IncludeItemTypes: 'Playlist',
Limit: query.limit,
MediaTypes: 'Audio',
Recursive: true,
ParentId: playlistFolder?.Id,
SearchTerm: query.searchTerm,
SortBy: playlistListSortMap.jellyfin[query.sortBy],
SortOrder: sortOrderMap.jellyfin[query.sortOrder],