mirror of
https://github.com/jeffvli/sonixd.git
synced 2026-04-29 02:32:37 -04:00
Add getSongsByGenre endpoint
This commit is contained in:
@@ -199,7 +199,7 @@ const normalizeSong = (item: any) => {
|
||||
discNumber: item.discNumber,
|
||||
created: item.created,
|
||||
streamUrl: getStreamUrl(item.id, legacyAuth),
|
||||
image: getCoverArtUrl(item, legacyAuth, 150),
|
||||
image: getCoverArtUrl(item, legacyAuth, 350),
|
||||
starred: item.starred,
|
||||
userRating: item.userRating,
|
||||
type: Item.Music,
|
||||
@@ -288,7 +288,7 @@ const normalizeFolder = (item: any) => {
|
||||
title: item.name || item.title,
|
||||
created: item.DateCreated,
|
||||
isDir: true,
|
||||
image: getCoverArtUrl(item, legacyAuth, 150),
|
||||
image: getCoverArtUrl(item, legacyAuth, 350),
|
||||
type: Item.Folder,
|
||||
uniqueId: nanoid(),
|
||||
};
|
||||
@@ -565,7 +565,7 @@ export const setRating = async (options: { ids: string[]; rating: number }) => {
|
||||
|
||||
export const getSimilarSongs = async (options: { id: string; count: number }) => {
|
||||
const { data } = await api.get(`/getSimilarSongs2`, { params: options });
|
||||
return (_.uniqBy(data.similarSongs2.song, (e: any) => e.id) || []).map((entry: any) =>
|
||||
return (_.uniqBy(data?.similarSongs2?.song, (e: any) => e.id) || []).map((entry: any) =>
|
||||
normalizeSong(entry)
|
||||
);
|
||||
};
|
||||
@@ -577,6 +577,18 @@ export const getTopSongs = async (options: { artist: string; count: number }) =>
|
||||
);
|
||||
};
|
||||
|
||||
export const getSongsByGenre = async (options: {
|
||||
genre: string;
|
||||
count: number;
|
||||
offset: number;
|
||||
musicFolderId?: string | number;
|
||||
}) => {
|
||||
const { data } = await api.get(`/getSongsByGenre`, { params: options });
|
||||
return (_.uniqBy(data?.songsByGenre?.song, (e: any) => e.id) || []).map((entry: any) =>
|
||||
normalizeSong(entry)
|
||||
);
|
||||
};
|
||||
|
||||
export const updatePlaylistSongs = async (options: { id: string; entry: any[] }) => {
|
||||
const playlistParams = new URLSearchParams();
|
||||
const songIds = _.map(options.entry, 'id');
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
getSearch,
|
||||
getSimilarSongs,
|
||||
getTopSongs,
|
||||
getSongsByGenre,
|
||||
getStarred,
|
||||
scrobble,
|
||||
setRating,
|
||||
@@ -95,6 +96,7 @@ const endpoints = [
|
||||
{ id: 'getDownloadUrl', endpoint: { subsonic: getDownloadUrl, jellyfin: jfGetDownloadUrl } },
|
||||
{ id: 'getSongs', endpoint: { subsonic: undefined, jellyfin: jfGetSongs } },
|
||||
{ id: 'getTopSongs', endpoint: { subsonic: getTopSongs, jellyfin: undefined } },
|
||||
{ id: 'getSongsByGenre', endpoint: { subsonic: getSongsByGenre, jellyfin: jfGetSongs } },
|
||||
|
||||
// Playlist handling logic is split up by server type due to differences in how each server handles them.
|
||||
// You will need to add custom logic in the playlist/context menu component handlers.
|
||||
|
||||
@@ -52,7 +52,8 @@ export type APIEndpoints =
|
||||
| 'getMusicDirectorySongs'
|
||||
| 'getDownloadUrl'
|
||||
| 'getSongs'
|
||||
| 'getTopSongs';
|
||||
| 'getTopSongs'
|
||||
| 'getSongsByGenre';
|
||||
|
||||
export interface GenericItem {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user