Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import instaloader
|
3 |
+
|
4 |
+
def download_instagram_media(username):
|
5 |
+
loader = instaloader.Instaloader()
|
6 |
+
|
7 |
+
try:
|
8 |
+
profile = instaloader.Profile.from_username(loader.context, username)
|
9 |
+
|
10 |
+
for post in profile.get_posts():
|
11 |
+
loader.download_post(post, target=profile.username)
|
12 |
+
|
13 |
+
st.success(f"Download complete for '{username}'!")
|
14 |
+
|
15 |
+
except instaloader.exceptions.ProfileNotExistsException:
|
16 |
+
st.error(f"Profile '{username}' not found.")
|
17 |
+
|
18 |
+
def main():
|
19 |
+
st.title("Instagram Media Downloader")
|
20 |
+
|
21 |
+
# Input field for the Instagram username
|
22 |
+
username = st.text_input("Enter Instagram Username:")
|
23 |
+
|
24 |
+
# Button to trigger the download
|
25 |
+
if st.button("Download Media"):
|
26 |
+
if username:
|
27 |
+
download_instagram_media(username)
|
28 |
+
else:
|
29 |
+
st.warning("Please enter a valid username.")
|
30 |
+
|
31 |
+
if __name__ == "__main__":
|
32 |
+
main()
|