modify to watch not view.

This commit is contained in:
The Ghost of FOSS' Past 2024-10-28 11:52:50 -05:00
parent 2f5fbe9e5c
commit 58dc0dfe1d

View file

@ -17,7 +17,7 @@ document.getElementById('search-button').addEventListener('click', async () => {
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}">Download</a> <a href="#" class="download-link" data-url="${video.url}">Watch</a>
`; `;
resultsList.appendChild(listItem); resultsList.appendChild(listItem);
}); });
@ -28,13 +28,13 @@ document.getElementById('search-button').addEventListener('click', async () => {
e.preventDefault(); e.preventDefault();
const videoUrl = e.target.dataset.url; const videoUrl = e.target.dataset.url;
const downloadResponse = await fetch(`https://ubertuberbe.nodemixaholic.com/download?url=${encodeURIComponent(videoUrl)}`); const downloadResponse = await fetch(`https://ubertuberbe.nodemixaholic.com/download?url=${encodeURIComponent(videoUrl)}`);
const blob = await downloadResponse.blob(); //const blob = await downloadResponse.blob();
const url = window.URL.createObjectURL(blob); //const url = window.URL.createObjectURL(blob);
const a = document.createElement('a'); const a = document.createElement('a');
a.style.display = 'none'; a.style.display = 'none';
a.href = url; a.href = url;
a.download = 'video.mp4'; // You might want to set this dynamically //a.download = 'video.mp4'; // You might want to set this dynamically
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);