File size: 1,280 Bytes
4b1f3a4
 
5efa6b0
4b1f3a4
 
5efa6b0
 
4b1f3a4
 
 
 
 
 
 
5efa6b0
 
4b1f3a4
 
 
 
 
 
 
5efa6b0
4b1f3a4
5efa6b0
 
4b1f3a4
 
5efa6b0
4b1f3a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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);
    }
});