mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 21:50:35 +02:00
Add internet radio (#1384)
This commit is contained in:
@@ -5,6 +5,7 @@ import orderBy from 'lodash/orderBy';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { jfApiClient } from '/@/renderer/api/jellyfin/jellyfin-api';
|
||||
import { useRadioStore } from '/@/renderer/features/radio/store/radio-store';
|
||||
import { jfNormalize } from '/@/shared/api/jellyfin/jellyfin-normalize';
|
||||
import { JFSongListSort, JFSortOrder, jfType } from '/@/shared/api/jellyfin/jellyfin-types';
|
||||
import { getFeatures, hasFeature, sortSongList, VersionInfo } from '/@/shared/api/utils';
|
||||
@@ -115,6 +116,26 @@ export const JellyfinController: InternalControllerEndpoint = {
|
||||
|
||||
return null;
|
||||
},
|
||||
createInternetRadioStation: async (args) => {
|
||||
const { apiClientProps, body } = args;
|
||||
|
||||
if (!apiClientProps.serverId) {
|
||||
throw new Error('No serverId found');
|
||||
}
|
||||
|
||||
const state = useRadioStore.getState();
|
||||
if (!state?.actions?.createStation) {
|
||||
throw new Error('Radio store not initialized');
|
||||
}
|
||||
|
||||
state.actions.createStation(apiClientProps.serverId, {
|
||||
homepageUrl: body.homepageUrl || null,
|
||||
name: body.name,
|
||||
streamUrl: body.streamUrl,
|
||||
});
|
||||
|
||||
return null;
|
||||
},
|
||||
createPlaylist: async (args) => {
|
||||
const { apiClientProps, body } = args;
|
||||
|
||||
@@ -158,6 +179,22 @@ export const JellyfinController: InternalControllerEndpoint = {
|
||||
|
||||
return null;
|
||||
},
|
||||
deleteInternetRadioStation: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
if (!apiClientProps.serverId) {
|
||||
throw new Error('No serverId found');
|
||||
}
|
||||
|
||||
const state = useRadioStore.getState();
|
||||
if (!state?.actions?.deleteStation) {
|
||||
throw new Error('Radio store not initialized');
|
||||
}
|
||||
|
||||
state.actions.deleteStation(apiClientProps.serverId, query.id);
|
||||
|
||||
return null;
|
||||
},
|
||||
deletePlaylist: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
@@ -633,6 +670,20 @@ export const JellyfinController: InternalControllerEndpoint = {
|
||||
totalRecordCount: res.body?.TotalRecordCount || 0,
|
||||
};
|
||||
},
|
||||
getInternetRadioStations: async (args) => {
|
||||
const { apiClientProps } = args;
|
||||
|
||||
if (!apiClientProps.serverId) {
|
||||
throw new Error('No serverId found');
|
||||
}
|
||||
|
||||
const state = useRadioStore.getState();
|
||||
if (!state?.actions?.getStations) {
|
||||
throw new Error('Radio store not initialized');
|
||||
}
|
||||
|
||||
return state.actions.getStations(apiClientProps.serverId);
|
||||
},
|
||||
getLyrics: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
@@ -1455,6 +1506,26 @@ export const JellyfinController: InternalControllerEndpoint = {
|
||||
songs: songs.map((item) => jfNormalize.song(item, apiClientProps.server)),
|
||||
};
|
||||
},
|
||||
updateInternetRadioStation: async (args) => {
|
||||
const { apiClientProps, body, query } = args;
|
||||
|
||||
if (!apiClientProps.serverId) {
|
||||
throw new Error('No serverId found');
|
||||
}
|
||||
|
||||
const state = useRadioStore.getState();
|
||||
if (!state?.actions?.updateStation) {
|
||||
throw new Error('Radio store not initialized');
|
||||
}
|
||||
|
||||
state.actions.updateStation(apiClientProps.serverId, query.id, {
|
||||
homepageUrl: body.homepageUrl || null,
|
||||
name: body.name,
|
||||
streamUrl: body.streamUrl,
|
||||
});
|
||||
|
||||
return null;
|
||||
},
|
||||
updatePlaylist: async (args) => {
|
||||
const { apiClientProps, body, query } = args;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user