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

Function searchAndDownloadCover

convert/convert.ts:150–171  ·  view source on GitHub ↗
(query: string, savePath: string)

Source from the content-addressed store, hash-verified

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;
152 if (imageUrl) {
153 imageUrl = imageUrl.replace('100x100bb.jpg', '600x600bb.jpg');
154 const response = await axios.get(imageUrl, { responseType: 'stream' });
155 const writer = fs.createWriteStream(savePath);
156 response.data.pipe(writer);
157 return new Promise((resolve, reject) => {
158 writer.on('finish', () => resolve(true));
159 writer.on('error', () => reject(false));
160 });
161 }
162 }
163 } catch (error) {
164 console.error("Cover search failed:", error);
165 }
166 return false;
167}
168
169// --- Main Converter Class ---
170class VideoConverter {
171 public readonly tempDir: string;
172
173 constructor() {
174 this.tempDir = path.join(process.cwd(), "temp", "convert");

Callers 1

handleVideoConversionMethod · 0.85

Calls 2

errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected