MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / handleDownload

Method handleDownload

music/music.ts:2097–2315  ·  view source on GitHub ↗
(msg: Api.Message, query: string)

Source from the content-addressed store, hash-verified

2095 });
2096 return;
2097 }
2098
2099 // 先编辑原消息显示处理中
2100 await msg.edit({
2101 text: "🎵 <b>处理中...</b>",
2102 parseMode: "html",
2103 });
2104
2105 // 创建一个状态消息用于后续更新
2106 const statusMsg = msg;
2107
2108 try {
2109 let url: string | null = null;
2110 let metadata: SongInfo | undefined;
2111
2112 // Check if input is URL
2113 if (query.includes("youtube.com") || query.includes("youtu.be")) {
2114 url = query;
2115 } else {
2116 // 解析查询获取元数据(可能使用 AI)
2117 metadata = await this.parseQuery(query);
2118 console.log(
2119 `[music] 查询解析结果: ${metadata.artist} - ${metadata.title}`
2120 );
2121
2122 // 显示AI识别结果
2123 const recognitionText = metadata.album
2124 ? `${metadata.artist} - ${metadata.title} - ${metadata.album}`
2125 : `${metadata.artist} - ${metadata.title}`;
2126
2127 await statusMsg.edit({
2128 text: `🤖 <b>AI 识别结果:</b> ${Utils.escape(recognitionText)}`,
2129 parseMode: "html",
2130 });
2131
2132 // 使用 yt-dlp 搜索,加入"動態歌詞"关键词
2133 const searchQuery = `${recognitionText} lyrics`;
2134 url = await this.downloader.search(searchQuery, metadata.duration);
2135 }
2136
2137 if (!url) {
2138 await statusMsg.edit({
2139 text: `😔 <b>未找到相关音乐</b>
2140
2141🔍 <b>建议尝试:</b>
2142• 更换搜索关键词
2143• 配置 Cookie 绕过地区限制
2144• 使用 WARP 改善网络连接
2145
2146⚙️ <b>快速配置:</b>
2147<code>${commandName} set cookie [Cookie]</code>
2148<code>${commandName} set api_key [Gemini密钥]</code>`,
2149 parseMode: "html",
2150 });
2151 return;
2152 }
2153
2154 // Download

Callers 1

executeMethod · 0.95

Calls 10

initializeMethod · 0.95
parseQueryMethod · 0.95
checkYtDlpMethod · 0.80
checkDependenciesMethod · 0.80
searchMethod · 0.80
downloadMethod · 0.80
editMethod · 0.45
escapeMethod · 0.45
deleteMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected