Skip to content

Commit

Permalink
fix user-agent issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Tairraos committed Sep 20, 2022
1 parent 9cf4574 commit ab6401b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 9 additions & 12 deletions downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async function parseVideoInfo(task) {
break;
case "vm.tiktok":
case "www.tiktok":
apiurl = `https://api-h2.tiktokv.com/aweme/v1/feed/?version_code=2613&aweme_id=${task.videoId}&device_type=Pixel%204`;
apiurl = `https://api-h2.tiktokv.com/aweme/v1/feed/?version_code=2613&aweme_id=${task.videoId}&device_type=iPad`;
result = await fetchURL(apiurl);
if (result.status_code !== 0) {
return { success: false, reason: result.status_msg };
Expand All @@ -199,17 +199,14 @@ async function parseVideoInfo(task) {
}

async function fetchURL(url) {
const response = await fetch(url, {
headers: {
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"cache-control": "no-cache",
pragma: "no-cache"
},
referrerPolicy: "strict-origin-when-cross-origin",
method: "GET",
mode: "cors"
});

let headers = new Headers();
headers.set("Referer", "no-referrer");
let requestOptions = {
method: "POST",
headers: headers,
redirect: "follow"
};
let response = await fetch(url, requestOptions);
return response.redirected ? response : await response.json();
}

Expand Down
4 changes: 4 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ function createWindow() {

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

// setup user-agent
config.mainWindow.webContents.userAgent = "Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3";
config.mainWindow.loadFile("index.html");
}

Expand Down Expand Up @@ -124,6 +127,7 @@ app.on("ready", () => {
}

initIPC();

});

app.on("second-instance", () => config.mainWindow.show());
Expand Down

0 comments on commit ab6401b

Please sign in to comment.