TikTok-Api
TikTok-Api copied to clipboard
[FEATURE_REQUEST] - How to get watermarkless videos
const fetch = require('node-fetch');
function generateDeviceId() {
var i = 1, a = new Array(19);//Math.floor(Math.random() * 9) + 11
a[0] = 54;//Math.floor(Math.random() * 9) + 49
while (i < a.length) {
a[i++] = Math.floor(Math.random() * 10) + 48;
}
return String.fromCharCode.apply(null, a);
}
function generateBase62(length) {
var i = 0, r = "", base62 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
while (i < length) {
r += base62.charAt(Math.floor(Math.random() * 62));
i++;
}
return r;
}
function requestAweme(path) {
return new Promise((resolve, reject)=>{
const date = new Date();
const time = date.getTime() - date.getTimezoneOffset() * 60000;
const requestURL = "https://api-t2.tiktokv.com" + path
+ "®ion=US"
//+ "&version_name=10.0.0"
+ "&ts=" + Math.floor(time / 1000)
+ "&timezone_name=Etc%2FGMT"
+ "&device_type=Pixel%20" + generateBase62(8);
+ "&iid=" + generateDeviceId()
+ "&locale=en"
+ "&app_type=normal"
//+ "&build_number=10.0.0"
+ "&resolution=1080*1920"
+ "&aid=1180"
+ "&app_name=musical_ly"
+ "&_rticket=" + time
+ "&device_platform=android"
+ "&version_code=100000"
+ "&dpi=441"
+ "&cpu_support64=false"
+ "&sys_region=US"
+ "&timezone_offset=0"
+ "&device_id=" + generateDeviceId()
+ "&pass-route=1"
+ "&device_brand=google"
+ "&os_version=8.0.0"
//+ "&ab_version=10.0.0"
+ "&op_region=US"
+ "&app_language=en"
+ "&pass-region=1"
+ "&language=en"
+ "&channel=googleplay";
fetch(requestURL, {
headers: {
'User-Agent': 'okhttp'
}
}).then(async (response)=>{
response.json().then(resolve);
}).catch(reject);
});
}
async function requestVideoDetail(id) {
return await requestAweme("/aweme/v1/aweme/detail/?aweme_id=" + id);
}
async function requestVideosDetail(ids) {
return await requestAweme("/aweme/v1/multi/aweme/detail/?aweme_ids=[" + (typeof ids === "string" ? ids : ids.join()) + "]");
}
// example usage of above functions
(async function(){
const exampleData = await requestVideoDetail('7006347072731401477'); // excuse the cringe, I picked a random video
const secretID = exampleData.aweme_detail.video.play_addr.uri; // you can use this to manually query for watermarkless videos
console.log(secretID);
// or you can just get the URLs from the response
const watermarklessURLs = exampleData.aweme_detail.video.play_addr.url_list;
console.log(watermarklessURLs)
})();
Thank me later.
Thank you so much :smiling_face_with_three_hearts: