@tobyg74/tiktok-api-dl
Advanced tools
Comparing version 1.1.4 to 1.1.5
export declare const _tiktokurl: string; | ||
export declare const _tiktokapi: (params: any) => string; | ||
export declare const _tiktokSearchUserFull: (params: any) => string; | ||
export declare const _tiktokSearchVideoFull: (params: any) => string; | ||
export declare const _tiktokGetPosts: (params: any) => string; | ||
export declare const _tiktokvApi: string; | ||
export declare const _tiktokvFeed: (params: any) => string; | ||
export declare const _ssstikurl: string; | ||
@@ -7,0 +8,0 @@ export declare const _ssstikapi: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._musicaldownmusicapi = exports._musicaldownapi = exports._musicaldownurl = exports._ssstikapi = exports._ssstikurl = exports._tiktokGetPosts = exports._tiktokSearchVideoFull = exports._tiktokSearchUserFull = exports._tiktokapi = exports._tiktokurl = void 0; | ||
exports._musicaldownmusicapi = exports._musicaldownapi = exports._musicaldownurl = exports._ssstikapi = exports._ssstikurl = exports._tiktokvFeed = exports._tiktokvApi = exports._tiktokGetPosts = exports._tiktokSearchVideoFull = exports._tiktokSearchUserFull = exports._tiktokurl = void 0; | ||
exports._tiktokurl = "https://www.tiktok.com"; | ||
const _tiktokapi = (params) => `https://api.tiktokv.com/aweme/v1/feed/?${params}`; | ||
exports._tiktokapi = _tiktokapi; | ||
const _tiktokSearchUserFull = (params) => `${exports._tiktokurl}/api/search/user/full/?${params}`; | ||
@@ -13,2 +11,5 @@ exports._tiktokSearchUserFull = _tiktokSearchUserFull; | ||
exports._tiktokGetPosts = _tiktokGetPosts; | ||
exports._tiktokvApi = `https://api.tiktokv.com`; | ||
const _tiktokvFeed = (params) => `${exports._tiktokvApi}/aweme/v1/feed/?${params}`; | ||
exports._tiktokvFeed = _tiktokvFeed; | ||
exports._ssstikurl = "https://ssstik.io"; | ||
@@ -15,0 +16,0 @@ exports._ssstikapi = `${exports._ssstikurl}/abc?url=dl`; |
@@ -12,7 +12,7 @@ import { MusicalDownResponse } from "./types/downloader/musicaldown"; | ||
}) => Promise<TiktokDownloaderResponse<T>>; | ||
Search: <T_1 extends "video" | "user">(query: string, options: { | ||
type: T_1; | ||
Search: <T extends "user" | "video">(query: string, options: { | ||
type: T; | ||
cookie?: string; | ||
page?: number; | ||
}) => Promise<TiktokSearchResponse<T_1>>; | ||
}) => Promise<TiktokSearchResponse<T>>; | ||
StalkUser: (username: string, options?: { | ||
@@ -19,0 +19,0 @@ cookie?: string; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const api_1 = require("../../constants/api"); | ||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/; | ||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt|lite)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/; | ||
const getRequest = (url) => new Promise((resolve, reject) => { | ||
@@ -13,0 +13,0 @@ if (!TiktokURLregex.test(url)) { |
@@ -8,5 +8,6 @@ "use strict"; | ||
const axios_1 = __importDefault(require("axios")); | ||
const async_retry_1 = __importDefault(require("async-retry")); | ||
const cheerio_1 = require("cheerio"); | ||
const api_1 = require("../../constants/api"); | ||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/; | ||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt|lite)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/; | ||
const fetchTT = () => new Promise(async (resolve, reject) => { | ||
@@ -23,6 +24,6 @@ axios_1.default.get(api_1._ssstikurl, { | ||
const value = match[1]; | ||
resolve({ status: "success", result: value }); | ||
return resolve({ status: "success", result: value }); | ||
} | ||
else { | ||
resolve({ status: "error", message: "Failed to get the request form!" }); | ||
return resolve({ status: "error", message: "Failed to get the request form!" }); | ||
} | ||
@@ -32,28 +33,37 @@ }) | ||
}); | ||
const SSSTik = (url) => new Promise(async (resolve, reject) => { | ||
if (!TiktokURLregex.test(url)) { | ||
return resolve({ | ||
status: "error", | ||
message: "Invalid Tiktok URL. Make sure your url is correct!" | ||
const SSSTik = (url) => new Promise(async (resolve) => { | ||
try { | ||
if (!TiktokURLregex.test(url)) { | ||
return resolve({ | ||
status: "error", | ||
message: "Invalid Tiktok URL. Make sure your url is correct!" | ||
}); | ||
} | ||
const tt = await fetchTT(); | ||
if (tt.status !== "success") | ||
return resolve({ status: "error", message: tt.message }); | ||
const response = (0, async_retry_1.default)(async () => { | ||
const res = await (0, axios_1.default)(api_1._ssstikapi, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | ||
Origin: api_1._ssstikurl, | ||
Referer: api_1._ssstikurl + "/en", | ||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0" | ||
}, | ||
data: new URLSearchParams(Object.entries({ | ||
id: url, | ||
locale: "en", | ||
tt: tt.result | ||
})) | ||
}); | ||
if (res.status === 200 && res.data !== "") | ||
return res.data; | ||
throw new Error("Failed to fetch data from SSSTik!"); | ||
}, { | ||
retries: 20, | ||
minTimeout: 200, | ||
maxTimeout: 1000 | ||
}); | ||
} | ||
const tt = await fetchTT(); | ||
if (tt.status !== "success") | ||
return resolve({ status: "error", message: tt.message }); | ||
(0, axios_1.default)(api_1._ssstikapi, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | ||
Origin: api_1._ssstikurl, | ||
Referer: api_1._ssstikurl + "/en", | ||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0" | ||
}, | ||
data: new URLSearchParams(Object.entries({ | ||
id: url, | ||
locale: "en", | ||
tt: tt.result | ||
})) | ||
}) | ||
.then(({ data }) => { | ||
const $ = (0, cheerio_1.load)(data); | ||
const $ = (0, cheerio_1.load)(await response); | ||
const desc = $("p.maintext").text().trim(); | ||
@@ -69,2 +79,4 @@ const author = { | ||
}; | ||
const video = $("a.without_watermark").attr("href"); | ||
const music = $("a.music").attr("href"); | ||
const images = []; | ||
@@ -76,3 +88,3 @@ $("ul.splide__list > li") | ||
}); | ||
if (images.length !== 0) { | ||
if (images.length !== 0 && music) { | ||
resolve({ | ||
@@ -86,7 +98,7 @@ status: "success", | ||
images, | ||
music: $("a.music").attr("href") | ||
music | ||
} | ||
}); | ||
} | ||
else { | ||
else if (video && music) { | ||
resolve({ | ||
@@ -99,10 +111,12 @@ status: "success", | ||
statistics, | ||
video: $("a.without_watermark").attr("href"), | ||
music: $("a.music").attr("href") | ||
video, | ||
music | ||
} | ||
}); | ||
} | ||
}) | ||
.catch((e) => resolve({ status: "error", message: e.message })); | ||
} | ||
catch (err) { | ||
resolve({ status: "error", message: err.message }); | ||
} | ||
}); | ||
exports.SSSTik = SSSTik; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const params_1 = require("../../constants/params"); | ||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/; | ||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt|lite)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/; | ||
const TiktokAPI = (url) => new Promise((resolve, reject) => { | ||
@@ -86,3 +86,3 @@ if (!TiktokURLregex.test(url)) { | ||
const fetchTiktokData = async (ID) => { | ||
const res = await fetch((0, api_1._tiktokapi)(new URLSearchParams((0, params_1._tiktokApiParams)({ | ||
const res = await fetch((0, api_1._tiktokvFeed)(new URLSearchParams((0, params_1._tiktokApiParams)({ | ||
aweme_id: ID | ||
@@ -92,2 +92,3 @@ })).toString()), { | ||
headers: { | ||
Cookie: "tt_csrf_token=g1GUApj0-ADAIP9COU6o1m1_NnbwhKGTbiyI; ttwid=1%7CvqigUFT-mdDjU8gnwF3hkh8sPQqokFjCRyD7R1jpM44%7C1720342326%7Cc8c89833ea6bb912642ea1340ef98691ad3382878374ec61a5de85eeb5d79e83; ak_bmsc=C3345397EF8621798FA50BACA05F1AD3~000000000000000000000000000000~YAAQhq0wFzqUPlOQAQAA+ctjjBiYLJJ3WVeqfLXcnxTCKMkcRlAYLT+GxhKgkMdR94wzPi2zqWiZfuEUdBpaJmo01qZY4M4dUO6xiYqbXZev0cFbauilIxyj1WRUHOy9+oAUCAkyWRMubLICOr1g9XUc7eadCgHCEnmwfVYe6mYbkwaqDMn/0mgxdqJCjnLFnEQTLG1FXUYkhk1sjrzg1ubRwJLuAdw4T+FZg2mYeQIdFuo/CUPf8Jw2UYfNd…XkpqwL-3Zzf_VO_mXrptr32f1D4TVmQPhR1FNen76-b7g2Tey2UlUrFD1fhpjJmOySmQtS_eW0p8BVLJthEcysTN98LLGTkAzD7M335V27Rf0zxX8ZsVWE6wa2P7x5X-HNmCwEO_WccrcClQifgb2PCKYDmhpG5BWNwoer5-8ak1SwZjybv_hdspeNhpbylwg4sNLRc_OiunUK0tYW2hiV7xrliwDKsIMVsZcQ0kwvBmp0eyUQJrEJv0fnzoS0o_jKMFtTvUChfEVz0Laj5O4MKf52isC30U3q; last_login_method=google; passport_fe_beating_status=true; msToken=ftn8ICq2_TfkkAyS3f6umBK1FafalSQ_IyzJxq1LmeBmDe2QxefwBfd_weMdvJI3TU5Z8gyFmzJdPSMESb5zUeseZysme5LBC19xouQTYAAMfVV35YliLfxMWhWZ_2ABP_uYMFNDJ5jtYE4Ap6uRyA==", | ||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36" | ||
@@ -94,0 +95,0 @@ } |
{ | ||
"name": "@tobyg74/tiktok-api-dl", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Scraper for downloading media in the form of videos, images and audio from Tiktok. Also for stalking Tiktok Users", | ||
@@ -36,6 +36,8 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"async-retry": "^1.3.3", | ||
"axios": "^1.3.4", | ||
"cheerio": "^1.0.0-rc.12", | ||
"crypto-js": "^4.2.0", | ||
"qs": "^6.12.0" | ||
"qs": "^6.12.0", | ||
"uuid": "^10.0.0" | ||
}, | ||
@@ -42,0 +44,0 @@ "devDependencies": { |
@@ -0,0 +0,0 @@ <h1 align="center"> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61990
29
1132
6
1
+ Addedasync-retry@^1.3.3
+ Addeduuid@^10.0.0
+ Addedasync-retry@1.3.3(transitive)
+ Addedretry@0.13.1(transitive)
+ Addeduuid@10.0.0(transitive)