Merge branch 'jeffvli:development' into development

This commit is contained in:
Penelope Gwen 2025-01-24 11:32:23 -08:00 committed by GitHub
commit 8996d58c08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 24 additions and 27 deletions

View file

@ -41,7 +41,7 @@ const getCoverArtUrl = (args: {
`?id=${args.coverArtId}` + `?id=${args.coverArtId}` +
`&${args.credential}` + `&${args.credential}` +
'&v=1.13.0' + '&v=1.13.0' +
'&c=feishin' + '&c=Feishin' +
`&size=${size}` `&size=${size}`
); );
}; };
@ -57,7 +57,6 @@ const normalizePlayDate = (item: WithDate): string | null => {
const normalizeSong = ( const normalizeSong = (
item: z.infer<typeof ndType._response.song> | z.infer<typeof ndType._response.playlistSong>, item: z.infer<typeof ndType._response.song> | z.infer<typeof ndType._response.playlistSong>,
server: ServerListItem | null, server: ServerListItem | null,
deviceId: string,
imageSize?: number, imageSize?: number,
): Song => { ): Song => {
let id; let id;
@ -127,7 +126,7 @@ const normalizeSong = (
serverId: server?.id || 'unknown', serverId: server?.id || 'unknown',
serverType: ServerType.NAVIDROME, serverType: ServerType.NAVIDROME,
size: item.size, size: item.size,
streamUrl: `${server?.url}/rest/stream.view?id=${id}&v=1.13.0&c=feishin_${deviceId}&${server?.credential}`, streamUrl: `${server?.url}/rest/stream.view?id=${id}&v=1.13.0&c=Feishin&${server?.credential}`,
trackNumber: item.trackNumber, trackNumber: item.trackNumber,
uniqueId: nanoid(), uniqueId: nanoid(),
updatedAt: item.updatedAt, updatedAt: item.updatedAt,
@ -191,7 +190,7 @@ const normalizeAlbum = (
serverType: ServerType.NAVIDROME, serverType: ServerType.NAVIDROME,
size: item.size, size: item.size,
songCount: item.songCount, songCount: item.songCount,
songs: item.songs ? item.songs.map((song) => normalizeSong(song, server, '')) : undefined, songs: item.songs ? item.songs.map((song) => normalizeSong(song, server)) : undefined,
uniqueId: nanoid(), uniqueId: nanoid(),
updatedAt: item.updatedAt, updatedAt: item.updatedAt,
userFavorite: item.starred, userFavorite: item.starred,

View file

@ -255,7 +255,7 @@ axiosClient.interceptors.response.use(
const parsePath = (fullPath: string) => { const parsePath = (fullPath: string) => {
const [path, params] = fullPath.split('?'); const [path, params] = fullPath.split('?');
const parsedParams = qs.parse(params); const parsedParams = qs.parse(params, { arrayLimit: 99999, parameterLimit: 99999 });
const notNilParams = omitBy(parsedParams, (value) => value === 'undefined' || value === 'null'); const notNilParams = omitBy(parsedParams, (value) => value === 'undefined' || value === 'null');
return { return {

View file

@ -73,6 +73,7 @@ export const SubsonicController: ControllerEndpoint = {
} else { } else {
const salt = randomString(12); const salt = randomString(12);
const hash = md5(body.password + salt); const hash = md5(body.password + salt);
credential = `u=${encodeURIComponent(body.username)}&s=${encodeURIComponent(salt)}&t=${encodeURIComponent(hash)}`; credential = `u=${encodeURIComponent(body.username)}&s=${encodeURIComponent(salt)}&t=${encodeURIComponent(hash)}`;
credentialParams = { credentialParams = {
s: salt, s: salt,
@ -522,7 +523,7 @@ export const SubsonicController: ControllerEndpoint = {
`?id=${query.id}` + `?id=${query.id}` +
`&${apiClientProps.server?.credential}` + `&${apiClientProps.server?.credential}` +
'&v=1.13.0' + '&v=1.13.0' +
'&c=feishin' '&c=Feishin'
); );
}, },
getGenreList: async ({ query, apiClientProps }) => { getGenreList: async ({ query, apiClientProps }) => {
@ -672,9 +673,8 @@ export const SubsonicController: ControllerEndpoint = {
} }
let results = let results =
res.body.playlist.entry?.map((song) => res.body.playlist.entry?.map((song) => ssNormalize.song(song, apiClientProps.server)) ||
ssNormalize.song(song, apiClientProps.server, ''), [];
) || [];
if (query.sortBy && query.sortOrder) { if (query.sortBy && query.sortOrder) {
results = sortSongList(results, query.sortBy, query.sortOrder); results = sortSongList(results, query.sortBy, query.sortOrder);
@ -706,7 +706,7 @@ export const SubsonicController: ControllerEndpoint = {
const results = res.body.randomSongs?.song || []; const results = res.body.randomSongs?.song || [];
return { return {
items: results.map((song) => ssNormalize.song(song, apiClientProps.server, '')), items: results.map((song) => ssNormalize.song(song, apiClientProps.server)),
startIndex: 0, startIndex: 0,
totalRecordCount: res.body.randomSongs?.song?.length || 0, totalRecordCount: res.body.randomSongs?.song?.length || 0,
}; };
@ -765,7 +765,7 @@ export const SubsonicController: ControllerEndpoint = {
return res.body.similarSongs.song.reduce<Song[]>((acc, song) => { return res.body.similarSongs.song.reduce<Song[]>((acc, song) => {
if (song.id !== query.songId) { if (song.id !== query.songId) {
acc.push(ssNormalize.song(song, apiClientProps.server, '')); acc.push(ssNormalize.song(song, apiClientProps.server));
} }
return acc; return acc;
@ -784,7 +784,7 @@ export const SubsonicController: ControllerEndpoint = {
throw new Error('Failed to get song detail'); throw new Error('Failed to get song detail');
} }
return ssNormalize.song(res.body.song, apiClientProps.server, ''); return ssNormalize.song(res.body.song, apiClientProps.server);
}, },
getSongList: async ({ query, apiClientProps }) => { getSongList: async ({ query, apiClientProps }) => {
const fromAlbumPromises = []; const fromAlbumPromises = [];
@ -811,7 +811,7 @@ export const SubsonicController: ControllerEndpoint = {
return { return {
items: items:
res.body.searchResult3?.song?.map((song) => res.body.searchResult3?.song?.map((song) =>
ssNormalize.song(song, apiClientProps.server, ''), ssNormalize.song(song, apiClientProps.server),
) || [], ) || [],
startIndex: query.startIndex, startIndex: query.startIndex,
totalRecordCount: null, totalRecordCount: null,
@ -835,8 +835,7 @@ export const SubsonicController: ControllerEndpoint = {
const results = res.body.songsByGenre?.song || []; const results = res.body.songsByGenre?.song || [];
return { return {
items: items: results.map((song) => ssNormalize.song(song, apiClientProps.server)) || [],
results.map((song) => ssNormalize.song(song, apiClientProps.server, '')) || [],
startIndex: 0, startIndex: 0,
totalRecordCount: null, totalRecordCount: null,
}; };
@ -855,7 +854,7 @@ export const SubsonicController: ControllerEndpoint = {
const results = const results =
(res.body.starred?.song || []).map((song) => (res.body.starred?.song || []).map((song) =>
ssNormalize.song(song, apiClientProps.server, ''), ssNormalize.song(song, apiClientProps.server),
) || []; ) || [];
return { return {
@ -925,7 +924,7 @@ export const SubsonicController: ControllerEndpoint = {
} }
return { return {
items: results.map((song) => ssNormalize.song(song, apiClientProps.server, '')), items: results.map((song) => ssNormalize.song(song, apiClientProps.server)),
startIndex: 0, startIndex: 0,
totalRecordCount: results.length, totalRecordCount: results.length,
}; };
@ -950,7 +949,7 @@ export const SubsonicController: ControllerEndpoint = {
return { return {
items: items:
res.body.searchResult3?.song?.map((song) => res.body.searchResult3?.song?.map((song) =>
ssNormalize.song(song, apiClientProps.server, ''), ssNormalize.song(song, apiClientProps.server),
) || [], ) || [],
startIndex: 0, startIndex: 0,
totalRecordCount: null, totalRecordCount: null,
@ -1183,7 +1182,7 @@ export const SubsonicController: ControllerEndpoint = {
return { return {
items: items:
res.body.topSongs?.song?.map((song) => res.body.topSongs?.song?.map((song) =>
ssNormalize.song(song, apiClientProps.server, ''), ssNormalize.song(song, apiClientProps.server),
) || [], ) || [],
startIndex: 0, startIndex: 0,
totalRecordCount: res.body.topSongs?.song?.length || 0, totalRecordCount: res.body.topSongs?.song?.length || 0,
@ -1258,7 +1257,7 @@ export const SubsonicController: ControllerEndpoint = {
ssNormalize.album(album, apiClientProps.server), ssNormalize.album(album, apiClientProps.server),
), ),
songs: (res.body.searchResult3?.song || []).map((song) => songs: (res.body.searchResult3?.song || []).map((song) =>
ssNormalize.song(song, apiClientProps.server, ''), ssNormalize.song(song, apiClientProps.server),
), ),
}; };
}, },

View file

@ -29,7 +29,7 @@ const getCoverArtUrl = (args: {
`?id=${args.coverArtId}` + `?id=${args.coverArtId}` +
`&${args.credential}` + `&${args.credential}` +
'&v=1.13.0' + '&v=1.13.0' +
'&c=feishin' + '&c=Feishin' +
`&size=${size}` `&size=${size}`
); );
}; };
@ -37,7 +37,6 @@ const getCoverArtUrl = (args: {
const normalizeSong = ( const normalizeSong = (
item: z.infer<typeof ssType._response.song>, item: z.infer<typeof ssType._response.song>,
server: ServerListItem | null, server: ServerListItem | null,
deviceId: string,
size?: number, size?: number,
): QueueSong => { ): QueueSong => {
const imageUrl = const imageUrl =
@ -48,7 +47,7 @@ const normalizeSong = (
size: size || 300, size: size || 300,
}) || null; }) || null;
const streamUrl = `${server?.url}/rest/stream.view?id=${item.id}&v=1.13.0&c=feishin_${deviceId}&${server?.credential}`; const streamUrl = `${server?.url}/rest/stream.view?id=${item.id}&v=1.13.0&c=Feishin&${server?.credential}`;
return { return {
album: item.album || '', album: item.album || '',
@ -215,7 +214,7 @@ const normalizeAlbum = (
songCount: item.songCount, songCount: item.songCount,
songs: songs:
(item as z.infer<typeof ssType._response.album>).song?.map((song) => (item as z.infer<typeof ssType._response.album>).song?.map((song) =>
normalizeSong(song, server, ''), normalizeSong(song, server),
) || [], ) || [],
uniqueId: nanoid(), uniqueId: nanoid(),
updatedAt: item.created, updatedAt: item.created,

View file

@ -69,10 +69,10 @@ export const useDiscordRpc = () => {
activity.largeImageKey = song?.imageUrl; activity.largeImageKey = song?.imageUrl;
} }
if (generalSettings.lastfmApiKey && song?.album && song?.artists.length) { if (generalSettings.lastfmApiKey && song?.album && song?.albumArtists.length) {
console.log('Fetching album info for', song.album, song.artists[0].name); console.log('Fetching album info for', song.album, song.albumArtists[0].name);
const albumInfo = await fetch( const albumInfo = await fetch(
`https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=${generalSettings.lastfmApiKey}&artist=${encodeURIComponent(song.artistName)}&album=${encodeURIComponent(song.album)}&format=json`, `https://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=${generalSettings.lastfmApiKey}&artist=${encodeURIComponent(song.albumArtists[0].name)}&album=${encodeURIComponent(song.album)}&format=json`,
); );
const albumInfoJson = await albumInfo.json(); const albumInfoJson = await albumInfo.json();