downloaderjavascript154
Facebook Video & Reels Native Downloader (Direct Stream - No Third-Party)
Scraper dan downloader video serta reels Facebook 100% native direct stream tanpa bergantung pada website pihak ketiga (SnapSave/SaveFrom). Zero-dependency dan mendukung resolusi HD & SD.
Vamz Spectre29 Okt 2026239 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/facebook-native-downloader" -o facebook-native-downloader.js
# 2. Jalankan script
node facebook-native-downloader.js
Dependencies npm yang Dibutuhkan:
npm install none (zero-dependency native Node.js 18+)Panduan Penggunaan:
Download script: curl -sL "https://code.vamxapi.my.id/snippet/raw/facebook-native-downloader" -o facebook-native-downloader.js Eksekusi via terminal: node facebook-native-downloader.js "https://www.facebook.com/watch/?v=10153231379946729"
facebook-native-downloader.js(239 lines)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/**
* Facebook Video & Reels Native Downloader
* 100% Native Facebook Direct Stream Scraper (Zero-Dependency)
*
* Target: https://www.facebook.com
* Author: Vamz Spectre
* License: MIT
*
* Cara Penggunaan via CLI:
* node facebook-native-downloader.js "https://www.facebook.com/watch/?v=10153231379946729"
*
* Download Script:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/facebook-native-downloader" -o facebook-native-downloader.js
*/
/**
* Decode escape sequence URL Facebook (\u0026 -> &, \/ -> /, dll)
* @param {string} raw - String URL ter-escape
* @returns {string} URL bersih
*/
function decodeFbUrl(raw) {
if (!raw) return "";
try {
return JSON.parse(`"${raw}"`);
} catch {
return raw
.replace(/\\u0025/g, "%")
.replace(/\\u0026/g, "&")
.replace(/\\u002F/gi, "/")
.replace(/\\\//g, "/")
.replace(/&/g, "&");
}
}
/**
* Bersihkan karakter HTML Entities pada teks atau judul
* @param {string} str - String dengan entitas HTML
* @returns {string} String bersih
*/
function decodeHtmlEntities(str) {
if (!str) return "";
return str
.replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
.replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(parseInt(dec, 10)))
.replace(/&/g, "&")
.replace(/"/g, '"')
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/ /g, " ");
}
/**
* Normalisasi URL Facebook (Reels/Watch/Post)
* @param {string} url - URL Facebook mentah
* @returns {string} URL ter-normalisasi
*/
function normalizeFacebookUrl(url) {
let u = url.trim();
const reelMatch = u.match(/(?:facebook\.com|fb\.watch)\/reel\/(\d+)/i);
if (reelMatch && reelMatch[1]) {
return `https://www.facebook.com/watch/?v=${reelMatch[1]}`;
}
return u;
}
/**
* Ekstrak metadata dan direct stream URL video Facebook (HD & SD)
* @param {string} fbUrl - URL video atau reels Facebook
* @returns {Promise<object>} Metadata dan download link
*/
async function downloadFacebook(fbUrl) {
if (!fbUrl || typeof fbUrl !== "string") {
return {
status: false,
creator: "Vamz Spectre",
message: "Parameter URL Facebook wajib diisi."
};
}
const cleanUrl = normalizeFacebookUrl(fbUrl);
if (!/facebook\.com|fb\.watch/i.test(cleanUrl)) {
return {
status: false,
creator: "Vamz Spectre",
message: "URL tidak valid. Harus menyertakan domain facebook.com atau fb.watch."
};
}
const headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
"Accept-Language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
"Sec-Ch-Ua": '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": '"Windows"',
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1"
};
try {
const res = await fetch(cleanUrl, {
headers,
redirect: "follow"
});
if (!res.ok) {
return {
status: false,
creator: "Vamz Spectre",
message: `Gagal memuat halaman Facebook (HTTP status ${res.status})`
};
}
const html = await res.text();
// 1. Ekstrak Video Stream HD
let hdUrl = "";
const hdMatch =
html.match(/"browser_native_hd_url":"([^"]+)"/) ||
html.match(/"playable_url_quality_hd":"([^"]+)"/) ||
html.match(/"hd_src":"([^"]+)"/) ||
html.match(/"hd_src_no_ratelimit":"([^"]+)"/);
if (hdMatch && hdMatch[1]) {
hdUrl = decodeFbUrl(hdMatch[1]);
}
// 2. Ekstrak Video Stream SD
let sdUrl = "";
const sdMatch =
html.match(/"browser_native_sd_url":"([^"]+)"/) ||
html.match(/"playable_url":"([^"]+)"/) ||
html.match(/"sd_src":"([^"]+)"/) ||
html.match(/"sd_src_no_ratelimit":"([^"]+)"/);
if (sdMatch && sdMatch[1]) {
sdUrl = decodeFbUrl(sdMatch[1]);
}
// 3. Fallback OpenGraph jika stream native belum ditemukan
if (!hdUrl && !sdUrl) {
const ogVideo =
html.match(/<meta\s+property="og:video"\s+content="([^"]+)"/i) ||
html.match(/<meta\s+content="([^"]+)"\s+property="og:video"/i) ||
html.match(/"video":\s*\[\s*\{\s*"url":\s*"([^"]+)"/i);
if (ogVideo && ogVideo[1]) {
sdUrl = decodeFbUrl(ogVideo[1]);
}
}
if (!hdUrl && !sdUrl) {
return {
status: false,
creator: "Vamz Spectre",
message: "Tidak dapat menemukan stream video. Pastikan video bersifat publik dan link masih aktif."
};
}
// 4. Ekstrak Judul
let title = "";
const titleMatch =
html.match(/<meta\s+property="og:title"\s+content="([^"]+)"/i) ||
html.match(/<title>([^<]+)<\/title>/i);
if (titleMatch && titleMatch[1]) {
title = decodeHtmlEntities(decodeFbUrl(titleMatch[1].replace(/ \| Facebook$/i, "").trim()));
}
// 5. Ekstrak Thumbnail
let thumbnail = "";
const thumbMatch =
html.match(/<meta\s+property="og:image"\s+content="([^"]+)"/i) ||
html.match(/"preferred_thumbnail":{"image":{"uri":"([^"]+)"/i);
if (thumbMatch && thumbMatch[1]) {
thumbnail = decodeFbUrl(thumbMatch[1]);
}
// 6. Ekstrak Durasi
let duration = null;
const durMatch = html.match(/"playable_duration_in_ms":(\d+)/);
if (durMatch && durMatch[1]) {
duration = Math.round(Number(durMatch[1]) / 1000);
}
const medias = [];
if (hdUrl) {
medias.push({ quality: "HD", url: hdUrl });
}
if (sdUrl) {
medias.push({ quality: "SD", url: sdUrl });
}
const primaryVideoUrl = hdUrl || sdUrl;
return {
status: true,
creator: "Vamz Spectre",
result: {
title: title || "Facebook Video",
duration: duration || null,
thumbnail: thumbnail || null,
video: primaryVideoUrl,
medias,
source: "facebook_native_direct"
}
};
} catch (err) {
return {
status: false,
creator: "Vamz Spectre",
message: err.message || "Terjadi kesalahan saat memproses video Facebook"
};
}
}
// CLI Runner
if (require.main === module) {
const targetUrl = process.argv[2];
if (!targetUrl) {
console.error("Usage: node facebook-native-downloader.js <facebook_video_or_reel_url>");
process.exit(1);
}
downloadFacebook(targetUrl)
.then((res) => {
console.log(JSON.stringify(res, null, 2));
process.exit(res.status ? 0 : 1);
})
.catch((err) => {
console.error(JSON.stringify({ status: false, creator: "Vamz Spectre", error: err.message }, null, 2));
process.exit(1);
});
}
module.exports = { downloadFacebook };