Improvements to dynamic colors and YT-DL imports.

This commit is contained in:
translator committed 2026-03-18 10:27:21 +09:00
1 parent ad68f9f5e9
commit ed72ded98f
8 files changed
+861 -62

No files matched your search

+186 -49
View File
@@ -45,6 +45,8 @@ interface Props {
storageKey?: string
/** URL of the source audio cover art (served by /api/projects/{id}/cover-art). */
coverArtUrl?: string
/** Thumbnail URL fallback from yt-dlp sidecar metadata. */
thumbnailUrl?: string
/** Artist name from source audio metadata. */
artist?: string
/** Track title from source audio metadata — used in the visual overlay only. */
@@ -127,19 +129,105 @@ function hslToHex(h: number, s: number, l: number): string {
return `#${[r, g, b].map(v => v.toString(16).padStart(2, '0')).join('')}`
}
function buildHighContrastSpeakerPalette(seedColor?: string): string[] {
function clamp01(value: number): number {
return Math.min(1, Math.max(0, value))
}
function relativeLuminance(rgb: { r: number; g: number; b: number }): number {
const toLinear = (v: number) => {
const x = v / 255
return x <= 0.03928 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4)
}
const r = toLinear(rgb.r)
const g = toLinear(rgb.g)
const b = toLinear(rgb.b)
return 0.2126 * r + 0.7152 * g + 0.0722 * b
}
function contrastRatio(a: { r: number; g: number; b: number }, b: { r: number; g: number; b: number }): number {
const la = relativeLuminance(a)
const lb = relativeLuminance(b)
const lighter = Math.max(la, lb)
const darker = Math.min(la, lb)
return (lighter + 0.05) / (darker + 0.05)
}
function ensureReadableColor(
seedColor: string,
bgColor: string,
minRatio = 4.5,
preferLighter = true,
): string {
const seedRgb = parseCssColorToRgb(seedColor)
const bgRgb = parseCssColorToRgb(bgColor)
if (!seedRgb || !bgRgb) return seedColor
const bgLum = relativeLuminance(bgRgb)
const seedLum = relativeLuminance(seedRgb)
const seedRatio = contrastRatio(seedRgb, bgRgb)
if (seedRatio >= minRatio && (!preferLighter || seedLum > bgLum + 0.015)) return seedColor
const { h, s } = rgbToHsl(seedRgb.r, seedRgb.g, seedRgb.b)
const sat = Math.min(0.98, Math.max(0.62, s))
let best = seedColor
let bestRatio = seedRatio
for (let i = 0; i <= 40; i++) {
const l = clamp01(0.99 - i * 0.02)
const candidate = hslToHex(h, sat, l)
const rgb = parseCssColorToRgb(candidate)
if (!rgb) continue
const lum = relativeLuminance(rgb)
if (preferLighter && lum <= bgLum + 0.015) continue
const ratio = contrastRatio(rgb, bgRgb)
if (ratio >= minRatio) return candidate
if (ratio > bestRatio) {
best = candidate
bestRatio = ratio
}
}
const whiteRatio = contrastRatio({ r: 255, g: 255, b: 255 }, bgRgb)
if (whiteRatio >= bestRatio) return '#ffffff'
return best
}
function normalizeDynamicBackground(seedColor?: string): string | null {
if (!seedColor) return null
const rgb = parseCssColorToRgb(seedColor)
if (!rgb) return null
const { h, s, l } = rgbToHsl(rgb.r, rgb.g, rgb.b)
// Keep dynamic backgrounds as the darkest visual layer.
const darkS = Math.min(0.90, Math.max(0.52, s * 1.08))
const darkL = Math.min(0.22, Math.max(0.08, l * 0.58 + 0.02))
return hslToHex(h, darkS, darkL)
}
function buildDynamicBackgroundGradient(bgColor?: string): string | null {
if (!bgColor) return null
const rgb = parseCssColorToRgb(bgColor)
if (!rgb) return null
const { h, s, l } = rgbToHsl(rgb.r, rgb.g, rgb.b)
const top = hslToHex(h, Math.min(0.94, Math.max(0.56, s * 1.08)), Math.min(0.30, l + 0.05))
const bottom = hslToHex((h + 8) % 360, Math.min(0.90, Math.max(0.50, s)), Math.max(0.05, l - 0.05))
return `linear-gradient(180deg, ${top} 0%, ${bottom} 100%)`
}
function buildHighContrastSpeakerPalette(seedColor?: string, bgColor?: string): string[] {
const fallback = SPEAKER_PALETTE
if (!seedColor) return fallback
const rgb = parseCssColorToRgb(seedColor)
if (!rgb) return fallback
const { h } = rgbToHsl(rgb.r, rgb.g, rgb.b)
const hues = [0, 38, 78, 120, 168, 210, 255, 300]
return hues.map((delta, idx) => {
const palette = hues.map((delta, idx) => {
const hh = (h + delta) % 360
const sat = 0.86
const light = idx % 2 === 0 ? 0.58 : 0.68
const light = idx % 2 === 0 ? 0.66 : 0.74
return hslToHex(hh, sat, light)
})
if (!bgColor) return palette
return palette.map(color => ensureReadableColor(color, bgColor, 4.5, true))
}
// ─── Speaker colours ──────────────────────────────────────────────────────────
@@ -508,6 +596,7 @@ interface StyleState {
highlightColor: string
wordHighlight: string
textAlign: 'left' | 'center' | 'right'
activeLineVerticalAlign: 'top' | 'center' | 'bottom'
lineSpacing: number
dynBg: boolean
dynBgMode: 'flat' | 'gradient'
@@ -545,6 +634,7 @@ function buildInitialStyle(styleOptions?: Partial<LyricsStyleOptions>): StyleSta
highlightColor: styleOptions?.highlightColor ?? DEFAULT_STYLE.highlightColor,
wordHighlight: styleOptions?.wordHighlightColor ?? DEFAULT_STYLE.wordHighlight,
textAlign: (styleOptions?.textAlign ?? DEFAULT_STYLE.textAlign) as 'left' | 'center' | 'right',
activeLineVerticalAlign: (styleOptions?.activeLineVerticalAlign ?? DEFAULT_STYLE.activeLineVerticalAlign) as 'top' | 'center' | 'bottom',
lineSpacing: styleOptions?.lineSpacing ?? DEFAULT_STYLE.lineSpacing,
}
}
@@ -557,6 +647,7 @@ const DEFAULT_STYLE: StyleState = {
highlightColor: '#3b82f6',
wordHighlight: '#60a5fa',
textAlign: 'center',
activeLineVerticalAlign: 'center',
lineSpacing: 1.6,
dynBg: false,
dynBgMode: 'gradient',
@@ -675,6 +766,26 @@ function StylePicker({
className="w-20 h-1.5 accent-brand-400"
/>
</div>
<div className="flex items-center gap-1">
<span className="text-[10px] text-slate-500">Anchor</span>
{([
{ value: 'top', label: 'Top' },
{ value: 'center', label: 'Center' },
{ value: 'bottom', label: 'Bottom' },
] as const).map(opt => (
<button
key={opt.value}
onClick={() => onChange({ activeLineVerticalAlign: opt.value })}
className={`text-[10px] px-1.5 py-0.5 rounded transition-colors ${
style.activeLineVerticalAlign === opt.value
? 'bg-white/20 text-white'
: 'text-slate-400 hover:text-slate-200'
}`}
>
{opt.label}
</button>
))}
</div>
</div>
{/* Universal effects row */}
<div className="flex items-center gap-3 flex-wrap">
@@ -890,6 +1001,11 @@ function StylePicker({
))}
</div>
)}
{style.dynBg && (
<span className="text-[10px] text-slate-500">
Dynamic mode auto-adjusts lyric colors for contrast.
</span>
)}
</div>
)}
</div>
@@ -1016,7 +1132,7 @@ function LrcEditor({
// ─── Main component ───────────────────────────────────────────────────────────
export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems, title, styleOptions, defaultStyle, onLrcChange, storageKey, coverArtUrl, artist, songTitle }: Props) {
export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems, title, styleOptions, defaultStyle, onLrcChange, storageKey, coverArtUrl, thumbnailUrl, artist, songTitle }: Props) {
// Internal lrc override from editor
const [editedLrc, setEditedLrc] = useState<string | null>(null)
const activeLrc = editedLrc ?? lrcText
@@ -1063,19 +1179,22 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
}, [styleOptions])
// Destructure for convenience
const { fontFamily, fontSize: baseFontSize, bgColor, textColor, wordHighlight, dynBg, karaokeMode, fontBold } = style
const { fontFamily, fontSize: baseFontSize, bgColor, dynBg, karaokeMode, fontBold } = style
// fontSize is finalised after isFullscreen is available (declared below)
const artworkUrl = coverArtUrl ?? thumbnailUrl
const hasVideoBackdrop = !!videoUrl
// Track whether cover art image loaded successfully
const [artLoaded, setArtLoaded] = useState(false)
// Reset artLoaded when coverArtUrl changes
useEffect(() => { setArtLoaded(false) }, [coverArtUrl])
// Reset artLoaded when artwork source changes
useEffect(() => { setArtLoaded(false) }, [artworkUrl])
// ── Dynamic background color extracted from album art (Canvas API) ──────────
const [extractedBg, setExtractedBg] = useState<string | null>(null)
useEffect(() => {
if (!dynBg || !coverArtUrl) { setExtractedBg(null); return }
if (!dynBg || !artworkUrl) { setExtractedBg(null); return }
const img = new window.Image()
img.crossOrigin = 'anonymous'
img.onload = () => {
@@ -1118,31 +1237,38 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
// Keep hue identity but boost saturation/lightness slightly so colors pop.
const { h, s, l } = rgbToHsl(baseR, baseG, baseB)
const vividS = Math.max(0.58, Math.min(0.88, s * 1.2))
const vividL = Math.max(0.20, Math.min(0.36, l * 0.72 + 0.06))
setExtractedBg(hslToHex(h, vividS, vividL))
const vividS = Math.max(0.58, Math.min(0.90, s * 1.22))
const vividL = Math.max(0.18, Math.min(0.42, l * 0.74 + 0.06))
const vivid = hslToHex(h, vividS, vividL)
setExtractedBg(normalizeDynamicBackground(vivid))
} catch { setExtractedBg(null) }
}
img.onerror = () => setExtractedBg(null)
img.src = coverArtUrl
}, [dynBg, coverArtUrl])
img.src = artworkUrl
}, [dynBg, artworkUrl])
const dynamicBgGradient = useMemo(() => {
if (!extractedBg) return null
const rgb = parseCssColorToRgb(extractedBg)
if (!rgb) return null
const { h, s, l } = rgbToHsl(rgb.r, rgb.g, rgb.b)
const top = hslToHex(h, Math.min(0.92, Math.max(0.62, s * 1.12)), Math.min(0.46, l + 0.08))
const bottom = hslToHex((h + 10) % 360, Math.min(0.86, Math.max(0.56, s)), Math.max(0.14, l - 0.08))
return `linear-gradient(180deg, ${top} 0%, ${bottom} 100%)`
}, [extractedBg])
const dynamicBgGradient = useMemo(() => buildDynamicBackgroundGradient(extractedBg ?? undefined), [extractedBg])
const dynamicTheme = useMemo(() => {
if (!dynBg || !extractedBg) return null
return {
textColor: ensureReadableColor(style.textColor, extractedBg, 7.0, true),
highlightColor: ensureReadableColor(style.highlightColor, extractedBg, 4.5, true),
wordHighlight: ensureReadableColor(style.wordHighlight, extractedBg, 4.5, true),
speakerPalette: buildHighContrastSpeakerPalette(extractedBg, extractedBg),
}
}, [dynBg, extractedBg, style.textColor, style.highlightColor, style.wordHighlight])
const effectiveTextColor = dynamicTheme?.textColor ?? style.textColor
const effectiveHighlightColor = dynamicTheme?.highlightColor ?? style.highlightColor
const effectiveWordHighlight = dynamicTheme?.wordHighlight ?? style.wordHighlight
// Effective background: extracted dynamic color/gradient or user static color.
const effectiveBgColor = dynBg && extractedBg ? extractedBg : bgColor
const effectiveBgGradient = dynBg && style.dynBgMode === 'gradient' ? dynamicBgGradient : null
const dynamicSpeakerPalette = useMemo(
() => (dynBg ? buildHighContrastSpeakerPalette(extractedBg ?? undefined) : SPEAKER_PALETTE),
[dynBg, extractedBg],
() => (dynamicTheme?.speakerPalette ?? SPEAKER_PALETTE),
[dynamicTheme],
)
// Per-stem state (multi-stem mode)
@@ -1253,8 +1379,8 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
const currentTimeRef = useRef(0)
const activeWordSpanRef = useRef<HTMLSpanElement | null>(null)
const linesRef = useRef<LrcLine[]>(lines)
const brightRef = useRef(wordHighlight)
const dimRef = useRef(textColor + '60')
const brightRef = useRef(effectiveWordHighlight)
const dimRef = useRef(effectiveTextColor + '60')
const karaokeModeRef = useRef(karaokeMode)
// Keep linesRef in sync (done directly in render so RAF always sees latest parse)
@@ -1280,10 +1406,10 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
// for the karaoke word-fill gradient instead of the global highlight color.
useEffect(() => {
const ln = linesRef.current[activeLine]
brightRef.current = ln?.speaker ? getSpeakerColor(ln.speaker) : style.wordHighlight
dimRef.current = textColor
brightRef.current = ln?.speaker ? getSpeakerColor(ln.speaker) : effectiveWordHighlight
dimRef.current = effectiveTextColor
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeLine, textColor, speakerColors, dynamicSpeakerPalette, style.wordHighlight])
}, [activeLine, effectiveTextColor, speakerColors, dynamicSpeakerPalette, effectiveWordHighlight])
// Keep karaokeModeRef in sync so the RAF loop sees the latest value without restarting
karaokeModeRef.current = karaokeMode
@@ -1660,18 +1786,18 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
// Keep optional video background synchronized to transport and master clock.
useEffect(() => {
const v = videoRef.current
if (!v || !videoUrl || visualStyle !== 'video') return
if (!v || !hasVideoBackdrop) return
if (Math.abs(v.currentTime - currentTime) > 0.25) {
v.currentTime = currentTime
}
}, [currentTime, videoUrl, visualStyle])
}, [currentTime, hasVideoBackdrop])
useEffect(() => {
const v = videoRef.current
if (!v || !videoUrl || visualStyle !== 'video') return
if (!v || !hasVideoBackdrop) return
if (isPlaying) v.play().catch(() => {})
else v.pause()
}, [isPlaying, videoUrl, visualStyle])
}, [isPlaying, hasVideoBackdrop])
function handleVolumeChange(e: React.ChangeEvent<HTMLInputElement>) {
const v = parseFloat(e.target.value)
@@ -1767,7 +1893,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
position: 'relative',
} as any}
>
{videoUrl && visualStyle === 'video' && (
{hasVideoBackdrop && (
<>
<video
ref={videoRef}
@@ -1784,7 +1910,8 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
inset: 0,
width: '100%',
height: '100%',
objectFit: 'cover',
objectFit: 'contain',
backgroundColor: '#020617',
zIndex: 0,
}}
/>
@@ -1805,16 +1932,17 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
currentTimeRef={currentTimeRef}
visualStyle={visualStyle}
style={{
bgColor: (videoUrl && visualStyle === 'video') ? 'rgba(0,0,0,0)' : effectiveBgColor,
bgGradient: (videoUrl && visualStyle === 'video') ? null : effectiveBgGradient,
textColor: style.textColor,
highlightColor: style.highlightColor,
wordHighlight: style.wordHighlight,
bgColor: hasVideoBackdrop ? 'rgba(0,0,0,0)' : effectiveBgColor,
bgGradient: hasVideoBackdrop ? null : effectiveBgGradient,
textColor: effectiveTextColor,
highlightColor: effectiveHighlightColor,
wordHighlight: effectiveWordHighlight,
fontFamily: style.fontFamily,
fontSize,
fontBold: style.fontBold,
lineSpacing: style.lineSpacing,
textAlign: style.textAlign,
activeLineVerticalAlign: style.activeLineVerticalAlign,
dynBg: style.dynBg,
dynBgMode: style.dynBgMode,
scaleX: style.scaleX,
@@ -1844,7 +1972,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
</div>
{/* Windowed album art overlay — top-left hovering card (only shown when art loaded) */}
{!isFullscreen && coverArtUrl && artLoaded && (
{!isFullscreen && artworkUrl && artLoaded && (
<div style={{
position: 'absolute', top: 8, left: 8, zIndex: 10,
display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 8,
@@ -1856,7 +1984,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
backdropFilter: 'blur(2px)',
}}>
<img
src={coverArtUrl}
src={artworkUrl}
alt="Cover"
style={{ width: 48, height: 48, objectFit: 'cover', borderRadius: 6, flexShrink: 0 }}
/>
@@ -1879,9 +2007,9 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
</div>
)}
{/* Hidden image used to detect whether cover art is available */}
{coverArtUrl && !artLoaded && (
{artworkUrl && !artLoaded && (
<img
src={coverArtUrl}
src={artworkUrl}
alt=""
style={{ display: 'none' }}
onLoad={() => setArtLoaded(true)}
@@ -2061,7 +2189,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
{/* Style picker panel */}
{showStylePicker && (
<div className={isFullscreen ? 'bg-black/50' : 'bg-slate-100/80 dark:bg-gray-800/80'}>
<StylePicker style={style} onChange={patchStyle} onReset={resetStyle} hasCoverArt={!!coverArtUrl && artLoaded} hasElrc={hasElrc} />
<StylePicker style={style} onChange={patchStyle} onReset={resetStyle} hasCoverArt={!!artworkUrl && artLoaded} hasElrc={hasElrc} />
{/* Speaker colour swatches — always shown so user knows if diarization is missing */}
<div className="px-3 py-2 border-b border-white/10 flex items-center gap-3 flex-wrap">
<span className="text-[10px] text-slate-500 shrink-0">Speakers</span>
@@ -2152,7 +2280,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
)}
{/* Content area: fullscreen with art → side-by-side on wide screens, stacked on mobile */}
{isFullscreen && coverArtUrl && artLoaded ? (
{isFullscreen && artworkUrl && artLoaded ? (
<div style={{ flex: '1 1 0', display: 'flex', flexDirection: isNarrow ? 'column' : 'row', overflow: 'hidden' }}>
{/* Left/top panel: album art + artist + title */}
<div style={{
@@ -2168,7 +2296,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, videoUrl, stems,
backgroundColor: 'rgba(0,0,0,0.3)',
}}>
<img
src={coverArtUrl}
src={artworkUrl}
alt="Cover"
style={{
width: isNarrow ? 52 : '100%',
@@ -2339,6 +2467,12 @@ function lineStride(style: StyleState): number {
return style.fontSize * style.lineSpacing * LINE_STRIDE_FACTOR
}
function activeLineAnchorY(height: number, align: StyleState['activeLineVerticalAlign']): number {
if (align === 'top') return height * 0.28
if (align === 'bottom') return height * 0.72
return height * 0.5
}
function getCanvasLineVisualTargets(
visualStyle: LyricsVisualStyle,
style: StyleState,
@@ -2715,7 +2849,8 @@ function snapCanvasSceneState(
activateCanvasLineGroup(state, activeIdx, lines, style, visualStyle, speakerColorFn)
const scrollIdx = Math.max(0, activeIdx)
const scrollRecord = state.lineRecords[scrollIdx]
state.linesGroup.translation.y = state.two.height / 2 - (scrollRecord?.yOffset ?? 0)
const anchorY = activeLineAnchorY(state.two.height, style.activeLineVerticalAlign)
state.linesGroup.translation.y = anchorY - (scrollRecord?.yOffset ?? 0)
const blurEnabled = visualStyle === 'blur' || style.effectBlurEnabled
const blurKeep = blurEnabled ? new Set<number>() : null
@@ -3196,7 +3331,8 @@ function updateCanvasScene(
const scrollIdx = Math.max(0, newActiveIdx)
const scrollRecord = state.lineRecords[scrollIdx]
const targetY = state.two.height / 2 - (scrollRecord?.yOffset ?? scrollIdx * stride)
const anchorY = activeLineAnchorY(state.two.height, style.activeLineVerticalAlign)
const targetY = anchorY - (scrollRecord?.yOffset ?? scrollIdx * stride)
state.linesGroup.translation.y = canvasLerp(state.linesGroup.translation.y, targetY, LERP_FACTOR)
const blurEnabled = visualStyle === 'blur' || style.effectBlurEnabled
@@ -3363,6 +3499,7 @@ function LyricsCanvas({ lines, currentTimeRef, visualStyle, style, speakerColorF
fontSize: style.fontSize,
fontBold: style.fontBold,
textAlign: style.textAlign,
activeLineVerticalAlign: style.activeLineVerticalAlign,
lineSpacing: style.lineSpacing,
scaleX: style.scaleX,
scaleY: style.scaleY,
+81 -3
View File
@@ -194,6 +194,7 @@ function SubsonicPanel() {
enabled: open,
refetchInterval: open ? 10000 : false,
})
const subsonicImports = importedFiles.filter((f) => (f.source || '').toLowerCase() !== 'yt-dlp')
async function doSearch() {
const hasAny = [query, titleFilter, artistFilter, albumFilter, albumArtistFilter].some(v => v.trim())
@@ -355,11 +356,11 @@ function SubsonicPanel() {
)}
{/* Imported files list */}
{importedFiles.length > 0 && (
{subsonicImports.length > 0 && (
<div>
<p className="text-[10px] font-bold uppercase tracking-widest ui-text-muted mb-1">Imported Files</p>
<p className="text-[10px] font-bold uppercase tracking-widest ui-text-muted mb-1">Subsonic Imports</p>
<div className="space-y-1 max-h-40 overflow-y-auto">
{importedFiles.map((f) => {
{subsonicImports.map((f) => {
const isDeleting = deletingFile === f.filename
return (
<div
@@ -421,6 +422,16 @@ function YtDlPanel() {
const [submitting, setSubmitting] = useState(false)
const [jobId, setJobId] = useState<string | null>(null)
const [submitErr, setSubmitErr] = useState<string | null>(null)
const [autoTarget, setAutoTarget] = useState<ImportedFile | null>(null)
const [deletingFile, setDeletingFile] = useState<string | null>(null)
const { data: importedFiles = [] } = useQuery<ImportedFile[]>({
queryKey: ['imports'],
queryFn: listImports,
enabled: open,
refetchInterval: open ? 10000 : false,
})
const ytdlImports = importedFiles.filter((f) => (f.source || '').toLowerCase() === 'yt-dlp')
// Poll the job while it is queued or running.
const { data: job } = useQuery({
@@ -463,6 +474,21 @@ function YtDlPanel() {
}
}
async function doDeleteImport(filename: string) {
setDeletingFile(filename)
try {
await deleteImport(filename)
queryClient.invalidateQueries({ queryKey: ['imports'] })
if (autoTarget?.filename === filename) {
setAutoTarget(null)
}
} catch (e) {
setSubmitErr(e instanceof Error ? e.message : 'Failed to delete imported file')
} finally {
setDeletingFile(null)
}
}
// Derive a friendly progress label.
let progressLabel: string | null = null
if (jobRunning && job) {
@@ -523,6 +549,58 @@ function YtDlPanel() {
{(submitErr || jobError) && (
<p className="text-xs text-red-500 dark:text-red-400 break-all">{submitErr ?? jobError}</p>
)}
{ytdlImports.length > 0 && (
<div className="pt-1">
<p className="text-[10px] font-bold uppercase tracking-widest ui-text-muted mb-1">YT-DL Imports</p>
<div className="space-y-1 max-h-32 overflow-y-auto">
{ytdlImports.map((f) => {
const isDeleting = deletingFile === f.filename
return (
<div
key={f.path}
className="group flex items-center gap-2 rounded-lg border ui-border ui-surface px-2.5 py-1.5"
>
<div className="flex-1 min-w-0">
<p className="text-xs font-medium ui-text truncate">{f.filename}</p>
<p className="text-[10px] ui-text-muted">{(f.size / 1024 / 1024).toFixed(1)} MB</p>
</div>
<button
onClick={() => setAutoTarget(f)}
title="Auto pipeline"
className="shrink-0 p-1 rounded ui-text-muted hover:text-amber-500 transition-colors opacity-0 group-hover:opacity-100"
>
<Zap className="w-3 h-3" />
</button>
<button
onClick={() => doDeleteImport(f.filename)}
disabled={isDeleting}
title="Delete import"
className="shrink-0 p-1 rounded ui-text-muted hover:text-red-500 transition-colors opacity-0 group-hover:opacity-100"
>
{isDeleting
? <Loader2 className="w-3 h-3 animate-spin" />
: <Trash2 className="w-3 h-3" />}
</button>
</div>
)
})}
</div>
</div>
)}
{autoTarget && (
<AutoPipelineDialog
target={{
filePath: autoTarget.path,
filename: autoTarget.filename,
initialProjectName: autoTarget.artist && autoTarget.title
? `${autoTarget.artist} - ${autoTarget.title}`
: autoTarget.filename.replace(/\.[^/.]+$/, ''),
}}
onClose={() => setAutoTarget(null)}
/>
)}
</div>
)}
</div>
+41 -4
View File
@@ -357,14 +357,51 @@ html[data-skin] .dark\:border-gray-800 {
/* Range input styling */
input[type="range"] {
background-color: rgb(var(--ui-surface-2));
@apply rounded-lg appearance-none cursor-pointer;
-webkit-appearance: none;
appearance: none;
background: transparent;
cursor: pointer;
height: 0.375rem;
border-radius: 9999px;
}
input[type="range"]::-webkit-slider-runnable-track {
height: 0.375rem;
border-radius: 9999px;
background-color: rgb(var(--ui-border) / 0.78);
border: 1px solid rgb(var(--ui-border) / 0.9);
}
input[type="range"]::-webkit-slider-thumb {
@apply appearance-none w-4 h-4 rounded-full bg-brand-500 cursor-pointer;
-webkit-appearance: none;
appearance: none;
width: 0.875rem;
height: 0.875rem;
border-radius: 9999px;
background-color: rgb(var(--brand-500));
border: 1px solid rgb(var(--ui-surface));
margin-top: -0.3125rem;
box-shadow: 0 0 0 1px rgb(var(--ui-border) / 0.85);
}
input[type="range"]::-moz-range-track {
height: 0.375rem;
border-radius: 9999px;
background-color: rgb(var(--ui-border) / 0.78);
border: 1px solid rgb(var(--ui-border) / 0.9);
}
input[type="range"]::-moz-range-thumb {
@apply w-4 h-4 rounded-full bg-brand-500 cursor-pointer border-0;
width: 0.875rem;
height: 0.875rem;
border-radius: 9999px;
background-color: rgb(var(--brand-500));
border: 1px solid rgb(var(--ui-surface));
box-shadow: 0 0 0 1px rgb(var(--ui-border) / 0.85);
cursor: pointer;
}
input[type="range"]:focus-visible {
outline: 2px solid rgb(var(--ui-focus));
outline-offset: 2px;
}
+7 -2
View File
@@ -1727,7 +1727,7 @@ const WHISPER_LANGS = [
{ id: 'hi', label: 'Hindi' },
]
function LrcPreview({ file, jobId, originalAudioUrl, sourceVideoUrl, stems, title, storageKey, coverArtUrl, artist, songTitle }: {
function LrcPreview({ file, jobId, originalAudioUrl, sourceVideoUrl, stems, title, storageKey, coverArtUrl, thumbnailUrl, artist, songTitle }: {
file: JobFile
jobId: string
originalAudioUrl?: string
@@ -1736,6 +1736,7 @@ function LrcPreview({ file, jobId, originalAudioUrl, sourceVideoUrl, stems, titl
title?: string
storageKey?: string
coverArtUrl?: string
thumbnailUrl?: string
artist?: string
songTitle?: string
}) {
@@ -1798,6 +1799,7 @@ function LrcPreview({ file, jobId, originalAudioUrl, sourceVideoUrl, stems, titl
title={title}
storageKey={storageKey}
coverArtUrl={coverArtUrl}
thumbnailUrl={thumbnailUrl}
artist={artist}
songTitle={songTitle}
/>
@@ -1853,6 +1855,7 @@ function StemLyricsRow({
sourceVideoUrl,
stems,
coverArtUrl,
thumbnailUrl,
artist,
songTitle,
lyricModels,
@@ -1867,6 +1870,7 @@ function StemLyricsRow({
sourceVideoUrl?: string
stems?: { name: string; label: string; url: string }[]
coverArtUrl?: string
thumbnailUrl?: string
artist?: string
songTitle?: string
lyricModels?: LyricModelsPayload
@@ -2274,7 +2278,7 @@ function StemLyricsRow({
{activeJob.files
.filter((f) => f.name.endsWith('.elrc') || f.name.endsWith('.lrc') || f.name.endsWith('.sylrc'))
.map((f) => (
<LrcPreview key={f.name} file={f} jobId={activeJob.id} originalAudioUrl={originalAudioUrl} sourceVideoUrl={sourceVideoUrl} stems={stems} title={projectName} storageKey={`${activeJob.id}-${f.name}`} coverArtUrl={coverArtUrl} artist={artist} songTitle={songTitle} />
<LrcPreview key={f.name} file={f} jobId={activeJob.id} originalAudioUrl={originalAudioUrl} sourceVideoUrl={sourceVideoUrl} stems={stems} title={projectName} storageKey={`${activeJob.id}-${f.name}`} coverArtUrl={coverArtUrl} thumbnailUrl={thumbnailUrl} artist={artist} songTitle={songTitle} />
))}
{/* Inline transcript display for lyric-transcribe jobs */}
{activeJob.job_type === 'lyric-transcribe' && (
@@ -2448,6 +2452,7 @@ function LyricsSection({
sourceVideoUrl={sourceVideoUrl}
stems={stemEntries.length > 0 ? stemEntries : undefined}
coverArtUrl={projectCoverArtUrl(project.id)}
thumbnailUrl={project.source_thumbnail_url}
artist={project.source_artist}
songTitle={project.source_title}
lyricModels={lyricModels}
+2
View File
@@ -196,6 +196,7 @@ export interface ProjectDetail {
mix_job: Job | null
source_artist?: string
source_title?: string
source_thumbnail_url?: string
}
// Lyrics Style options
@@ -208,4 +209,5 @@ export interface LyricsStyleOptions {
wordHighlightColor: string
lineSpacing: number
textAlign: 'left' | 'center' | 'right'
activeLineVerticalAlign?: 'top' | 'center' | 'bottom'
}