El siguiente código es para descargar miniaturas de youtube. Quiero que añadas tambien…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
El siguiente código es para descargar miniaturas de youtube. Quiero que añadas tambien el código necesario para descargar miniaturas de vimeo:
document.getElementById('showThumbnail').addEventListener('click', function() { const videoUrl = document.getElementById('videoUrl').value; const regex = /(?:https?://)?(?:www.)?(?:youtube.com/(?:[^/\n\s]+/\S+/|(?:v|e(?:mbed)?)/|\S*?[?&]v=)|youtu.be/)([a-zA-Z0-9_-]{11})/; const match = videoUrl.match(regex);
codeif (match) { const videoId = match[1]; const thumbnailUrl = `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`; const thumbnailContainer = document.getElementById('thumbnailContainer'); thumbnailContainer.innerHTML = `<img src="${thumbnailUrl}" alt="Video Thumbnail"/>`; const thumbnailLinkAbove = document.getElementById('thumbnailLinkAbove'); const thumbnailLinkBelow = document.getElementById('thumbnailLinkBelow'); thumbnailLinkAbove.innerHTML = ''; thumbnailLinkBelow.innerHTML = ''; const anchorAbove = document.createElement('a'); anchorAbove.href = thumbnailUrl; anchorAbove.setAttribute('download', ''); anchorAbove.textContent = 'Download Thumbnail (Above)'; thumbnailLinkAbove.appendChild(anchorAbove); const anchorBelow = document.createElement('a'); anchorBelow.href = thumbnailUrl; anchorBelow.setAttribute('download', ''); anchorBelow.textContent = 'Download Thumbnail (Below)'; thumbnailLinkBelow.appendChild(anchorBelow); } else { alert('Invalid YouTube video URL. Please enter a valid URL.'); }});
- Assistant