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

Method checkSource

music_hub/music_hub.ts:1105–1143  ·  view source on GitHub ↗
(source: SourceKey)

Source from the content-addressed store, hash-verified

1103 `❌ <b>上传失败,保留下载链接</b>\n${codeTag(urlInfo.url)}\n\n` +
1104 `🌐 直拉错误: ${htmlEscape(errorText(directError))}\n` +
1105 `📤 上传错误: ${htmlEscape(errorText(fallbackError))}`
1106 );
1107 if (session) await this.deleteCommandIfDifferent(msg, session.message);
1108 }
1109 }
1110 }
1111
1112 private async checkSource(source: SourceKey): Promise<SourceCheckResult> {
1113 const started = Date.now();
1114 try {
1115 const songs = await this.searchSource(source, HEALTH_KEYWORD, 1);
1116 const first = songs[0];
1117 if (!first) {
1118 return {
1119 key: source,
1120 ok: false,
1121 elapsedMs: Date.now() - started,
1122 error: "无搜索结果",
1123 };
1124 }
1125
1126 await this.requestApi<any>(
1127 {
1128 types: "url",
1129 source,
1130 id: first.url_id || first.id,
1131 br: "128",
1132 },
1133 CHECK_TIMEOUT_MS
1134 );
1135
1136 return {
1137 key: source,
1138 ok: true,
1139 elapsedMs: Date.now() - started,
1140 sample: `${first.name} - ${formatArtists(first.artist)}`,
1141 };
1142 } catch (error) {
1143 return {
1144 key: source,
1145 ok: false,
1146 elapsedMs: Date.now() - started,

Callers 1

checkAllSourcesMethod · 0.95

Calls 2

searchSourceMethod · 0.95
formatArtistsFunction · 0.85

Tested by

no test coverage detected