2024-10-28 15:36:29 +00:00
|
|
|
document.getElementById('search-button').addEventListener('click', async () => {
|
|
|
|
const query = document.getElementById('search-input').value;
|
|
|
|
const resultsList = document.getElementById('video-results');
|
|
|
|
resultsList.innerHTML = ''; // Clear previous results
|
|
|
|
|
|
|
|
if (!query) {
|
|
|
|
alert('Please enter a search query.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
const response = await fetch(`https://ubertuberbe.nodemixaholic.com/search?q=${encodeURIComponent(query)}`);
|
|
|
|
const videos = await response.json();
|
|
|
|
|
|
|
|
videos.forEach(video => {
|
|
|
|
const listItem = document.createElement('li');
|
2024-10-28 17:10:28 +00:00
|
|
|
let url = `https://ubertuberbe.nodemixaholic.com/download?url=${encodeURIComponent(video.url)}`
|
2024-10-28 15:36:29 +00:00
|
|
|
listItem.innerHTML = `
|
|
|
|
<strong>${video.title}</strong> (${video.views} views) by ${video.author}
|
|
|
|
<br>
|
2024-10-28 17:10:28 +00:00
|
|
|
<a href="${url}" class="download-link" data-url="${video.url}">Watch</a>
|
2024-10-28 15:36:29 +00:00
|
|
|
`;
|
|
|
|
resultsList.appendChild(listItem);
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
console.error('Error fetching videos:', error);
|
|
|
|
alert('An error occurred while searching for videos.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|