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

Method downloadImages

cosplay/cosplay.ts:138–163  ·  view source on GitHub ↗
(imageUrls: string[])

Source from the content-addressed store, hash-verified

136 }
137
138 async downloadImages(imageUrls: string[]): Promise<string[]> {
139 const tasks = imageUrls.map((url) =>
140 this.limit(async () => {
141 try {
142 return await this.downloadImage(url);
143 } catch (error) {
144 console.warn(`下载失败: ${url}`, error);
145 return null;
146 }
147 })
148 );
149
150 const results = await Promise.allSettled(tasks);
151 const tempFiles = results
152 .filter(
153 (r): r is PromiseFulfilledResult<string> =>
154 r.status === "fulfilled" && r.value !== null
155 )
156 .map((r) => r.value);
157
158 if (!tempFiles.length) {
159 throw new Error("所有图片下载失败");
160 }
161
162 return tempFiles;
163 }
164
165 private async getRandomPhotoSet(): Promise<PhotoSet> {
166 return withRetry(async () => {

Callers 1

CosplayPluginClass · 0.80

Calls 2

downloadImageMethod · 0.95
warnMethod · 0.80

Tested by

no test coverage detected