[-] Revert unintended changes

This commit is contained in:
2025-11-23 09:00:44 +08:00
parent a3fbcbffb2
commit 11d20c560c
+9 -9
View File
@@ -140,7 +140,7 @@ export const getSongUrl = async (id: number | string) => {
// ///////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////////
// API for Song Preparation // API for Song Preparation
export interface ProgressItem { task: string, progress: number } export interface ProgressItem { id: string, task: string, progress: number }
export interface SongProcessState { items: ProgressItem[], status: 'running' | 'done' | 'error' } export interface SongProcessState { items: ProgressItem[], status: 'running' | 'done' | 'error' }
const songProcessingStatus = new Map<number, SongProcessState>() const songProcessingStatus = new Map<number, SongProcessState>()
@@ -152,20 +152,20 @@ export const prepareSong = async (songId: number) => {
const state: SongProcessState = { items: [], status: 'running' } const state: SongProcessState = { items: [], status: 'running' }
songProcessingStatus.set(songId, state) songProcessingStatus.set(songId, state)
const addTask = (task: string) => ({ task, progress: 0 }).also(it => state.items.push(it)) const addTask = (id: string, task: string) => ({ id, task, progress: 0 }).also(it => state.items.push(it))
try { try {
// 1. Get Lyrics // 1. Get Lyrics
const taskLyrics = addTask('从网易云获取歌词') const taskLyrics = addTask('lyrics', '从网易云获取歌词')
const raw = await getLyricsRaw(songId) const raw = await getLyricsRaw(songId)
taskLyrics.progress = 1 taskLyrics.progress = 1
if (raw.lang !== 'jpn') { if (raw.lang !== 'jpn') {
addTask('错误: 不是日语歌曲').progress = -1 addTask('error', '错误: 不是日语歌曲').progress = -1
return state.status = 'error' return state.status = 'error'
} }
// 2. AI Process // 2. AI Process
const taskAI = addTask('AI 标注歌词读音') const taskAI = addTask('ai', 'AI 标注歌词读音')
// Check cache // Check cache
if (await checkLyricsProcessed(songId)) taskAI.progress = 1 if (await checkLyricsProcessed(songId)) taskAI.progress = 1
@@ -176,12 +176,12 @@ export const prepareSong = async (songId: number) => {
} }
// 3. Audio // 3. Audio
const taskAudio = addTask('从网易云获取音乐') const taskAudio = addTask('music', '从网易云获取音乐')
await getSongUrl(songId) await getSongUrl(songId)
taskAudio.progress = 1 taskAudio.progress = 1
// 4. Source Separation // 4. Source Separation
const taskSeparation = addTask('AI 人声分离') const taskSeparation = addTask('separation', 'AI 人声分离')
const inputPath = path.join(CACHE_DIR, `${songId}/exhigh.mp3`) const inputPath = path.join(CACHE_DIR, `${songId}/exhigh.mp3`)
const outputDir = path.join(CACHE_DIR, `${songId}`) const outputDir = path.join(CACHE_DIR, `${songId}`)
@@ -189,14 +189,14 @@ export const prepareSong = async (songId: number) => {
await separateSong(inputPath, outputDir) await separateSong(inputPath, outputDir)
taskSeparation.progress = 1 taskSeparation.progress = 1
} catch (e: any) { } catch (e: any) {
addTask(`错误: ${e.message}`).progress = -1 addTask('error', `错误: ${e.message}`).progress = -1
// Don't fail the whole process, just this step // Don't fail the whole process, just this step
} }
state.status = 'done' state.status = 'done'
} catch (e) { } catch (e) {
addTask(`错误: ${eToString(e)}`).progress = -1 addTask('error', `错误: ${eToString(e)}`).progress = -1
state.status = 'error' state.status = 'error'
} }
} }