[enhancement]: parse replaygain from subsonic endpoints where available

This commit is contained in:
Kendall Garner 2024-04-27 22:20:42 -07:00
parent ef87a8c2a7
commit c36f0a055d
No known key found for this signature in database
GPG key ID: 18D2767419676C87
2 changed files with 22 additions and 2 deletions

View file

@ -75,7 +75,13 @@ const normalizeSong = (
discNumber: item.discNumber || 1, discNumber: item.discNumber || 1,
discSubtitle: null, discSubtitle: null,
duration: item.duration ? item.duration * 1000 : 0, duration: item.duration ? item.duration * 1000 : 0,
gain: null, gain:
item.replayGain && (item.replayGain.albumGain || item.replayGain.trackGain)
? {
album: item.replayGain.albumGain,
track: item.replayGain.trackGain,
}
: null,
genres: item.genre genres: item.genre
? [ ? [
{ {
@ -94,7 +100,13 @@ const normalizeSong = (
lyrics: null, lyrics: null,
name: item.title, name: item.title,
path: item.path, path: item.path,
peak: null, peak:
item.replayGain && (item.replayGain.albumPeak || item.replayGain.trackPeak)
? {
album: item.replayGain.albumPeak,
track: item.replayGain.trackPeak,
}
: null,
playCount: item?.playCount || 0, playCount: item?.playCount || 0,
releaseDate: null, releaseDate: null,
releaseYear: item.year ? String(item.year) : null, releaseYear: item.year ? String(item.year) : null,

View file

@ -53,6 +53,13 @@ const musicFolderList = z.object({
}), }),
}); });
const songGain = z.object({
albumGain: z.number().optional(),
albumPeak: z.number().optional(),
trackGain: z.number().optional(),
trackPeak: z.number().optional(),
});
const song = z.object({ const song = z.object({
album: z.string().optional(), album: z.string().optional(),
albumId: z.string().optional(), albumId: z.string().optional(),
@ -72,6 +79,7 @@ const song = z.object({
parent: z.string(), parent: z.string(),
path: z.string(), path: z.string(),
playCount: z.number().optional(), playCount: z.number().optional(),
replayGain: songGain.optional(),
size: z.number(), size: z.number(),
starred: z.boolean().optional(), starred: z.boolean().optional(),
suffix: z.string(), suffix: z.string(),