Spaces:
Paused
Paused
File size: 1,334 Bytes
469ad23 eee9760 469ad23 151202b 469ad23 151202b 469ad23 151202b 469ad23 eee9760 151202b 52d3852 151202b 469ad23 151202b 469ad23 |
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import streamlit as st
import instaloader
import os
def download_reel(url, username, password):
# Set up Instaloader with login credentials
loader = instaloader.Instaloader()
loader.login(username, password)
# Extract shortcode from URL
shortcode = url.split('/')[-2]
# Download the reel
try:
post = instaloader.Post.from_shortcode(loader.context, shortcode)
loader.download_post(post, target=f"reels/{shortcode}")
return f"Reel downloaded successfully to reels/{shortcode}"
except Exception as e:
return f"An error occurred: {str(e)}"
def main():
st.title('Instagram Reel Downloader')
# Input for Reel URL
url = st.text_input('Enter the Instagram Reel URL')
# Handle form submission
if st.button('Download Reel'):
if url:
# Instagram login credentials (remember to handle this securely)
username = 's'
password = 'S'
# Create the directory if it doesn't exist
if not os.path.exists("reels"):
os.makedirs("reels")
# Download the reel
result = download_reel(url, username, password)
st.write(result)
else:
st.warning('Please enter a URL.')
if __name__ == "__main__":
main()
|