forked from cjtrowbridge/tiktok-bulk-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
372 lines (305 loc) · 16.4 KB
/
index.html
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap core CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<!-- Include JQuery -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin="anonymous">
</script>
<meta name="description" content="TikTok Bulk Downloader">
<meta name="author" content="CJ Trowbridge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<meta property="og:title" content="TikTok Bulk Downloader">
<meta property="og:description" content="TikTok Bulk Downloader">
<title>TikTok Bulk Downloader</title>
</head>
<body class="bg-dark text-white">
<div class="container mt-5">
<p><b>Notice:</b> Your data is not uploaded. Everything happens in the browser. I don't want your data. You can also save the page to your computer before running it. If you notice a bug, want to see the source code, or want to submit a pull request for a change or fix, <a href="https://github.com/cjtrowbridge/tiktok-bulk-downloader">click here</a> to access the github repository.</p>
<p><a style="background-color: #FFDD00; color: black;" class="btn btn-buymeacoffee" href="https://buymeacoffee.com/cjtrowbridge">☕ Buy me a coffee</a></p>
<h1 class="mb-4">TikTok Data Parser</h1>
<form id="dataForm" class="mb-4">
<div class="mb-3">
<label for="osSelect" class="form-label">Select Your Operating System</label>
<select class="form-select" id="osSelect" required>
<option value="">Choose...</option>
<option value="windows">Windows</option>
<option value="mac">Mac</option>
<option value="linux">Linux</option>
</select>
</div>
<div id="osSpecificFeedback">
<p class="text-muted">Please select an operating system to proceed.</p>
</div>
<div class="mb-3">
<label for="userDataFile" class="form-label">You will need your <a target="_blank" href="https://www.tiktok.com/setting/download-your-data">TikTok User Data File</a>. The file is not going to be ready immediately, as it is generated by request. Make sure to choose JSON- It is not the default in the request form but it is required for your script.</label>
<input class="form-control" type="file" id="userDataFile" accept=".json" required>
</div>
<div class="mb-3">
<label class="form-label">Select What to Download</label>
<div class="form-check">
<input class="form-check-input" type="checkbox" checked="checked" value="videos" id="downloadVideos">
<label class="form-check-label" for="downloadVideos">Your Videos</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="reposts" id="downloadReposts">
<label class="form-check-label" for="downloadReposts">Your Reposts</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="collections" id="downloadCollections">
<label class="form-check-label" for="downloadCollections">Your Collections</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="likes" id="downloadLikes">
<label class="form-check-label" for="downloadLikes">Your Liked Videos</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Parse and Generate Script</button>
</form>
<div id="output" class="mt-4">
<div id="buttonWrapper"></div>
<h3>Parsed Data:</h3>
<pre id="parsedData" class="bg-secondary p-3 rounded"></pre>
</div>
</div>
<script>
$(document).ready(function () {
//Depending on the os they select, offer feedback on how they need to prepare to be able to run the script
$('#osSelect').on('change', function () {
const os = $(this).val();
let feedback = '';
if (os === 'windows') {
feedback = 'You will need to have cURL installed to run the script. You can download it from https://curl.se/windows/. In order to download reposts, liked videos, and collections, you will need to have yt-dlp installed. You can download it from https://github.com/yt-dlp/yt-dlp';
} else if (os === 'mac') {
feedback = 'You will need to have cURL installed to run the script. You can install it using Homebrew with the command "brew install curl". In order to download reposts, liked videos, and collections, you will need to have yt-dlp installed. You can download it from https://github.com/yt-dlp/yt-dlp';
} else if (os === 'linux') {
feedback = 'You will need to have cURL installed to run the script. You can install it using your package manager. In order to download reposts, liked videos, and collections, you will need to have yt-dlp installed. You can download it from https://github.com/yt-dlp/yt-dlp';
}
$('#osSpecificFeedback').html(`<p class="text-muted">${feedback}</p>`);
});
$('#dataForm').on('submit', function (e) {
e.preventDefault();
const os = $('#osSelect').val();
const fileInput = $('#userDataFile')[0].files[0];
if (!os || !fileInput) {
alert('Please select an operating system and upload a file.');
return;
}
const reader = new FileReader();
reader.onload = function (event) {
//try {
const data = JSON.parse(event.target.result);
// Initialize parsed data object
const parsedData = {};
// Include the requested data
const selectedCategories = [];
if ($('#downloadVideos').is(':checked')){
videos = getVideos(data);
parsedData.videos = videos;
}
if ($('#downloadReposts').is(':checked')){
reposts = getReposts(data);
parsedData.reposts = reposts;
}
if ($('#downloadCollections').is(':checked')){
collections = getCollections(data);
parsedData.collections = collections;
}
if ($('#downloadLikes').is(':checked')){
likes = getLikes(data);
parsedData.likes = likes;
}
$('#parsedData').text(JSON.stringify(parsedData, null, 2));
// Generate script based on OS and parsed data
const script = generateDownloadScript(os, parsedData);
// Provide script download
const blob = new Blob([script], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
// Set the filename based on the OS
let filename = 'download-script';
if (os === 'windows') {
filename += '.bat';
} else if (os === 'mac') {
filename += '.sh';
} else if (os === 'linux') {
filename += '.sh';
}
link.textContent = 'Download Your Script';
link.className = 'btn btn-success mt-3';
link.download = filename;
$('#buttonWrapper').html(link);
//} catch (error) {
// alert('Error parsing JSON file: ' + error.message + '. Try refreshing the page.');
//}
};
reader.readAsText(fileInput);
});
function generateDownloadScript(os, data) {
if(os === 'windows') {
return generateWindowsScript(data);
} else if(os === 'mac') {
return generateMacScript(data);
} else if(os === 'linux') {
return generateLinuxScript(data);
} else {
return 'echo "Invalid operating system selected."';
}
}
function getVideos(data) {
//data.Video.Videos contains a list of objects
//We want to get the link from each object and a clean version of the date to use as the filename so the files are sortable once downloaded. This should use only hyphens and numbers, and if there are duplicate times, it needs to include an extra ordinal.
//The result should be an array of objects like this: [{"url": "https://url","filename": "2025-01-16-23-50-04.mp4"}]
const videos = data.Video.Videos.VideoList;
ret = videos.map(video => {
const date = video.Date.replace(/[^0-9]/g, '-');
return {
url: video.Link,
filename: `video_${date}.mp4`
};
});
console.log("Found These Videos: ",ret);
return ret;
}
function getReposts(data) {
//Activity.Share History.ShareHistoryList has a list of objects
//We want to get the link from each object and a clean version of the date to use as the filename so the files are sortable once downloaded. This should use only hyphens and numbers, and if there are duplicate times, it needs to include an extra ordinal.
//The result should be an array of objects like this: [{"url": "https://url/","filename": "2024-07-21-15-29-53.mp4"}]
const reposts = data.Activity['Share History']['ShareHistoryList'];
ret = reposts.map(repost => {
const date = repost.Date.replace(/[^0-9]/g, '-');
return {
url: repost.Link,
filename: `repost_${date}.mp4`
};
});
console.log("Found These Reposts: ",ret);
return ret;
}
function getCollections(data) {
//Activity.Favorite Videos.FavoriteVieoList has a list of objects
//We want to get the link from each object and a clean version of the date to use as the filename so the files are sortable once downloaded. This should use only hyphens and numbers, and if there are duplicate times, it needs to include an extra ordinal.
//The result should be an array of objects like this: [{"url": "https://url/","filename": "2025-01-17-07-35-23"}]
const collections = data.Activity['Favorite Videos'].FavoriteVideoList;
ret = collections.map(collection => {
const date = collection.Date.replace(/[^0-9]/g, '-');
return {
url: collection.Link,
filename: `collection_${date}.mp4`
};
});
console.log("Found These Collections: ",ret);
return ret;
}
function getLikes(data) {
//Activity.Like List.ItemFavoriteList has a list of objects
//We want to get the link from each object and a clean version of the date to use as the filename so the files are sortable once downloaded. This should use only hyphens and numbers, and if there are duplicate times, it needs to include an extra ordinal.
//The result should be an array of objects like this: [{"url": "https://url/", "filename": "2024-07-21-15-29-53.mp4"}]
const likes = data.Activity['Like List'].ItemFavoriteList;
ret = likes.map(like => {
const date = like.date.replace(/[^0-9]/g, '-');
return {
url: like.link,
filename: `like_${date}.mp4`
};
});
console.log("Found These Likes: ",ret);
return ret;
}
function generateWindowsScript(data) {
let script = '@echo off\n';
script += 'echo Downloading TikTok data...\n';
if (data.videos) {
script += 'echo Downloading videos...\n';
data.videos.forEach(video => {
script += `curl -o "${video.filename}" "${video.url}"\n`;
});
}
if (data.reposts) {
script += 'echo Downloading reposts...\n';
data.reposts.forEach(repost => {
script += `if(!(Test-Path "${repost.filename}")){yt-dlp -o "${repost.filename}" "${repost.url}"}\n`;
});
}
if (data.collections) {
script += 'echo Downloading collections...\n';
data.collections.forEach(collection => {
script += `if(!(Test-Path "${collection.filename}")){yt-dlp -o "${collection.filename}" "${collection.url}"}\n`;
});
}
if (data.likes) {
script += 'echo Downloading liked videos...\n';
data.likes.forEach(like => {
script += `if(!(Test-Path "${like.filename}")){yt-dlp -o "${like.filename}" "${like.url}"}\n`;
});
}
return script;
}
function generateMacScript(data) {
let script = '#!/bin/bash\n';
script += 'echo "Downloading TikTok data..."\n';
if (data.videos) {
script += 'echo "Downloading videos..."\n';
data.videos.forEach(video => {
script += `curl -o "${video.filename}" "${video.url}"\n`;
});
}
if (data.reposts) {
script += 'echo "Downloading reposts..."\n';
data.reposts.forEach(repost => {
script += `if [ ! -e "${repost.filename}" ]; then yt-dlp -o "${repost.filename}" "${repost.url}"; fi\n`;
});
}
if (data.collections) {
script += 'echo "Downloading collections..."\n';
data.collections.forEach(collection => {
script += `if [ ! -e "${collection.filename}" ]; then yt-dlp -o "${collection.filename}" "${collection.url}"; fi\n`;
});
}
if (data.likes) {
script += 'echo "Downloading liked videos..."\n';
data.likes.forEach(like => {
script += `if [ ! -e "${like.filename}" ]; then yt-dlp -o "${like.filename}" "${like.url}"; fi\n`;
});
}
return script;
}
function generateLinuxScript(data) {
let script = '#!/bin/bash\n';
script += 'echo "Downloading TikTok data..."\n';
if (data.videos) {
script += 'echo "Downloading videos..."\n';
data.videos.forEach(video => {
script += `curl -o "${video.filename}" "${video.url}"\n`;
});
}
if (data.reposts) {
script += 'echo "Downloading reposts..."\n';
data.reposts.forEach(repost => {
script += `if [ ! -e "${repost.filename}" ]; then yt-dlp -o "${repost.filename}" "${repost.url}"; fi\n`;
});
}
if (data.collections) {
script += 'echo "Downloading collections..."\n';
data.collections.forEach(collection => {
script += `if [ ! -e "${collection.filename}" ]; then yt-dlp -o "${collection.filename}" "${collection.url}"; fi\n`;
});
}
if (data.likes) {
script += 'echo "Downloading liked videos..."\n';
data.likes.forEach(like => {
script += `if [ ! -e "${like.filename}" ]; then yt-dlp -o "${like.filename}" "${like.url}"; fi\n`;
});
}
return script;
}
});
</script>
</body>
</html>