MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / download

Function download

scripts/douyin_batchDownload.js:418–445  ·  view source on GitHub ↗
({
        folderName = "douyin",
        expectBlobTypes,
        data,
        onProgressItem,
        onFinishItem,
      })

Source from the content-addressed store, hash-verified

416 }).$mount(div);
417
418 async function download({
419 folderName = "douyin",
420 expectBlobTypes,
421 data,
422 onProgressItem,
423 onFinishItem,
424 }) {
425 const dir = await UfsGlobal.Utils.chooseFolderToDownload(folderName);
426 onProgressItem?.(0, data.length);
427
428 UfsGlobal.Extension.trackEvent("douyin_batchDownload-download");
429 for (let i = 0; i < data.length; ++i) {
430 try {
431 onProgressItem?.(i + 1, data.length);
432 const { url, filename } = data[i];
433 const realUrl = await UfsGlobal.Utils.getRedirectedUrl(url);
434 await UfsGlobal.Utils.downloadToFolder({
435 url: realUrl,
436 fileName: filename,
437 dirHandler: dir,
438 expectBlobTypes,
439 });
440 onFinishItem?.(i + 1, data.length);
441 } catch (e) {
442 console.error(e);
443 }
444 }
445 }
446 },
447 },
448};

Callers 2

downloadVideoFunction · 0.70
downloadAudioFunction · 0.70

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected