Skip to content

Commit

Permalink
add tiktok downloader HD
Browse files Browse the repository at this point in the history
  • Loading branch information
thoriqazzikraa committed Sep 25, 2023
1 parent 18fea00 commit 480089f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const scrape = require("scrape-websitee")
ttsModel,
},
downloader: {
tiktokHD, // (url)
soundcloud, // (url)
spotify, // (url)
igStory, // (username)
Expand Down
33 changes: 33 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,38 @@ const pickRandom = async (ext) => {
return ext[Math.floor(Math.random() * ext.length)]
}

async function tiktokHD(url) {
let result = {}
const bodyForm = new formData()
bodyForm.append("q", url)
bodyForm.append("lang", "id")
try {
const { data } = await axios(`https://savetik.co/api/ajaxSearch`, {
method: "post",
data: bodyForm,
headers: {
"content-type": "application/x-www-form-urlencoded",
"User-Agent": "PostmanRuntime/7.32.2"
}
})
const $ = cheerio.load(data.data)
$("div.video-data > div > .tik-right > div > p").filter(function () {
if ($(this).find("a").text().includes("HD")) {
result.status = true
result.title = $("div.video-data > div > .tik-left > div > .content > div > h3").text()
result.quality = $(this).find("a").text().split("MP4 ")[1]
result.url = $(this).find("a").attr("href")
}
})
return result
} catch (err) {
result.status = false
result.message = "Video not found!"
console.log(result)
return result
}
}

async function soundcloud(url) {
if (!checkUrl.isUrl(url)) throw new Error("Please input url")
if (!url.includes("soundcloud.com")) throw new Error("Invalid soundcloud url")
Expand Down Expand Up @@ -889,6 +921,7 @@ module.exports = {
ttsModel
},
downloader: {
tiktokHD,
soundcloud,
spotify,
igStory,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrape-websitee",
"version": "1.0.46",
"version": "1.0.47",
"description": "Website Scraping",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 480089f

Please sign in to comment.