-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulkd.html
More file actions
262 lines (230 loc) · 12.6 KB
/
Copy pathbulkd.html
File metadata and controls
262 lines (230 loc) · 12.6 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
<!-- v2.3 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bulkd</title>
<link href="https://minisoft.it/icons/fix.png" rel="shortcut icon" type="image/x-icon" />
<link href="https://minisoft.it/icons/fix.png" rel="apple-touch-icon" />
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#006E81',
'primary-dark': '#006E81',
secondary: '#814000',
}
}
}
}
</script>
</head>
<body class="bg-gray-100 flex flex-col min-h-screen">
<header class="bg-white border-b border-gray-200">
<div class="container mx-auto px-4 py-6 max-w-4xl">
<h1 class="text-3xl font-bold text-center text-gray-800">Bulkd</h1>
<p class="text-gray-600 text-center mt-1">Multi-URL File Downloader</p>
</div>
</header>
<main class="container mx-auto px-4 py-8 max-w-4xl">
<!-- Instructions Section -->
<div class="bg-white rounded-lg shadow-md p-6 mb-8">
<h2 class="text-xl font-semibold text-gray-800 mb-4">Instructions</h2>
<div class="bg-slate-50 border-l-4 border-primary p-4 rounded-r">
<ol class="list-decimal pl-5 space-y-1">
<li>Paste URLs in the text area below (one URL per line)</li>
<li>Click "Parse URLs" to validate and prepare for download</li>
<li>Use "Download All" to batch download all files, or download individual files using their respective buttons</li>
</ol>
</div>
</div>
<!-- Content -->
<div class="bg-white rounded-lg shadow-md p-6 mb-8">
<label for="html" class="block text-sm font-medium text-gray-700 mb-2">Paste your URLs here</label>
<textarea id="urlInput" class="w-full h-48 p-3 border border-gray-300 rounded-lg mb-4 resize-y" placeholder="Paste one URLs per line. Example: https://example.com/file1.pdf https://example.com/file2.jpg"></textarea>
<div class="flex flex-wrap justify-center gap-4">
<button id="parseUrls" class="bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary-dark transition duration-200">
Parse URLs
</button>
<button id="downloadAll" class="bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary-dark transition duration-200 disabled:bg-gray-400 disabled:cursor-not-allowed" disabled>
Download All
</button>
<button id="clearAll" class="bg-secondary text-white px-4 py-2 rounded-lg">
Clear All
</button>
</div>
</div>
<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold text-gray-800 mb-4">Results</h2>
<div id="status" class="space-y-2"></div>
<ul id="urlList" class="mt-4 space-y-2"></ul>
</div>
</main>
<footer class="bg-white border-t border-gray-200 mt-auto">
<div class="container mx-auto px-4 py-6 max-w-4xl">
<p class="text-gray-600 text-center">© <a href="https://minisoft.it/" class="text-primary hover:text-primary-dark">Minisoft</a> — All rights reserved</p>
</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', function() {
const urlInput = document.getElementById('urlInput');
const parseUrlsBtn = document.getElementById('parseUrls');
const downloadAllBtn = document.getElementById('downloadAll');
const clearAllBtn = document.getElementById('clearAll');
const statusDiv = document.getElementById('status');
const urlList = document.getElementById('urlList');
// Parse URLs and create list
parseUrlsBtn.addEventListener('click', function() {
const urls = urlInput.value.trim().split('\n').filter(url => url.trim() !== '');
if (urls.length === 0) {
showStatus('Please enter at least one URL.', 'error');
return;
}
urlList.innerHTML = '';
let validUrlsCount = 0;
urls.forEach((url, index) => {
try {
url = url.trim();
new URL(url); // This will throw an error if the URL is invalid
const li = document.createElement('li');
li.className = 'flex items-center justify-between bg-white p-3 rounded-lg shadow-sm border border-gray-200';
const leftSection = document.createElement('div');
leftSection.className = 'flex items-center flex-grow overflow-hidden mr-4';
const statusIndicator = document.createElement('span');
statusIndicator.className = 'w-3 h-3 rounded-full bg-gray-300 mr-3 flex-shrink-0';
leftSection.appendChild(statusIndicator);
const urlSpan = document.createElement('span');
urlSpan.className = 'text-gray-700 truncate';
urlSpan.textContent = url;
urlSpan.title = url;
leftSection.appendChild(urlSpan);
li.appendChild(leftSection);
const downloadBtn = document.createElement('button');
downloadBtn.className = 'bg-primary hover:bg-primary-dark text-white text-sm py-1 px-3 rounded flex-shrink-0 transition duration-200';
downloadBtn.textContent = 'Download';
downloadBtn.dataset.url = url;
downloadBtn.addEventListener('click', function() {
downloadFile(url, statusIndicator);
});
li.appendChild(downloadBtn);
urlList.appendChild(li);
validUrlsCount++;
} catch (e) {
showStatus(`Invalid URL skipped: ${url}`, 'error');
}
});
if (validUrlsCount > 0) {
showStatus(`${validUrlsCount} valid URL(s) parsed and ready for download.`, 'success');
downloadAllBtn.disabled = false;
downloadAllBtn.classList.remove('disabled:bg-gray-400', 'disabled:cursor-not-allowed');
} else {
showStatus('No valid URLs found. Please check your input.', 'error');
downloadAllBtn.disabled = true;
downloadAllBtn.classList.add('disabled:bg-gray-400', 'disabled:cursor-not-allowed');
}
});
// Download a single file
function downloadFile(url, statusIndicator) {
statusIndicator.className = 'w-3 h-3 rounded-full bg-yellow-400 mr-3 flex-shrink-0';
fetch(url, {
method: 'GET',
mode: 'cors' // Try using CORS if available
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.blob();
})
.then(blob => {
const filename = getFilenameFromUrl(url);
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
statusIndicator.className = 'w-3 h-3 rounded-full bg-green-500 mr-3 flex-shrink-0';
})
.catch(error => {
statusIndicator.className = 'w-3 h-3 rounded-full bg-red-500 mr-3 flex-shrink-0';
console.error('Download error:', error);
// Try alternative download method for cross-origin restrictions
const a = document.createElement('a');
a.href = url;
a.download = getFilenameFromUrl(url);
a.target = '_blank';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
showStatus(`Direct download initiated for: ${getFilenameFromUrl(url)}. If download doesn't start, the URL might have cross-origin restrictions.`, 'warning');
});
}
// Download all files
downloadAllBtn.addEventListener('click', function() {
const downloadButtons = document.querySelectorAll('[data-url]');
const delay = 1000; // 1 second delay between downloads to avoid overwhelming the browser
showStatus(`Starting download of ${downloadButtons.length} files...`, 'info');
downloadButtons.forEach((button, index) => {
setTimeout(() => {
const url = button.dataset.url;
const statusIndicator = button.parentNode.querySelector('.rounded-full');
downloadFile(url, statusIndicator);
}, index * delay);
});
});
// Clear all
clearAllBtn.addEventListener('click', function() {
urlInput.value = '';
urlList.innerHTML = '';
statusDiv.innerHTML = '';
downloadAllBtn.disabled = true;
downloadAllBtn.classList.add('disabled:bg-gray-400', 'disabled:cursor-not-allowed');
});
// Helper function to extract filename from URL
function getFilenameFromUrl(url) {
try {
const parsedUrl = new URL(url);
const pathname = parsedUrl.pathname;
const filename = pathname.substring(pathname.lastIndexOf('/') + 1);
return filename || 'download';
} catch (e) {
return 'download';
}
}
// Helper function to show status messages
function showStatus(message, type = 'info') {
const div = document.createElement('div');
div.className = 'p-3 rounded-lg text-sm mb-3';
div.textContent = message;
switch (type) {
case 'success':
div.className += ' bg-green-100 text-green-800 border border-green-200';
break;
case 'error':
div.className += ' bg-red-100 text-red-800 border border-red-200';
break;
case 'warning':
div.className += ' bg-yellow-100 text-yellow-800 border border-yellow-200';
break;
default: // info
div.className += ' bg-slate-100 text-slate-800 border border-slate-200';
}
statusDiv.prepend(div);
// Auto-remove status messages after 10 seconds
setTimeout(() => {
div.classList.add('opacity-0', 'transition-opacity', 'duration-500');
setTimeout(() => {
if (div.parentNode === statusDiv) {
statusDiv.removeChild(div);
}
}, 500);
}, 10000);
}
});
</script>
</body>
</html>