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}` +
`&${args.credential}` +
'&v=1.13.0' +
'&c=feishin' +
'&c=Feishin' +
`&size=${size}`
);
};
@ -57,7 +57,6 @@ const normalizePlayDate = (item: WithDate): string | null => {
const normalizeSong = (
item: z.infer<typeof ndType._response.song> | z.infer<typeof ndType._response.playlistSong>,
server: ServerListItem | null,
deviceId: string,
imageSize?: number,
): Song => {
let id;
@ -127,7 +126,7 @@ const normalizeSong = (
serverId: server?.id || 'unknown',
serverType: ServerType.NAVIDROME,
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,
uniqueId: nanoid(),
updatedAt: item.updatedAt,
@ -191,7 +190,7 @@ const normalizeAlbum = (
serverType: ServerType.NAVIDROME,
size: item.size,
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(),
updatedAt: item.updatedAt,
userFavorite: item.starred,

View file

@ -255,7 +255,7 @@ axiosClient.interceptors.response.use(
const parsePath = (fullPath: string) => {
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');
return {

View file

@ -73,6 +73,7 @@ export const SubsonicController: ControllerEndpoint = {
} else {
const salt = randomString(12);
const hash = md5(body.password + salt);
credential = `u=${encodeURIComponent(body.username)}&s=${encodeURIComponent(salt)}&t=${encodeURIComponent(hash)}`;
credentialParams = {
s: salt,
@ -522,7 +523,7 @@ export const SubsonicController: ControllerEndpoint = {
`?id=${query.id}` +
`&${apiClientProps.server?.credential}` +
'&v=1.13.0' +
'&c=feishin'
'&c=Feishin'
);
},
getGenreList: async ({ query, apiClientProps }) => {
@ -672,9 +673,8 @@ export const SubsonicController: ControllerEndpoint = {
}
let results =
res.body.playlist.entry?.map((song) =>
ssNormalize.song(song, apiClientProps.server, ''),
) || [];
res.body.playlist.entry?.map((song) => ssNormalize.song(song, apiClientProps.server)) ||
[];
if (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 || [];
return {
items: results.map((song) => ssNormalize.song(song, apiClientProps.server, '')),
items: results.map((song) => ssNormalize.song(song, apiClientProps.server)),
startIndex: 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) => {
if (song.id !== query.songId) {
acc.push(ssNormalize.song(song, apiClientProps.server, ''));
acc.push(ssNormalize.song(song, apiClientProps.server));
}
return acc;
@ -784,7 +784,7 @@ export const SubsonicController: ControllerEndpoint = {
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 }) => {
const fromAlbumPromises = [];
@ -811,7 +811,7 @@ export const SubsonicController: ControllerEndpoint = {
return {
items:
res.body.searchResult3?.song?.map((song) =>
ssNormalize.song(song, apiClientProps.server, ''),
ssNormalize.song(song, apiClientProps.server),
) || [],
startIndex: query.startIndex,
totalRecordCount: null,
@ -835,8 +835,7 @@ export const SubsonicController: ControllerEndpoint = {
const results = res.body.songsByGenre?.song || [];
return {
items:
results.map((song) => ssNormalize.song(song, apiClientProps.server, '')) || [],
items: results.map((song) => ssNormalize.song(song, apiClientProps.server)) || [],
startIndex: 0,
totalRecordCount: null,
};
@ -855,7 +854,7 @@ export const SubsonicController: ControllerEndpoint = {
const results =
(res.body.starred?.song || []).map((song) =>
ssNormalize.song(song, apiClientProps.server, ''),
ssNormalize.song(song, apiClientProps.server),
) || [];
return {
@ -925,7 +924,7 @@ export const SubsonicController: ControllerEndpoint = {
}
return {
items: results.map((song) => ssNormalize.song(song, apiClientProps.server, '')),
items: results.map((song) => ssNormalize.song(song, apiClientProps.server)),
startIndex: 0,
totalRecordCount: results.length,
};
@ -950,7 +949,7 @@ export const SubsonicController: ControllerEndpoint = {
return {
items:
res.body.searchResult3?.song?.map((song) =>
ssNormalize.song(song, apiClientProps.server, ''),
ssNormalize.song(song, apiClientProps.server),
) || [],
startIndex: 0,
totalRecordCount: null,
@ -1183,7 +1182,7 @@ export const SubsonicController: ControllerEndpoint = {
return {
items:
res.body.topSongs?.song?.map((song) =>
ssNormalize.song(song, apiClientProps.server, ''),
ssNormalize.song(song, apiClientProps.server),
) || [],
startIndex: 0,
totalRecordCount: res.body.topSongs?.song?.length || 0,
@ -1258,7 +1257,7 @@ export const SubsonicController: ControllerEndpoint = {
ssNormalize.album(album, apiClientProps.server),
),
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}` +
`&${args.credential}` +
'&v=1.13.0' +
'&c=feishin' +
'&c=Feishin' +
`&size=${size}`
);
};
@ -37,7 +37,6 @@ const getCoverArtUrl = (args: {
const normalizeSong = (
item: z.infer<typeof ssType._response.song>,
server: ServerListItem | null,
deviceId: string,
size?: number,
): QueueSong => {
const imageUrl =
@ -48,7 +47,7 @@ const normalizeSong = (
size: size || 300,
}) || 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 {
album: item.album || '',
@ -215,7 +214,7 @@ const normalizeAlbum = (
songCount: item.songCount,
songs:
(item as z.infer<typeof ssType._response.album>).song?.map((song) =>
normalizeSong(song, server, ''),
normalizeSong(song, server),
) || [],
uniqueId: nanoid(),
updatedAt: item.created,

View file

@ -69,10 +69,10 @@ export const useDiscordRpc = () => {
activity.largeImageKey = song?.imageUrl;
}
if (generalSettings.lastfmApiKey && song?.album && song?.artists.length) {
console.log('Fetching album info for', song.album, song.artists[0].name);
if (generalSettings.lastfmApiKey && song?.album && song?.albumArtists.length) {
console.log('Fetching album info for', song.album, song.albumArtists[0].name);
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();