mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
chore(lyrics): polish rebased TTML branch
This commit is contained in:
parent
177e7089ee
commit
27255fb9ae
@ -814,9 +814,9 @@ func (p *ttmlParser) updateTimingParams(attrs []xml.Attr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p.params.frameRate = max(frameRate, defaultTTMLFrameRate)
|
p.params.frameRate = positiveOrDefault(frameRate, defaultTTMLFrameRate)
|
||||||
p.params.subFrameRate = max(subFrameRate, defaultTTMLSubFrameRate)
|
p.params.subFrameRate = positiveOrDefault(subFrameRate, defaultTTMLSubFrameRate)
|
||||||
p.params.tickRate = max(tickRate, defaultTTMLTickRate)
|
p.params.tickRate = positiveOrDefault(tickRate, defaultTTMLTickRate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTTMLDurationExpression(expr string, params ttmlTimingParams) (int64, bool) {
|
func parseTTMLDurationExpression(expr string, params ttmlTimingParams) (int64, bool) {
|
||||||
@ -1102,7 +1102,7 @@ func hydrateLineTimingFromTokens(line model.Line) model.Line {
|
|||||||
return model.NormalizeLineTiming(line)
|
return model.NormalizeLineTiming(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
func max(v float64, fallback float64) float64 {
|
func positiveOrDefault(v float64, fallback float64) float64 {
|
||||||
if v <= 0 {
|
if v <= 0 {
|
||||||
return fallback
|
return fallback
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,6 +99,8 @@ func (api *Router) GetLyrics(r *http.Request) (*responses.Subsonic, error) {
|
|||||||
lyricsResponse := responses.Lyrics{}
|
lyricsResponse := responses.Lyrics{}
|
||||||
response.Lyrics = &lyricsResponse
|
response.Lyrics = &lyricsResponse
|
||||||
opts := filter.SongsByArtistTitleWithLyricsFirst(artist, title)
|
opts := filter.SongsByArtistTitleWithLyricsFirst(artist, title)
|
||||||
|
// Keep the search exhaustive so an older duplicate can still supply the
|
||||||
|
// matching sidecar lyrics when the newest candidate only has embedded data.
|
||||||
opts.Max = 0
|
opts.Max = 0
|
||||||
mediaFiles, err := api.ds.MediaFile(r.Context()).GetAll(opts)
|
mediaFiles, err := api.ds.MediaFile(r.Context()).GetAll(opts)
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,9 @@ const normalizeToken = (token) => {
|
|||||||
|
|
||||||
const buildAgentLookup = (structuredLyric) => {
|
const buildAgentLookup = (structuredLyric) => {
|
||||||
const lookup = new Map()
|
const lookup = new Map()
|
||||||
const agents = Array.isArray(structuredLyric?.agents) ? structuredLyric.agents : []
|
const agents = Array.isArray(structuredLyric?.agents)
|
||||||
|
? structuredLyric.agents
|
||||||
|
: []
|
||||||
for (const agent of agents) {
|
for (const agent of agents) {
|
||||||
const id = typeof agent?.id === 'string' ? agent.id : ''
|
const id = typeof agent?.id === 'string' ? agent.id : ''
|
||||||
if (!id || lookup.has(id)) {
|
if (!id || lookup.has(id)) {
|
||||||
@ -112,8 +114,7 @@ const normalizeCueLine = (cueLine, fallbackIndex, agentLookup) => {
|
|||||||
: fallbackIndex
|
: fallbackIndex
|
||||||
const agentId = typeof cueLine?.agentId === 'string' ? cueLine.agentId : ''
|
const agentId = typeof cueLine?.agentId === 'string' ? cueLine.agentId : ''
|
||||||
const agent = agentId ? agentLookup.get(agentId) || null : null
|
const agent = agentId ? agentLookup.get(agentId) || null : null
|
||||||
const fallbackRole =
|
const fallbackRole = typeof cueLine?.role === 'string' ? cueLine.role : ''
|
||||||
typeof cueLine?.role === 'string' ? cueLine.role : ''
|
|
||||||
const tokens = sortTokensByStart(
|
const tokens = sortTokensByStart(
|
||||||
Array.isArray(cueLine?.cue)
|
Array.isArray(cueLine?.cue)
|
||||||
? cueLine.cue.map(normalizeToken).filter(Boolean)
|
? cueLine.cue.map(normalizeToken).filter(Boolean)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user