(response: string, userInput: string)
| 133 | let title = '', artist = '', album = ''; |
| 134 | for (const line of lines) { |
| 135 | if (line.includes('歌曲名')) { title = line.split(/[::]/)[1]?.trim(); } |
| 136 | else if (line.includes('歌手')) { artist = line.split(/[::]/)[1]?.trim(); } |
| 137 | else if (line.includes('专辑')) { album = line.split(/[::]/)[1]?.trim(); } |
| 138 | } |
| 139 | return { |
| 140 | title: title || userInput, |
| 141 | artist: artist || '未知', |
| 142 | album: album || '未知', |
| 143 | }; |
| 144 | } |
| 145 | |
| 146 | async function searchAndDownloadCover(query: string, savePath: string): Promise<boolean> { |
| 147 | try { |
| 148 | const searchUrl = `https://itunes.apple.com/search?term=${encodeURIComponent(query)}&entity=song&limit=1`; |
| 149 | const { data } = await axios.get(searchUrl); |
| 150 | if (data.results && data.results.length > 0) { |
| 151 | let imageUrl = data.results[0].artworkUrl100; |
no outgoing calls
no test coverage detected