Tiktok Downloader (All Support)
Tiktok Downloader Via API Full Support (Foto, Video)
JSJavaScriptPublicAPIsTanpa lisensi1 file · 141 baris · 4.1 KBDiperbarui 24 Okt 202617 views
https://codeku.itsuki-nakano.my.id/repo/wilz/tiktok-downloader-all-supportcurl -s https://codeku.itsuki-nakano.my.id/raw/wilz/tiktok-downloader-all-supportFILES
tiktokdl.js · javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* Scraper TikTok Downloader
* Creator : @wilz
* Base : https://wilz.web.id/
*
* Fitur:
* - Sanitasi input URL TikTok.
* - Ekstraksi aman (optional chaining) untuk properti null.
* - Normalisasi data dari berbagai kemungkinan format respons API V3.
* - Struktur data hasil return yang bersih dan terstandarisasi.
*
* Instalasi:
* npm i axios
*
* CLI:
* node scraper/tiktokdl.js "https://vt.tiktok.com/ZSxxxx/"
*/
const axios = require('axios');
// ─── Konfigurasi ────────────────────────────────────────────────
const API_URL = 'https://api.wilz.web.id/api/download/tiktokv3';
const TIMEOUT = 30000;
const client = axios.create({
timeout: TIMEOUT,
headers: {
'User-Agent':
'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Mobile Safari/537.36',
Accept: 'application/json, text/plain, */*',
'Accept-Language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
},
});
// ─── Helper: Sanitasi URL ───────────────────────────────────────
function sanitizeUrl(input) {
return String(input || '').trim();
}
function isTiktokUrl(url) {
return /(tiktok\.com|vt\.tiktok\.com|vm\.tiktok\.com)/i.test(url);
}
// ─── Helper: Normalisasi Respons ────────────────────────────────
function normalize(json, sourceUrl) {
// API mungkin membungkus result di dalam "data" atau "result"
const root = json.data || json.result || json;
// Cek status error
const status = json.status || root.status;
if (status === 'error' || json.success === false) {
throw new Error(`API Error: ${json.message || root.message || 'Gagal mengambil data'}`);
}
const result = root.result || root;
const author = result.author || {};
const music = result.music || {};
return {
success: true,
source: sourceUrl,
type: result.type || 'video',
title: result.desc || result.title || '',
author: {
nickname: author.nickname || null,
avatar: author.avatar || null,
},
music: {
title: typeof music === 'object' ? music.title : music,
url: typeof music === 'object' ? music.playUrl || music.url : null,
},
video: {
hd: result.videoHD || result.video_hd || result.hd || null,
watermark: result.videoWatermark || result.video_watermark || result.watermark || null,
noWatermark: result.videoNowm || result.video_no_watermark || result.nowm || null,
},
images: Array.isArray(result.images) ? result.images : [],
raw: result, // Menyimpan data mentah untuk referensi
fetchedAt: new Date().toISOString(),
};
}
// ─── Fungsi Utama ───────────────────────────────────────────────
async function downloadTiktok(rawUrl) {
const targetUrl = sanitizeUrl(rawUrl);
if (!targetUrl) {
throw new Error('URL TikTok wajib diisi.');
}
if (!isTiktokUrl(targetUrl)) {
throw new Error('URL yang diberikan bukan dari TikTok.');
}
console.log(`[Scraper] Mengambil data untuk: ${targetUrl}`);
let res;
try {
res = await client.get(API_URL, { params: { url: targetUrl } });
} catch (err) {
if (err.response) {
throw new Error(`API Error (HTTP ${err.response.status}): ${JSON.stringify(err.response.data)}`);
}
throw new Error(`Koneksi gagal: ${err.message}`);
}
const json = res.data;
if (!json || typeof json !== 'object') {
throw new Error('Respons API tidak valid (bukan JSON).');
}
return normalize(json, targetUrl);
}
// ─── CLI Handler ────────────────────────────────────────────────
if (require.main === module) {
const url = process.argv[2];
if (!url) {
console.error(
'❌ Kesalahan: URL tidak ditemukan!\n\n' +
'Cara Penggunaan (CLI):\n' +
' node scraper/tiktok-v3.js "<url_tiktok>"\n\n' +
'Contoh:\n' +
' node scraper/tiktok-v3.js "https://vt.tiktok.com/ZSxxxx/"'
);
process.exit(1);
}
(async () => {
try {
const result = await downloadTiktok(url);
console.log('\n✅ Hasil Scrape Berhasil & Divalidasi:');
console.log(JSON.stringify(result, null, 2));
} catch (err) {
console.error('❌ Error:', err.message);
process.exit(1);
}
})();
}
module.exports = { downloadTiktok };PLAYGROUND
Siap
Klik Jalankan untuk melihat output.
Kode berjalan di kotak terisolasi di browser kamu. Tidak punya akses ke cookie, akun, atau server NAKANO CODE, dan tidak bisa membuka koneksi internet. Batas waktu 4 detik. Kode bot yang memanggil library WhatsApp (seperti Baileys) tidak bisa jalan di sini.