mirror of
https://github.com/antebudimir/feishin.git
synced 2026-03-02 12:17:25 +00:00
Add update playlist for jellyfin
This commit is contained in:
parent
0ed13c75af
commit
633c9f59d9
5 changed files with 74 additions and 18 deletions
|
|
@ -96,7 +96,7 @@ const endpoints: ApiController = {
|
|||
getPlaylistSongList: jellyfinApi.getPlaylistSongList,
|
||||
getSongDetail: undefined,
|
||||
getSongList: jellyfinApi.getSongList,
|
||||
updatePlaylist: undefined,
|
||||
updatePlaylist: jellyfinApi.updatePlaylist,
|
||||
updateRating: undefined,
|
||||
},
|
||||
navidrome: {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ import {
|
|||
artistListSortMap,
|
||||
sortOrderMap,
|
||||
albumArtistListSortMap,
|
||||
UpdatePlaylistArgs,
|
||||
UpdatePlaylistResponse,
|
||||
} from '/@/renderer/api/types';
|
||||
import { useAuthStore } from '/@/renderer/store';
|
||||
import { ServerListItem, ServerType } from '/@/renderer/types';
|
||||
|
|
@ -312,9 +314,6 @@ const getSongList = async (args: SongListArgs): Promise<JFSongList> => {
|
|||
}
|
||||
}
|
||||
|
||||
console.log('yearsGroup :>> ', yearsGroup);
|
||||
console.log('albumIds', query.albumIds);
|
||||
console.log('artistIds :>> ', query.artistIds);
|
||||
const yearsFilter = yearsGroup.length ? getCommaDelimitedString(yearsGroup) : undefined;
|
||||
const albumIdsFilter = query.albumIds ? getCommaDelimitedString(query.albumIds) : undefined;
|
||||
const artistIdsFilter = query.artistIds ? getCommaDelimitedString(query.artistIds) : undefined;
|
||||
|
|
@ -457,6 +456,33 @@ const createPlaylist = async (args: CreatePlaylistArgs): Promise<CreatePlaylistR
|
|||
};
|
||||
};
|
||||
|
||||
const updatePlaylist = async (args: UpdatePlaylistArgs): Promise<UpdatePlaylistResponse> => {
|
||||
const { query, body, server } = args;
|
||||
|
||||
const json = {
|
||||
Genres: body.genres?.map((item) => ({ Id: item.id, Name: item.name })) || [],
|
||||
MediaType: 'Audio',
|
||||
Name: body.name,
|
||||
Overview: body.comment || '',
|
||||
PremiereDate: null,
|
||||
ProviderIds: {},
|
||||
Tags: [],
|
||||
UserId: server?.userId, // Required
|
||||
};
|
||||
|
||||
await api
|
||||
.post(`items/${query.id}`, {
|
||||
headers: { 'X-MediaBrowser-Token': server?.credential },
|
||||
json,
|
||||
prefixUrl: server?.url,
|
||||
})
|
||||
.json<null>();
|
||||
|
||||
return {
|
||||
id: query.id,
|
||||
};
|
||||
};
|
||||
|
||||
const deletePlaylist = async (args: DeletePlaylistArgs): Promise<null> => {
|
||||
const { query, server } = args;
|
||||
|
||||
|
|
@ -728,10 +754,11 @@ const normalizePlaylist = (
|
|||
|
||||
return {
|
||||
description: item.Overview || null,
|
||||
duration: item.RunTimeTicks / 10000000,
|
||||
duration: item.RunTimeTicks / 10000,
|
||||
genres: item.GenreItems?.map((entry) => ({ id: entry.Id, name: entry.Name })),
|
||||
id: item.Id,
|
||||
imagePlaceholderUrl,
|
||||
imageUrl,
|
||||
imageUrl: imageUrl || null,
|
||||
name: item.Name,
|
||||
public: null,
|
||||
rules: null,
|
||||
|
|
@ -809,6 +836,7 @@ export const jellyfinApi = {
|
|||
getPlaylistList,
|
||||
getPlaylistSongList,
|
||||
getSongList,
|
||||
updatePlaylist,
|
||||
};
|
||||
|
||||
export const jfNormalize = {
|
||||
|
|
|
|||
|
|
@ -578,6 +578,7 @@ const normalizePlaylist = (
|
|||
return {
|
||||
description: item.comment,
|
||||
duration: item.duration * 1000,
|
||||
genres: [],
|
||||
id: item.id,
|
||||
imagePlaceholderUrl,
|
||||
imageUrl,
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ export type MusicFolder = {
|
|||
export type Playlist = {
|
||||
description: string | null;
|
||||
duration: number | null;
|
||||
genres: Genre[];
|
||||
id: string;
|
||||
imagePlaceholderUrl: string | null;
|
||||
imageUrl: string | null;
|
||||
|
|
@ -758,6 +759,7 @@ export type UpdatePlaylistQuery = {
|
|||
|
||||
export type UpdatePlaylistBody = {
|
||||
comment?: string;
|
||||
genres?: Genre[];
|
||||
name: string;
|
||||
public?: boolean;
|
||||
rules?: Record<string, any>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue