Browse Source

Add jf getStarred

master
jeffvli 3 years ago
committed by Jeff
parent
commit
d9fe12505c
  1. 3
      src/api/controller.ts
  2. 32
      src/api/jellyfinApi.ts

3
src/api/controller.ts

@ -41,6 +41,7 @@ import {
getPlaylist as jfGetPlaylist,
getPlaylists as jfGetPlaylists,
getRandomSongs as jfGetRandomSongs,
getStarred as jfGetStarred,
} from './jellyfinApi';
import { APIEndpoints, ServerType } from '../types';
@ -48,7 +49,7 @@ import { APIEndpoints, ServerType } from '../types';
const endpoints = [
{ id: 'getPlaylist', endpoint: { subsonic: getPlaylist, jellyfin: jfGetPlaylist } },
{ id: 'getPlaylists', endpoint: { subsonic: getPlaylists, jellyfin: jfGetPlaylists } },
{ id: 'getStarred', endpoint: { subsonic: getStarred, jellyfin: undefined } },
{ id: 'getStarred', endpoint: { subsonic: getStarred, jellyfin: jfGetStarred } },
{ id: 'getAlbum', endpoint: { subsonic: getAlbum, jellyfin: jfGetAlbum } },
{ id: 'getAlbums', endpoint: { subsonic: getAlbums, jellyfin: jfGetAlbums } },
{ id: 'getRandomSongs', endpoint: { subsonic: getRandomSongs, jellyfin: jfGetRandomSongs } },

32
src/api/jellyfinApi.ts

@ -345,3 +345,35 @@ export const getRandomSongs = async (options: {
return (data.Items || []).map((entry: any) => normalizeSong(entry));
};
export const getStarred = async () => {
const { data: songAndAlbumData } = await jellyfinApi.get(`/users/${auth.username}/items`, {
params: {
fields: 'Genres, DateCreated, MediaSources, ChildCount, UserData',
includeItemTypes: 'MusicAlbum, Audio',
isFavorite: true,
recursive: true,
},
});
const { data: artistData } = await jellyfinApi.get(`/artists`, {
params: {
imageTypeLimit: 1,
recursive: true,
sortBy: 'SortName',
sortOrder: 'Ascending',
isFavorite: true,
userId: auth.username,
},
});
return {
album: (
songAndAlbumData.Items.filter((data: any) => data.Type === 'MusicAlbum') || []
).map((entry: any) => normalizeAlbum(entry)),
song: (
songAndAlbumData.Items.filter((data: any) => data.Type === 'Audio') || []
).map((entry: any) => normalizeSong(entry)),
artist: (artistData.Items || []).map((entry: any) => normalizeArtist(entry)),
};
};

Loading…
Cancel
Save