mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +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,
|
pathReplace?: string,
|
||||||
pathReplaceWith?: string,
|
pathReplaceWith?: string,
|
||||||
playlistIndex?: number,
|
playlistIndex?: number,
|
||||||
|
discTitleMap?: Map<number, string>,
|
||||||
): Song => {
|
): Song => {
|
||||||
const participants = getParticipants(item);
|
const participants = getParticipants(item);
|
||||||
|
|
||||||
@@ -156,7 +157,7 @@ const normalizeSong = (
|
|||||||
container: item.contentType,
|
container: item.contentType,
|
||||||
createdAt: item.created,
|
createdAt: item.created,
|
||||||
discNumber: item.discNumber || 1,
|
discNumber: item.discNumber || 1,
|
||||||
discSubtitle: null,
|
discSubtitle: discTitleMap?.get(item.discNumber ?? 1) ?? null,
|
||||||
duration: item.duration ? item.duration * 1000 : 0,
|
duration: item.duration ? item.duration * 1000 : 0,
|
||||||
explicitStatus:
|
explicitStatus:
|
||||||
item.explicitStatus === 'explicit'
|
item.explicitStatus === 'explicit'
|
||||||
@@ -267,6 +268,12 @@ const normalizeAlbum = (
|
|||||||
pathReplace?: string,
|
pathReplace?: string,
|
||||||
pathReplaceWith?: string,
|
pathReplaceWith?: string,
|
||||||
): Album => {
|
): 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 =
|
const releaseDate =
|
||||||
item.releaseDate &&
|
item.releaseDate &&
|
||||||
typeof item.releaseDate.year === 'number' &&
|
typeof item.releaseDate.year === 'number' &&
|
||||||
@@ -312,7 +319,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, pathReplace, pathReplaceWith),
|
normalizeSong(song, server, pathReplace, pathReplaceWith, undefined, discTitleMap),
|
||||||
) || [],
|
) || [],
|
||||||
tags: null,
|
tags: null,
|
||||||
updatedAt: item.created,
|
updatedAt: item.created,
|
||||||
|
|||||||
@@ -153,6 +153,14 @@ const album = z.object({
|
|||||||
contributors: z.array(contributor).optional(),
|
contributors: z.array(contributor).optional(),
|
||||||
coverArt: z.string(),
|
coverArt: z.string(),
|
||||||
created: z.string(),
|
created: z.string(),
|
||||||
|
discTitles: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
disc: z.number(),
|
||||||
|
title: z.string(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
duration: z.number(),
|
duration: z.number(),
|
||||||
explicitStatus: z.string().optional(),
|
explicitStatus: z.string().optional(),
|
||||||
genre: z.string().optional(),
|
genre: z.string().optional(),
|
||||||
|
|||||||
Reference in New Issue
Block a user