Skip to content

Commit 49f3a53

Browse files
committed
fix name
1 parent 979a56d commit 49f3a53

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

scripts/tiktok_batchDownload.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,10 @@ export default {
264264
});
265265
const downVideoBtn = container.querySelector("button#video");
266266
downVideoBtn.addEventListener("click", () => {
267-
download(
268-
"video/mp4",
269-
getShowingVideos().map((_, i) => {
267+
download({
268+
folderName: "tiktok_videos",
269+
expectBlobType: "video/mp4",
270+
data: getShowingVideos().map((_, i) => {
270271
const urlList =
271272
_.video?.bitrateInfo?.find?.(
272273
(b) => b.Bitrate === _.video.bitrate
@@ -284,17 +285,17 @@ export default {
284285
".mp4",
285286
};
286287
}),
287-
(i, total) => {
288+
onProgressItem: (i, total) => {
288289
UfsGlobal.DOM.notify({
289290
msg: `Downloading... ${i}/${total} videos`,
290291
duration: 30000,
291292
});
292293
},
293-
(i, total) => {
294+
onFinishItem: (i, total) => {
294295
downVideoBtn.textContent = `🎬 Download video (${i}/${total})`;
295296
UfsGlobal.DOM.notify({ msg: `Downloaded ${i}/${total} videos` });
296-
}
297-
);
297+
},
298+
});
298299
});
299300
const downAudioBtn = container.querySelector("button#audio");
300301
downAudioBtn.addEventListener("click", () => {
@@ -303,8 +304,9 @@ export default {
303304
if (!uniqueMusic.has(item.music.id))
304305
uniqueMusic.set(item.music.id, item);
305306
}
306-
download(
307-
Array.from(uniqueMusic.values()).map((_, i) => ({
307+
download({
308+
folderName: "tiktok_musics",
309+
data: Array.from(uniqueMusic.values()).map((_, i) => ({
308310
url: _.music.playUrl,
309311
filename:
310312
i +
@@ -316,17 +318,17 @@ export default {
316318
) +
317319
".mp3",
318320
})),
319-
(i, total) => {
321+
onProgressItem: (i, total) => {
320322
UfsGlobal.DOM.notify({
321323
msg: `Downloading... ${i}/${total} audios`,
322324
duration: 30000,
323325
});
324326
},
325-
(i, total) => {
327+
onFinishItem: (i, total) => {
326328
downAudioBtn.textContent = `🎧 Download audio (${i}/${total})`;
327329
UfsGlobal.DOM.notify({ msg: `Downloaded ${i}/${total} audios` });
328-
}
329-
);
330+
},
331+
});
330332
});
331333
const downJsonBtn = container.querySelector("button#json");
332334
downJsonBtn.addEventListener("click", () => {
@@ -425,13 +427,14 @@ export default {
425427
.join("");
426428
}
427429

428-
async function download(
430+
async function download({
431+
folderName = "tiktok",
429432
expectBlobType,
430433
data,
431434
onProgressItem,
432-
onFinishItem
433-
) {
434-
const dir = await UfsGlobal.Utils.chooseFolderToDownload("tiktok");
435+
onFinishItem,
436+
}) {
437+
const dir = await UfsGlobal.Utils.chooseFolderToDownload(folderName);
435438
onProgressItem?.(0, data.length);
436439

437440
for (let i = 0; i < data.length; ++i) {

0 commit comments

Comments
 (0)