mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
add support for disc subtitles from subsonic discTitles field (#1609)
This commit is contained in:
@@ -134,6 +134,7 @@ const normalizeSong = (
|
||||
pathReplace?: string,
|
||||
pathReplaceWith?: string,
|
||||
playlistIndex?: number,
|
||||
discTitleMap?: Map<number, string>,
|
||||
): Song => {
|
||||
const participants = getParticipants(item);
|
||||
|
||||
@@ -156,7 +157,7 @@ const normalizeSong = (
|
||||
container: item.contentType,
|
||||
createdAt: item.created,
|
||||
discNumber: item.discNumber || 1,
|
||||
discSubtitle: null,
|
||||
discSubtitle: discTitleMap?.get(item.discNumber ?? 1) ?? null,
|
||||
duration: item.duration ? item.duration * 1000 : 0,
|
||||
explicitStatus:
|
||||
item.explicitStatus === 'explicit'
|
||||
@@ -267,6 +268,12 @@ const normalizeAlbum = (
|
||||
pathReplace?: string,
|
||||
pathReplaceWith?: string,
|
||||
): Album => {
|
||||
const discTitleMap = new Map<number, string>();
|
||||
|
||||
(item as z.infer<typeof ssType._response.album>).discTitles?.forEach((discTitle) => {
|
||||
discTitleMap.set(discTitle.disc, discTitle.title);
|
||||
});
|
||||
|
||||
const releaseDate =
|
||||
item.releaseDate &&
|
||||
typeof item.releaseDate.year === 'number' &&
|
||||
@@ -312,7 +319,7 @@ const normalizeAlbum = (
|
||||
songCount: item.songCount,
|
||||
songs:
|
||||
(item as z.infer<typeof ssType._response.album>).song?.map((song) =>
|
||||
normalizeSong(song, server, pathReplace, pathReplaceWith),
|
||||
normalizeSong(song, server, pathReplace, pathReplaceWith, undefined, discTitleMap),
|
||||
) || [],
|
||||
tags: null,
|
||||
updatedAt: item.created,
|
||||
|
||||
@@ -153,6 +153,14 @@ const album = z.object({
|
||||
contributors: z.array(contributor).optional(),
|
||||
coverArt: z.string(),
|
||||
created: z.string(),
|
||||
discTitles: z
|
||||
.array(
|
||||
z.object({
|
||||
disc: z.number(),
|
||||
title: z.string(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
duration: z.number(),
|
||||
explicitStatus: z.string().optional(),
|
||||
genre: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user