Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# streamlit_instaloader.py
|
2 |
+
import streamlit as st
|
3 |
+
import instaloader
|
4 |
+
|
5 |
+
def download_reels(username):
|
6 |
+
L = instaloader.Instaloader()
|
7 |
+
|
8 |
+
try:
|
9 |
+
# Login (if needed)
|
10 |
+
# L.login(username, password)
|
11 |
+
|
12 |
+
# Get the profile
|
13 |
+
profile = instaloader.Profile.from_username(L.context, username)
|
14 |
+
|
15 |
+
# Iterate over the reels
|
16 |
+
for post in profile.get_posts():
|
17 |
+
if post.typename == 'GraphVideo': # Reels are typically videos
|
18 |
+
L.download_post(post, target=f"{username}_reels")
|
19 |
+
st.success(f"Downloaded reel: {post.shortcode}")
|
20 |
+
|
21 |
+
except instaloader.exceptions.InstaloaderException as e:
|
22 |
+
st.error(f"Error: {e}")
|
23 |
+
|
24 |
+
def main():
|
25 |
+
st.title("Instagram Reels Downloader")
|
26 |
+
st.write("Enter the Instagram username to download their reels:")
|
27 |
+
|
28 |
+
username = st.text_input("Instagram Username", "")
|
29 |
+
|
30 |
+
if st.button("Download Reels"):
|
31 |
+
if username:
|
32 |
+
st.info(f"Downloading reels for {username}...")
|
33 |
+
download_reels(username)
|
34 |
+
else:
|
35 |
+
st.warning("Please enter a username.")
|
36 |
+
|
37 |
+
if __name__ == "__main__":
|
38 |
+
main()
|