Compare commits
2 commits
58dc0dfe1d
...
cd297ff914
Author | SHA1 | Date | |
---|---|---|---|
cd297ff914 | |||
9a0293a6e1 |
1 changed files with 2 additions and 20 deletions
22
script.js
22
script.js
|
@ -14,33 +14,15 @@ document.getElementById('search-button').addEventListener('click', async () => {
|
||||||
|
|
||||||
videos.forEach(video => {
|
videos.forEach(video => {
|
||||||
const listItem = document.createElement('li');
|
const listItem = document.createElement('li');
|
||||||
|
let url = `https://ubertuberbe.nodemixaholic.com/download?url=${encodeURIComponent(video.url)}`
|
||||||
listItem.innerHTML = `
|
listItem.innerHTML = `
|
||||||
<strong>${video.title}</strong> (${video.views} views) by ${video.author}
|
<strong>${video.title}</strong> (${video.views} views) by ${video.author}
|
||||||
<br>
|
<br>
|
||||||
<a href="#" class="download-link" data-url="${video.url}">Watch</a>
|
<a href="${url}" class="download-link" data-url="${video.url}">Watch</a>
|
||||||
`;
|
`;
|
||||||
resultsList.appendChild(listItem);
|
resultsList.appendChild(listItem);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add event listeners to download links
|
|
||||||
document.querySelectorAll('.download-link').forEach(link => {
|
|
||||||
link.addEventListener('click', async (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const videoUrl = e.target.dataset.url;
|
|
||||||
const downloadResponse = await fetch(`https://ubertuberbe.nodemixaholic.com/download?url=${encodeURIComponent(videoUrl)}`);
|
|
||||||
//const blob = await downloadResponse.blob();
|
|
||||||
|
|
||||||
//const url = window.URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.style.display = 'none';
|
|
||||||
a.href = url;
|
|
||||||
//a.download = 'video.mp4'; // You might want to set this dynamically
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
window.URL.revokeObjectURL(url);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching videos:', error);
|
console.error('Error fetching videos:', error);
|
||||||
alert('An error occurred while searching for videos.');
|
alert('An error occurred while searching for videos.');
|
||||||
|
|
Loading…
Reference in a new issue