Closed leleitu closed 10 months ago
Seeing the same thing in the past few days.
TypeError: Invalid attempt to destructure non-iterable instance
at index.js:8:585
at index.js:26:24
at Generator.next (<anonymous>)
at step (index.js:103:187)
at index.js:103:361
g```
Kind of fixed it. gave on up the library and used https://github.com/devhims/youtube-caption-extractor
Same. That other library is working for me
I have raised a PR #21. Not sure if it will get merged or not
thx. I have the same problems since some days. Perhaps I will try the other solution too.
I believe the latest 2.0.1 has fixed it, thanks @vgulerianb for your PR!
I am not getting responses anymore. code seems to be right
import { getSubtitles } from 'youtube-captions-scraper';
// Get references to HTML elements const videoLinkInput = document.getElementById('videoLink'); const fetchCaptionsButton = document.getElementById('fetchCaptions'); const captionsList = document.getElementById('captionsList');
// Add a click event listener to the "Fetch Captions" button fetchCaptionsButton.addEventListener('click', async () => { const videoURL = videoLinkInput.value.trim();
});
// Helper function to extract the video ID from the URL function getVideoID(url) { const match = url.match(/(?:v=|\/)([a-zA-Z0-9_-]{11})/); return match ? match[1] : null; }
// Helper function to display captions in the list function displayCaptions(captions) { captionsList.innerHTML = ''; captions.forEach((caption, index) => { const listItem = document.createElement('li'); listItem.textContent =
${index + 1}. ${caption.text}
; captionsList.appendChild(listItem); }); }