metek7 commited on
Commit
fa02584
·
verified ·
1 Parent(s): ef5efca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -44,10 +44,15 @@ L = instaloader.Instaloader()
44
 
45
  def download_instagram_video(url):
46
  try:
47
- # Extract post shortcode from URL
48
- shortcode = url.split("/")[-2]
 
 
 
 
 
49
 
50
- # Download the post
51
  post = instaloader.Post.from_shortcode(L.context, shortcode)
52
 
53
  # Create a temporary directory
 
44
 
45
  def download_instagram_video(url):
46
  try:
47
+ # Handle both post and reel URLs
48
+ if "reel" in url:
49
+ shortcode = url.split("/")[-2]
50
+ elif "p" in url:
51
+ shortcode = url.split("/")[-2]
52
+ else:
53
+ return None
54
 
55
+ # Download the post/reel
56
  post = instaloader.Post.from_shortcode(L.context, shortcode)
57
 
58
  # Create a temporary directory