function downloadVideo() {
// Get the URL of the video from the input field
const videoUrl = document.getElementById('video-url').value;
// Check if the URL is valid
if (!isValidUrl(videoUrl)) {
// Display an error message if the URL is not valid
document.getElementById('download-status').innerHTML = 'Invalid URL';
return;
}
// Use the Facebook API to retrieve the video URL
FB.api(
'/',
'POST',
{
id: videoUrl,
fields: 'source'
},
function(response) {
// Check if the video URL was retrieved successfully
if (response && !response.error) {
// Download the video using the URL
download(response.source);
} else {
// Display an error message if there was a problem
document.getElementById('download-