Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import instaloader
|
| 3 |
import os
|
| 4 |
from pathlib import Path
|
| 5 |
import base64
|
| 6 |
|
| 7 |
-
def download_reel_from_link(link,
|
| 8 |
L = instaloader.Instaloader()
|
| 9 |
download_dir = "downloaded_reels"
|
| 10 |
Path(download_dir).mkdir(exist_ok=True)
|
| 11 |
|
| 12 |
try:
|
| 13 |
-
#
|
| 14 |
-
L.
|
| 15 |
|
| 16 |
# Extract shortcode from the link
|
| 17 |
shortcode = link.split('/')[-2]
|
|
@@ -37,21 +38,28 @@ def get_download_link(file_path):
|
|
| 37 |
|
| 38 |
def main():
|
| 39 |
st.title("Instagram Reel Downloader")
|
| 40 |
-
st.write("Enter the Instagram reel link and your
|
| 41 |
|
| 42 |
link = st.text_input("Instagram Reel Link", "")
|
| 43 |
-
|
| 44 |
-
password = st.text_input("Instagram Password", type="password")
|
| 45 |
|
| 46 |
if st.button("Download Reel"):
|
| 47 |
-
if link and
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
st.info(f"Downloading reel from {link}...")
|
| 49 |
-
reel_path = download_reel_from_link(link,
|
| 50 |
if reel_path:
|
| 51 |
st.success(f"Downloaded reel: {Path(reel_path).name}")
|
| 52 |
st.markdown(get_download_link(reel_path), unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
| 53 |
else:
|
| 54 |
-
st.warning("Please enter a valid Instagram reel link and
|
| 55 |
|
| 56 |
if __name__ == "__main__":
|
| 57 |
main()
|
|
|
|
| 1 |
+
# streamlit_instaloader_cookie.py
|
| 2 |
import streamlit as st
|
| 3 |
import instaloader
|
| 4 |
import os
|
| 5 |
from pathlib import Path
|
| 6 |
import base64
|
| 7 |
|
| 8 |
+
def download_reel_from_link(link, cookiefile):
|
| 9 |
L = instaloader.Instaloader()
|
| 10 |
download_dir = "downloaded_reels"
|
| 11 |
Path(download_dir).mkdir(exist_ok=True)
|
| 12 |
|
| 13 |
try:
|
| 14 |
+
# Load session from cookies
|
| 15 |
+
L.context.load_cookiejar(cookiefile)
|
| 16 |
|
| 17 |
# Extract shortcode from the link
|
| 18 |
shortcode = link.split('/')[-2]
|
|
|
|
| 38 |
|
| 39 |
def main():
|
| 40 |
st.title("Instagram Reel Downloader")
|
| 41 |
+
st.write("Enter the Instagram reel link and provide your cookie file to download:")
|
| 42 |
|
| 43 |
link = st.text_input("Instagram Reel Link", "")
|
| 44 |
+
cookiefile = st.file_uploader("Upload Cookie File")
|
|
|
|
| 45 |
|
| 46 |
if st.button("Download Reel"):
|
| 47 |
+
if link and cookiefile:
|
| 48 |
+
# Save the uploaded cookie file locally
|
| 49 |
+
cookie_path = f"cookies_{cookiefile.name}"
|
| 50 |
+
with open(cookie_path, "wb") as f:
|
| 51 |
+
f.write(cookiefile.getvalue())
|
| 52 |
+
|
| 53 |
st.info(f"Downloading reel from {link}...")
|
| 54 |
+
reel_path = download_reel_from_link(link, cookie_path)
|
| 55 |
if reel_path:
|
| 56 |
st.success(f"Downloaded reel: {Path(reel_path).name}")
|
| 57 |
st.markdown(get_download_link(reel_path), unsafe_allow_html=True)
|
| 58 |
+
|
| 59 |
+
# Clean up the saved cookie file
|
| 60 |
+
os.remove(cookie_path)
|
| 61 |
else:
|
| 62 |
+
st.warning("Please enter a valid Instagram reel link and upload your cookie file.")
|
| 63 |
|
| 64 |
if __name__ == "__main__":
|
| 65 |
main()
|