Dev fixerr - #773
Dev fixerr#773
Conversation
Summary of ChangesHello @kazukokawagawa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the stability of lyric parsing by cleaning TTML content and significantly enhancing the debugging experience for audio source resolution. The added logging will provide developers with a clearer understanding of how song URLs and qualities are determined and fetched, making it easier to troubleshoot playback issues. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request appears to fix an issue with TTML lyric parsing by removing newlines before parsing. However, this fix introduces some code duplication. Additionally, a number of debugging console.log statements have been added to SongManager.ts, which should be removed before this is merged into a main branch. My review includes a suggestion to refactor for code reuse and comments to remove the debug logs.
| const ttmlContent = typeof ttml === "string" ? ttml : ""; | ||
| if (ttmlContent) { | ||
| ttmlLines = parseTTML(ttmlContent).lines || []; | ||
| ttmlLines = parseTTML(ttmlContent.replace(/\n\s*/g, "")).lines || []; |
There was a problem hiding this comment.
There's an opportunity to avoid code duplication here. The logic ttmlContent.replace(/\n\s*/g, "") was also added to cleanTTMLTranslations in this PR. Instead of repeating the replacement here, you could reuse cleanTTMLTranslations to ensure consistency and better maintainability.
| ttmlLines = parseTTML(ttmlContent.replace(/\n\s*/g, "")).lines || []; | |
| ttmlLines = parseTTML(this.cleanTTMLTranslations(ttmlContent)).lines || []; |
| const finalUrl = isTrial && !settingStore.playSongDemo ? null : normalizedUrl; | ||
| // 获取音质 | ||
| const quality = handleSongQuality(songData, "online"); | ||
| console.log(`[QualityDebug] getOnlineUrl quality determined: ${quality} for song ${id}`); |
| public getUnlockSongUrl = async (song: SongType): Promise<AudioSource> => { | ||
| const settingStore = useSettingStore(); | ||
| const songId = song.id; | ||
| console.log(`[QualityDebug] getUnlockSongUrl called for song ${songId}`); |
| // 优先检查本地缓存 | ||
| const cachedUrl = await this.checkLocalCache(songId); | ||
| if (cachedUrl) { | ||
| console.log(`[QualityDebug] getUnlockSongUrl found in local cache: ${cachedUrl}`); |
| if (unlockUrl && (unlockUrl.includes(".flac") || unlockUrl.includes(".wav"))) { | ||
| quality = QualityType.SQ; | ||
| } | ||
| console.log(`最终音质判断:详细输出:`, { unlockUrl, quality }); |
| */ | ||
| public getAudioSource = async (song: SongType): Promise<AudioSource> => { | ||
| const settingStore = useSettingStore(); | ||
| console.log(`[QualityDebug] getAudioSource called for song ${song.id} (${song.name})`); |
| // 如果官方链接有效且非试听(或者用户接受试听) | ||
| if (officialUrl && (!isTrial || (isTrial && settingStore.playSongDemo))) { | ||
| if (isTrial) window.$message.warning("当前歌曲仅可试听"); | ||
| console.log(`[QualityDebug] Using official URL. Quality: ${quality}`); |
| console.log(`🔓 [${songId}] 解锁成功`, unlockUrl); | ||
| console.log(`[QualityDebug] Using unlocked URL. Quality: ${unlockUrl.quality}`); |
There was a problem hiding this comment.
These lines appear to be for debugging. Logging the entire unlockUrl object should be avoided in production code. Please remove the new debug log and consider reverting the other log to its original state.
| console.log(`🔓 [${songId}] 解锁成功`, unlockUrl); | |
| console.log(`[QualityDebug] Using unlocked URL. Quality: ${unlockUrl.quality}`); | |
| console.log(`🔓 [${songId}] 解锁成功`); |
| const fallbackUrl = await this.checkLocalCache(songId); | ||
| if (fallbackUrl) { | ||
| console.log(`🚀 [${songId}] 网络请求失败,使用本地缓存兜底`); | ||
| console.log(`[QualityDebug] Fallback to cache (network fail). URL: ${fallbackUrl}`); |
No description provided.