mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 13:00:13 +02:00
Add internet radio (#1384)
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
ExplicitStatus,
|
||||
Folder,
|
||||
Genre,
|
||||
InternetRadioStation,
|
||||
LibraryItem,
|
||||
Playlist,
|
||||
RelatedArtist,
|
||||
@@ -391,11 +392,23 @@ const normalizeFolder = (
|
||||
};
|
||||
};
|
||||
|
||||
const normalizeInternetRadioStation = (
|
||||
item: z.infer<typeof ssType._response.internetRadioStation>,
|
||||
): InternetRadioStation => {
|
||||
return {
|
||||
homepageUrl: item.homepageUrl || null,
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
streamUrl: item.streamUrl,
|
||||
};
|
||||
};
|
||||
|
||||
export const ssNormalize = {
|
||||
album: normalizeAlbum,
|
||||
albumArtist: normalizeAlbumArtist,
|
||||
folder: normalizeFolder,
|
||||
genre: normalizeGenre,
|
||||
internetRadioStation: normalizeInternetRadioStation,
|
||||
playlist: normalizePlaylist,
|
||||
song: normalizeSong,
|
||||
};
|
||||
|
||||
@@ -654,6 +654,44 @@ const playQueueByIndex = z.object({
|
||||
}),
|
||||
});
|
||||
|
||||
const internetRadioStation = z.object({
|
||||
homepageUrl: z.string().optional(),
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
streamUrl: z.string(),
|
||||
});
|
||||
|
||||
const deleteInternetRadioStationParameters = z.object({
|
||||
id: z.string(),
|
||||
});
|
||||
|
||||
const deleteInternetRadioStation = z.null();
|
||||
|
||||
const createInternetRadioStationParameters = z.object({
|
||||
homepageUrl: z.string().optional(),
|
||||
name: z.string(),
|
||||
streamUrl: z.string(),
|
||||
});
|
||||
|
||||
const createInternetRadioStation = z.null();
|
||||
|
||||
const updateInternetRadioStationParameters = z.object({
|
||||
homepageUrl: z.string().optional(),
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
streamUrl: z.string(),
|
||||
});
|
||||
|
||||
const updateInternetRadioStation = z.null();
|
||||
|
||||
const getInternetRadioStations = z.object({
|
||||
internetRadioStations: z
|
||||
.object({
|
||||
internetRadioStation: z.array(internetRadioStation),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export const ssType = {
|
||||
_parameters: {
|
||||
albumInfo: albumInfoParameters,
|
||||
@@ -661,7 +699,9 @@ export const ssType = {
|
||||
artistInfo: artistInfoParameters,
|
||||
authenticate: authenticateParameters,
|
||||
createFavorite: createFavoriteParameters,
|
||||
createInternetRadioStation: createInternetRadioStationParameters,
|
||||
createPlaylist: createPlaylistParameters,
|
||||
deleteInternetRadioStation: deleteInternetRadioStationParameters,
|
||||
deletePlaylist: deletePlaylistParameters,
|
||||
getAlbum: getAlbumParameters,
|
||||
getAlbumList2: getAlbumList2Parameters,
|
||||
@@ -686,6 +726,7 @@ export const ssType = {
|
||||
similarSongs: similarSongsParameters,
|
||||
structuredLyrics: structuredLyricsParameters,
|
||||
topSongsList: topSongsListParameters,
|
||||
updateInternetRadioStation: updateInternetRadioStationParameters,
|
||||
updatePlaylist: updatePlaylistParameters,
|
||||
user: userParameters,
|
||||
},
|
||||
@@ -701,7 +742,9 @@ export const ssType = {
|
||||
authenticate,
|
||||
baseResponse,
|
||||
createFavorite,
|
||||
createInternetRadioStation,
|
||||
createPlaylist,
|
||||
deleteInternetRadioStation,
|
||||
directory,
|
||||
genre,
|
||||
getAlbum,
|
||||
@@ -710,12 +753,14 @@ export const ssType = {
|
||||
getArtists,
|
||||
getGenres,
|
||||
getIndexes,
|
||||
getInternetRadioStations,
|
||||
getMusicDirectory,
|
||||
getPlaylist,
|
||||
getPlaylists,
|
||||
getSong,
|
||||
getSongsByGenre,
|
||||
getStarred,
|
||||
internetRadioStation,
|
||||
musicFolderList,
|
||||
ping,
|
||||
playlist,
|
||||
@@ -733,6 +778,7 @@ export const ssType = {
|
||||
song,
|
||||
structuredLyrics,
|
||||
topSongsList,
|
||||
updateInternetRadioStation,
|
||||
user,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,7 +12,9 @@ import {
|
||||
AlbumArtistListSort,
|
||||
AlbumListSort,
|
||||
ArtistListSort,
|
||||
InternetRadioStation,
|
||||
LibraryItem,
|
||||
RadioListSort,
|
||||
ServerListItem,
|
||||
Song,
|
||||
SongListSort,
|
||||
@@ -365,6 +367,7 @@ export const sortAlbumArtistList = (
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
export const sortAlbumList = (albums: Album[], sortBy: AlbumListSort, sortOrder: SortOrder) => {
|
||||
let results = albums;
|
||||
|
||||
@@ -414,3 +417,29 @@ export const sortAlbumList = (albums: Album[], sortBy: AlbumListSort, sortOrder:
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
export const sortRadioList = (
|
||||
stations: InternetRadioStation[],
|
||||
sortBy: RadioListSort,
|
||||
sortOrder: SortOrder,
|
||||
) => {
|
||||
let results = stations;
|
||||
|
||||
const order = sortOrder === SortOrder.ASC ? 'asc' : 'desc';
|
||||
|
||||
switch (sortBy) {
|
||||
case RadioListSort.ID:
|
||||
results = [...results];
|
||||
if (order === 'desc') {
|
||||
results.reverse();
|
||||
}
|
||||
break;
|
||||
case RadioListSort.NAME:
|
||||
results = orderBy(results, [(v) => v.name.toLowerCase()], [order]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user