Spaces:
Running
Running
document.getElementById("reelForm").addEventListener("submit", async function (e) { | |
e.preventDefault(); | |
const reelUrl = document.getElementById("reelUrl").value; | |
const apiUrl = `https://slimshadow-instagram-r-api.hf.space/download/?reel_url=${encodeURIComponent(reelUrl)}`; | |
try { | |
// Make the API request | |
const response = await fetch(apiUrl); | |
if (!response.ok) { | |
throw new Error("Failed to fetch the reel. Please check the URL and try again."); | |
} | |
// Parse the JSON response | |
const data = await response.json(); | |
// Check if the response contains a valid download link | |
if (data.download_link) { | |
// Show the download link to the user | |
document.getElementById("result").classList.remove("hidden"); | |
const downloadLinkElement = document.getElementById("downloadLink"); | |
downloadLinkElement.href = data.download_link; | |
downloadLinkElement.textContent = "Click here to download the reel"; | |
} else { | |
throw new Error("Download link not available. Please try again."); | |
} | |
} catch (error) { | |
// Handle any errors that occur during the fetch or parsing | |
alert("Error: " + error.message); | |
} | |
}); | |