Skip to content

Commit

Permalink
pre release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tairraos committed Aug 16, 2022
1 parent a3a869e commit c6dc8e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
27 changes: 18 additions & 9 deletions downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ const taskQueue = {},
};

function parseContent(urlStr) {
return urlStr.match(/https?:\/\/(www\.tiktok\.com\/@[^/]+\/video\/(\d+)|www\.douyin\.com\/video\/(\d+)|v\.douyin\.com\/([^/]+)\/)/);
let parsed = urlStr.match(
/https?:\/\/(www\.tiktok\.com\/@[^/]+\/video\/(\d+)|vm\.tiktok\.com\/([^/]+)\/|www\.douyin\.com\/video\/(\d+)|v\.douyin\.com\/([^/]+)\/)/
);

return parsed ? {
videoUrl: parsed[0],
type: parsed[1].replace(/((www|v|vm)\.(tiktok|douyin)).*/, "$1"),
shareId: parsed.slice(2).filter((n) => n)[0]
} : null;
}

function watchClipboard(toggle) {
Expand All @@ -37,9 +45,9 @@ function watchClipboard(toggle) {
}

async function parseShareId(task) {
if (task.type === "v.douyin") {
const parsed = parseContent((await fetchURL(task.videoUrl))["url"]);
return parsed[3];
if (task.type === "v.douyin" || task.type === "vm.tiktok") {
let parsed = parseContent((await fetchURL(task.videoUrl))["url"]);
return parsed.shareId;
}
return task.shareId;
}
Expand Down Expand Up @@ -69,8 +77,8 @@ async function manageTask() {
return flashPasteBtnUI(STAT_ERROR);
}

const shareId = parsed[2] || parsed[3] || parsed[4];
if ($(`.task-${shareId}`)) {
const shareId = parsed.shareId;
if ($(`.task-${parsed.shareId}`)) {
printFooterLog("The same task is already in the download list.");
taskStore.isParseBusy = false;
return flashPasteBtnUI(STAT_ERROR);
Expand All @@ -79,9 +87,9 @@ async function manageTask() {
const taskId = taskStore.newTaskId++,
task = {
taskId,
shareId,
type: parsed[1].replace(/((www|v)\.(tiktok|douyin)).*/, "$1"),
videoUrl: parsed[0],
videoUrl: parsed.videoUrl,
type: parsed.type,
shareId: parsed.shareId,
domId: shareId
};
taskQueue[taskId] = task;
Expand Down Expand Up @@ -199,6 +207,7 @@ async function parseVideoInfo(task) {
rootInfo = result["item_list"][0];
rootInfo.fileurl = (await fetchURL(rootInfo["video"]["play_addr"]["url_list"][0].replace("playwm", "play")))["url"];
break;
case "vm.tiktok":
case "www.tiktok":
apiurl = `https://api.tiktokv.com/aweme/v1/aweme/detail/?aweme_id=${task.videoId}`;
result = await fetchURL(apiurl);
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function createWindow() {
});

// open debug
// config.mainWindow.webContents.openDevTools();
config.mainWindow.webContents.openDevTools();

config.mainWindow.loadFile("index.html");
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"downloader"
],
"main": "./main.js",
"version": "1.1.1",
"version": "1.2.0",
"author": "Tairraos",
"license": "MIT",
"scripts": {
Expand Down

0 comments on commit c6dc8e1

Please sign in to comment.