-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathexample.html
More file actions
278 lines (258 loc) · 12.1 KB
/
Copy pathexample.html
File metadata and controls
278 lines (258 loc) · 12.1 KB
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Playground Test CDN btch-downloader</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f9f9fb;
color: #222;
max-width: 900px;
margin: 40px auto;
padding: 25px;
}
h1 {
color: #0078ff;
text-align: center;
}
input {
width: 60%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 15px;
}
select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 15px;
margin-right: 10px;
}
button {
padding: 10px 20px;
border: none;
border-radius: 6px;
background: #0078ff;
color: white;
cursor: pointer;
}
button:hover {
background: #005ecc;
}
pre {
text-align: left;
background: #fff;
border: 1px solid #ddd;
border-radius: 6px;
padding: 10px;
overflow-x: auto;
white-space: pre-wrap;
}
hr {
margin: 30px 0;
}
ul {
text-align: left;
background: #fff;
border-radius: 6px;
padding: 15px;
border: 1px solid #ddd;
}
li {
margin-bottom: 6px;
}
a {
color: #0078ff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.info {
text-align: center;
margin-top: 10px;
font-size: 14px;
color: #555;
}
</style>
</head>
<body>
<h1>Playground</h1>
<p align="center">A single-page downloader for all supported platforms.</p>
<div align="center">
<select id="platformSelect">
<option value="auto">Auto Detect</option>
<option value="instagram">Instagram</option>
<option value="tiktok">TikTok</option>
<option value="facebook">Facebook</option>
<option value="twitter">Twitter</option>
<option value="youtube">YouTube</option>
<option value="mediafire">MediaFire</option>
<option value="capcut">CapCut</option>
<option value="gdrive">Google Drive</option>
<option value="pinterest">Pinterest</option>
<option value="douyin">Douyin</option>
<option value="xiaohongshu">Xiaohongshu</option>
<option value="xiaohongshuProfile">Xiaohongshu Profile</option>
<option value="snackvideo">SnackVideo</option>
<option value="cocofun">Cocofun</option>
<option value="spotify">Spotify</option>
<option value="yts">YTS</option>
<option value="soundcloud">SoundCloud</option>
<option value="threads">Threads</option>
<option value="kuaishou">Kuaishou</option>
</select>
<input id="urlInput" placeholder="Paste any supported URL here..." />
<button id="downloadBtn">Fetch</button>
</div>
<div class="info">
Developer: <strong>@prm2.0</strong> —
<a href="https://github.com/hostinger-bot/btch-downloader/issues" target="_blank">Report Issues</a>
</div>
<h3>Result:</h3>
<pre id="output">No data yet...</pre>
<hr>
<h3>Example URLs</h3>
<ul>
<li>Instagram: <a href="https://www.instagram.com/reel/DKPtUL_S9Nh/?igsh=MTE1dTVkb2E4NTFmcw==" target="_blank">https://www.instagram.com/reel/DKPtUL_S9Nh/?igsh=MTE1dTVkb2E4NTFmcw==</a></li>
<li>TikTok: <a href="https://www.tiktok.com/@omagadsus/video/7025456384175017243" target="_blank">https://www.tiktok.com/@omagadsus/video/7025456384175017243</a></li>
<li>Facebook: <a href="https://www.facebook.com/watch/?v=1393572814172251" target="_blank">https://www.facebook.com/watch/?v=1393572814172251</a></li>
<li>Twitter: <a href="https://twitter.com/gofoodindonesia/status/1229369819511709697" target="_blank">https://twitter.com/gofoodindonesia/status/1229369819511709697</a></li>
<li>YouTube: <a href="https://youtu.be/C8mJ8943X80" target="_blank">https://youtu.be/C8mJ8943X80</a></li>
<li>MediaFire: <a href="https://www.mediafire.com/file/941xczxhn27qbby/GBWA_V12.25FF-By.SamMods-.apk/file" target="_blank">https://www.mediafire.com/file/941xczxhn27qbby/GBWA_V12.25FF-By.SamMods-.apk/file</a></li>
<li>CapCut: <a href="https://www.capcut.com/template-detail/7299286607478181121" target="_blank">https://www.capcut.com/template-detail/7299286607478181121</a></li>
<li>Google Drive: <a href="https://drive.google.com/file/d/1thDYWcS5p5FFhzTpTev7RUv0VFnNQyZ4/view" target="_blank">https://drive.google.com/file/d/1thDYWcS5p5FFhzTpTev7RUv0VFnNQyZ4/view</a></li>
<li>Pinterest: <a href="https://pin.it/4CVodSq" target="_blank">https://pin.it/4CVodSq</a> or query (e.g., "Zhao Lusi")</li>
<li>Douyin: <a href="https://v.douyin.com/ikq8axJ/" target="_blank">https://v.douyin.com/ikq8axJ/</a></li>
<li>Xiaohongshu: <a href="https://xhslink.com/o/21DKXV988zp" target="_blank">https://xhslink.com/o/21DKXV988zp</a></li>
<li>Xiaohongshu Profile: <a href="https://www.xiaohongshu.com/user/profile/67873204000000000803d9a5" target="_blank">https://www.xiaohongshu.com/user/profile/67873204000000000803d9a5</a></li>
<li>SnackVideo: <a href="https://s.snackvideo.com/p/j9jKr9dR" target="_blank">https://s.snackvideo.com/p/j9jKr9dR</a></li>
<li>Cocofun: <a href="https://www.icocofun.com/share/post/379250110809" target="_blank">https://www.icocofun.com/share/post/379250110809</a></li>
<li>Spotify: <a href="https://open.spotify.com/track/3zakx7RAwdkUQlOoQ7SJRt" target="_blank">https://open.spotify.com/track/3zakx7RAwdkUQlOoQ7SJRt</a></li>
<li>SoundCloud: <a href="https://soundcloud.com/issabella-marchelina/sisa-rasa-mahalini-official-audio?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing" target="_blank">https://soundcloud.com/issabella-marchelina/sisa-rasa-mahalini-official-audio?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing</a></li>
<li>Threads: <a href="https://www.threads.com/@prm2.0/post/DUAdQcAkhRP?xmt=AQG0V_OPLTmE_5E242r6SPgYY_ofjuQxxRsZwS92_gBAKy4ctmOEbZP5cnKEibNlvn_8l-oK&slof=1" target="_blank">https://www.threads.com/@prm2.0/post/DUAdQcAkhRP?xmt=AQG0V_OPLTmE_5E242r6SPgYY_ofjuQxxRsZwS92_gBAKy4ctmOEbZP5cnKEibNlvn_8l-oK&slof=1</a></li>
<li>Kuaishou: <a href="https://v.kuaishou.com/JT195ZHT" target="_blank">https://v.kuaishou.com/JT195ZHT</a></li>
<li>YTS: <a href="#" target="_blank">Enter a YTS query (e.g., "movie title 2023")</a></li>
</ul>
<!-- Load btch CDN -->
<script src="https://cdn.jsdelivr.net/npm/btch-downloader@6.3.6/dist/browser/index.min.js" integrity="sha384-paQDBreWMHR8NI4nCcElcNf4zVMl/bxYh6Ns6oEZgYzEoSnr0YR2kXp17Vhh1nE0" crossorigin="anonymous"></script>
<script>
const output = document.getElementById("output");
const btn = document.getElementById("downloadBtn");
const input = document.getElementById("urlInput");
const platformSelect = document.getElementById("platformSelect");
const platformPlaceholders = {
auto: "Paste any supported URL here...",
instagram: "Paste Instagram URL (e.g., https://www.instagram.com/reel/DKPtUL_S9Nh/?igsh=MTE1dTVkb2E4NTFmcw==)",
tiktok: "Paste TikTok URL (e.g., https://www.tiktok.com/@user/video/123)",
facebook: "Paste Facebook URL (e.g., https://www.facebook.com/watch/?v=123)",
twitter: "Paste Twitter URL (e.g., https://twitter.com/user/status/123)",
youtube: "Paste YouTube URL (e.g., https://youtu.be/C8mJ8943X80)",
mediafire: "Paste MediaFire URL (e.g., https://www.mediafire.com/file/123)",
capcut: "Paste CapCut URL (e.g., https://www.capcut.com/template-detail/123)",
gdrive: "Paste Google Drive URL (e.g., https://drive.google.com/file/d/123)",
pinterest: "Paste Pinterest URL (e.g., https://pin.it/4CVodSq)",
douyin: "Paste Douyin URL (e.g., https://v.douyin.com/ikq8axJ/)",
xiaohongshu: "Paste Xiaohongshu URL (e.g., https://xhslink.com/o/123)",
xiaohongshuProfile: "Paste Xiaohongshu Profile URL (e.g., https://www.xiaohongshu.com/user/profile/abc123)",
snackvideo: "Paste SnackVideo URL (e.g., https://s.snackvideo.com/p/123)",
cocofun: "Paste Cocofun URL (e.g., https://www.icocofun.com/share/post/123)",
spotify: "Paste Spotify URL (e.g., https://open.spotify.com/track/123)",
soundcloud: "Paste SoundCloud URL (e.g., https://soundcloud.com/xxxxc)",
threads: "Paste Threads URL (e.g., https://www.threads.com/@prm2.0/post/DUAdQcAkhRP?xmt=AQG0V_OPLTmE_5E242r6SPgYY_ofjuQxxRsZwS92_gBAKy4ctmOEbZP5cnKEibNlvn_8l-oK&slof=1)",
kuaishou: "Paste Kuaishou URL (e.g., https://v.kuaishou.com/JT195ZHT)",
yts: "Enter YTS query (e.g., 'movie title 2023')"
};
const regexMap = {
instagram: /instagram\.com\/(p|reel|tv)\//i,
tiktok: /(tiktok\.com\/@[\w.-]+\/video\/\d+|vm\.tiktok\.com|vt\.tiktok\.com)/i,
facebook: /(facebook\.com\/(?:watch\/?\?v=|reel\/|share\/?|sharer\.php\?u=|photo\.php\?fbid=|video\.php\?v=|\w+\/(?:videos|posts)\/)|fb\.watch\/)\d+/i,
twitter: /(twitter\.com\/\w+\/status\/\d+|x\.com\/\w+\/status\/\d+)/i,
youtube: /(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/shorts\/|youtube\.com\/embed\/)[a-zA-Z0-9_-]+/i,
mediafire: /mediafire\.com\/(file|download|view)\//i,
capcut: /capcut\.com\/(template-detail\/\d+|@[\w.-]+\/video\/[\w-]+|t\/[\w-]+|\d+)/i,
gdrive: /drive\.google\.com\/(file\/d\/|open\?id=)[\w-]+/i,
pinterest: /(pinterest\.com\/pin\/\d+|pin\.it\/[a-zA-Z0-9]+)/i,
douyin: /(v\.douyin\.com\/\w+|douyin\.com\/\S+)/i,
xiaohongshu: /(xiaohongshu\.com\/discovery\/item\/\d+|xhslink\.com\/[a-zA-Z0-9]+)/i,
xiaohongshuProfile: /xiaohongshu\.com\/user\/profile\/[a-zA-Z0-9]+/i,
snackvideo: /snackvideo\.com\/@[\w.-]+\/video\/\d+|s\.snackvideo\.com\/\w+/i,
cocofun: /(icocofun|cocofun)\.com\/(share\/)?post\/\d+/i,
spotify: /(open\.spotify\.com\/(track|album|playlist|episode)\/[\w]+|spotify\.link\/[\w]+)/i,
soundcloud: /soundcloud\.com\/[\w.-]+\/[\w.-]+/i,
threads: /threads\.(net|com)\/@[\w.-]+\/post\/[\w_-]+/i,
kuaishou: /(v\.kuaishou\.com\/\w+|kuaishou\.com\/(?:short-video|video|share)\/[\w]+)/i,
};
const fnMap = {
instagram: "igdl",
tiktok: "ttdl",
facebook: "fbdown",
twitter: "twitter",
youtube: "youtube",
mediafire: "mediafire",
capcut: "capcut",
gdrive: "gdrive",
pinterest: "pinterest",
douyin: "douyin",
xiaohongshu: "xiaohongshu",
xiaohongshuProfile: "xiaohongshuProfile",
snackvideo: "snackvideo",
cocofun: "cocofun",
spotify: "spotify",
soundcloud: "soundcloud",
threads: "threads",
kuaishou: "kuaishou",
yts: "yts",
};
function isValidUrl(string) {
try {
new URL(string);
return true;
} catch (_) {
return false;
}
}
function detectPlatform(inputValue, selectedPlatform) {
if (selectedPlatform !== "auto") {
return selectedPlatform;
}
if (isValidUrl(inputValue)) {
for (const [name, regex] of Object.entries(regexMap)) {
if (regex.test(inputValue)) {
return name;
}
}
return "pinterest";
} else {
// Non-URL inputs default to YTS
return "yts";
}
}
platformSelect.addEventListener("change", () => {
input.placeholder = platformPlaceholders[platformSelect.value];
input.value = ""; // Clear
});
btn.addEventListener("click", async () => {
const inputValue = input.value.trim();
if (!inputValue) return alert("Please enter a valid URL or YTS query!");
output.textContent = "Detecting platform...";
try {
const btch = window.btch;
if (!btch) throw new Error("btch library not loaded.");
const platform = detectPlatform(inputValue, platformSelect.value);
const fnName = fnMap[platform];
const fn = btch[fnName];
if (!fn) throw new Error(`Downloader function missing for ${platform}`);
output.textContent = `Detected: ${platform}\nFetching data...`;
const res = await fn(inputValue);
output.textContent = JSON.stringify(res, null, 2);
} catch (err) {
output.textContent = "Error: " + (err.message || err);
}
});
</script>
</body>
</html>