fix(server/api/jellyfin.ts): use /Library/VirtualFolders Jellyfin API call to fetch Jellyfin libs

use /Library/VirtualFolders Jellyfin API call to fetch Jellyfin libraries, instead of relying on
user's view

fix #256
This commit is contained in:
Ethan Armbrust
2023-08-10 18:10:29 -04:00
parent acc230fd20
commit 8685f5796a

View File

@@ -171,28 +171,25 @@ class JellyfinAPI {
public async getLibraries(): Promise<JellyfinLibrary[]> { public async getLibraries(): Promise<JellyfinLibrary[]> {
try { try {
const account = await this.axios.get<any>( const libraries = await this.axios.get<any>('/Library/VirtualFolders');
`/Users/${this.userId ?? 'Me'}/Views`
);
const response: JellyfinLibrary[] = account.data.Items.filter( const response: JellyfinLibrary[] = libraries.data
(Item: any) => { .filter((Item: any) => {
return ( return (
Item.Type === 'CollectionFolder' &&
Item.CollectionType !== 'music' && Item.CollectionType !== 'music' &&
Item.CollectionType !== 'books' && Item.CollectionType !== 'books' &&
Item.CollectionType !== 'musicvideos' && Item.CollectionType !== 'musicvideos' &&
Item.CollectionType !== 'homevideos' Item.CollectionType !== 'homevideos'
); );
} })
).map((Item: any) => { .map((Item: any) => {
return <JellyfinLibrary>{ return <JellyfinLibrary>{
key: Item.Id, key: Item.ItemId,
title: Item.Name, title: Item.Name,
type: Item.CollectionType === 'movies' ? 'movie' : 'show', type: Item.CollectionType === 'movies' ? 'movie' : 'show',
agent: 'jellyfin', agent: 'jellyfin',
}; };
}); });
return response; return response;
} catch (e) { } catch (e) {