diff --git a/src/lang/en_us.json b/src/lang/en_us.json index f29970d..68c62c2 100644 --- a/src/lang/en_us.json +++ b/src/lang/en_us.json @@ -87,7 +87,8 @@ "list_select_local_file": "add local songs", "list_select_local_file_desc": "Select local song folder", "list_select_local_file_empty_tip": "No songs found in current directory", - "list_select_local_file_result_tip": "A total of {total} songs were found, {success} were successfully added, and {failed} were added", + "list_select_local_file_result_failed_tip": "A total of {total} songs were found, {success} were added successfully, and {failed} were added. You can go to the error log to view the songs that failed to be added.", + "list_select_local_file_result_tip": "{Total} songs found, all added!", "list_select_range": "range", "list_select_single": "Single Select", "list_select_unall": "Reverse Selection", diff --git a/src/lang/zh_cn.json b/src/lang/zh_cn.json index 9166d42..dff116b 100644 --- a/src/lang/zh_cn.json +++ b/src/lang/zh_cn.json @@ -87,7 +87,8 @@ "list_select_local_file": "添加本地歌曲", "list_select_local_file_desc": "选择本地歌曲文件夹", "list_select_local_file_empty_tip": "没有在当前目录中发现歌曲", - "list_select_local_file_result_tip": "共发现 {total} 首歌曲,成功添加 {success} 首,失败 {failed} 首", + "list_select_local_file_result_failed_tip": "共发现 {total} 首歌曲,成功添加 {success} 首,失败 {failed} 首,可到错误日志查看添加失败的歌曲", + "list_select_local_file_result_tip": "共发现 {total} 首歌曲,已全部添加!", "list_select_range": "区间", "list_select_single": "单选", "list_select_unall": "反选", diff --git a/src/screens/Home/Views/Mylist/MyList/listAction.ts b/src/screens/Home/Views/Mylist/MyList/listAction.ts index e82e7f7..60e134e 100644 --- a/src/screens/Home/Views/Mylist/MyList/listAction.ts +++ b/src/screens/Home/Views/Mylist/MyList/listAction.ts @@ -105,27 +105,35 @@ const buildLocalMusicInfo = (filePath: string, metadata: MusicMetadata): LX.Musi }, } } -const createLocalMusicInfos = async(filePaths: string[]): Promise => { +const createLocalMusicInfos = async(filePaths: string[], errorPath: string[]): Promise => { const list: LX.Music.MusicInfoLocal[] = [] for await (const path of filePaths) { const musicInfo = await readMetadata(path) - if (!musicInfo) continue + if (!musicInfo) { + errorPath.push(path) + continue + } list.push(buildLocalMusicInfo(path, musicInfo)) } return list } -const handleAddMusics = async(listId: string, filePaths: string[], index: number = -1, total: number = 0, successNum = 0) => { +const handleAddMusics = async(listId: string, filePaths: string[], index: number = -1, total: number = 0, errorPath: string[] = []) => { // console.log(index + 1, index + 201) if (!total) total = filePaths.length const paths = filePaths.slice(index + 1, index + 201) - const musicInfos = await createLocalMusicInfos(paths) - successNum += musicInfos.length + const musicInfos = await createLocalMusicInfos(paths, errorPath) if (musicInfos.length) await addListMusics(listId, musicInfos, settingState.setting['list.addMusicLocationType']) index += 200 - if (filePaths.length - 1 > index) await handleAddMusics(listId, filePaths, index, total, successNum) - - toast(global.i18n.t('list_select_local_file_result_tip', { total, success: successNum, failed: total - successNum }), 'long') + if (filePaths.length - 1 > index) await handleAddMusics(listId, filePaths, index, total, errorPath) + else { + if (errorPath.length) { + log.warn('Parse metadata failed:\n' + errorPath.map(p => p.split('/').at(-1)).join('\n')) + toast(global.i18n.t('list_select_local_file_result_failed_tip', { total, success: total - errorPath.length, failed: errorPath.length }), 'long') + } else { + toast(global.i18n.t('list_select_local_file_result_tip', { total }), 'long') + } + } } export const handleImportMediaFile = async(listInfo: LX.List.MyListInfo, path: string) => { setFetchingListStatus(listInfo.id, true)