mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-09 22:02:19 +02:00
Add internet radio (#1384)
This commit is contained in:
@@ -30,6 +30,14 @@ export const contract = c.router({
|
||||
200: ssType._response.createFavorite,
|
||||
},
|
||||
},
|
||||
createInternetRadioStation: {
|
||||
method: 'GET',
|
||||
path: 'createInternetRadioStation.view',
|
||||
query: ssType._parameters.createInternetRadioStation,
|
||||
responses: {
|
||||
200: ssType._response.createInternetRadioStation,
|
||||
},
|
||||
},
|
||||
createPlaylist: {
|
||||
method: 'GET',
|
||||
path: 'createPlaylist.view',
|
||||
@@ -38,6 +46,14 @@ export const contract = c.router({
|
||||
200: ssType._response.createPlaylist,
|
||||
},
|
||||
},
|
||||
deleteInternetRadioStation: {
|
||||
method: 'GET',
|
||||
path: 'deleteInternetRadioStation.view',
|
||||
query: ssType._parameters.deleteInternetRadioStation,
|
||||
responses: {
|
||||
200: ssType._response.deleteInternetRadioStation,
|
||||
},
|
||||
},
|
||||
deletePlaylist: {
|
||||
method: 'GET',
|
||||
path: 'deletePlaylist.view',
|
||||
@@ -110,6 +126,13 @@ export const contract = c.router({
|
||||
200: ssType._response.getIndexes,
|
||||
},
|
||||
},
|
||||
getInternetRadioStations: {
|
||||
method: 'GET',
|
||||
path: 'getInternetRadioStations.view',
|
||||
responses: {
|
||||
200: ssType._response.getInternetRadioStations,
|
||||
},
|
||||
},
|
||||
getMusicDirectory: {
|
||||
method: 'GET',
|
||||
path: 'getMusicDirectory.view',
|
||||
@@ -281,6 +304,14 @@ export const contract = c.router({
|
||||
200: ssType._response.setRating,
|
||||
},
|
||||
},
|
||||
updateInternetRadioStation: {
|
||||
method: 'GET',
|
||||
path: 'updateInternetRadioStation.view',
|
||||
query: ssType._parameters.updateInternetRadioStation,
|
||||
responses: {
|
||||
200: ssType._response.updateInternetRadioStation,
|
||||
},
|
||||
},
|
||||
updatePlaylist: {
|
||||
method: 'GET',
|
||||
path: 'updatePlaylist.view',
|
||||
|
||||
@@ -166,6 +166,23 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
|
||||
return null;
|
||||
},
|
||||
createInternetRadioStation: async (args) => {
|
||||
const { apiClientProps, body } = args;
|
||||
|
||||
const res = await ssApiClient(apiClientProps).createInternetRadioStation({
|
||||
query: {
|
||||
homepageUrl: body.homepageUrl,
|
||||
name: body.name,
|
||||
streamUrl: body.streamUrl,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Failed to create internet radio station');
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
createPlaylist: async ({ apiClientProps, body }) => {
|
||||
const res = await ssApiClient(apiClientProps).createPlaylist({
|
||||
query: {
|
||||
@@ -199,6 +216,21 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
|
||||
return null;
|
||||
},
|
||||
deleteInternetRadioStation: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
const res = await ssApiClient(apiClientProps).deleteInternetRadioStation({
|
||||
query: {
|
||||
id: query.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Failed to delete internet radio station');
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
deletePlaylist: async (args) => {
|
||||
const { apiClientProps, query } = args;
|
||||
|
||||
@@ -789,6 +821,19 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
startIndex: query.startIndex,
|
||||
});
|
||||
},
|
||||
getInternetRadioStations: async (args) => {
|
||||
const { apiClientProps } = args;
|
||||
|
||||
const res = await ssApiClient(apiClientProps).getInternetRadioStations();
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Failed to get internet radio stations');
|
||||
}
|
||||
|
||||
const stations = res.body.internetRadioStations?.internetRadioStation || [];
|
||||
|
||||
return stations.map((station) => ssNormalize.internetRadioStation(station));
|
||||
},
|
||||
getMusicFolderList: async (args) => {
|
||||
const { apiClientProps } = args;
|
||||
|
||||
@@ -822,6 +867,7 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
|
||||
return ssNormalize.playlist(res.body.playlist, apiClientProps.server);
|
||||
},
|
||||
|
||||
getPlaylistList: async ({ apiClientProps, query }) => {
|
||||
const sortOrder = query.sortOrder.toLowerCase() as 'asc' | 'desc';
|
||||
|
||||
@@ -1005,7 +1051,6 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
final.splice(0, 0, { label: 'all artists', value: '' });
|
||||
return final;
|
||||
},
|
||||
|
||||
getServerInfo: async (args) => {
|
||||
const { apiClientProps } = args;
|
||||
|
||||
@@ -1722,6 +1767,24 @@ export const SubsonicController: InternalControllerEndpoint = {
|
||||
|
||||
return null;
|
||||
},
|
||||
updateInternetRadioStation: async (args) => {
|
||||
const { apiClientProps, body, query } = args;
|
||||
|
||||
const res = await ssApiClient(apiClientProps).updateInternetRadioStation({
|
||||
query: {
|
||||
homepageUrl: body.homepageUrl,
|
||||
id: query.id,
|
||||
name: body.name,
|
||||
streamUrl: body.streamUrl,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Failed to update internet radio station');
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
updatePlaylist: async (args) => {
|
||||
const { apiClientProps, body, query } = args;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user