sheikhed commited on
Commit
8c9b09a
·
verified ·
1 Parent(s): 56211f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -17
app.py CHANGED
@@ -4,29 +4,16 @@ import re
4
 
5
  def extract_shortcode(url):
6
  """Extract Instagram shortcode from various URL formats"""
7
- # Remove any trailing parameters and clean URL
8
- clean_url = url.split('?')[0].strip()
9
-
10
  patterns = [
11
- # Standard formats
12
- r'instagram\.com/p/([A-Za-z0-9_-]+)',
13
- r'instagram\.com/reel/([A-Za-z0-9_-]+)',
14
- r'instagram\.com/tv/([A-Za-z0-9_-]+)',
15
- # With username in path
16
- r'instagram\.com/[^/]+/p/([A-Za-z0-9_-]+)',
17
- r'instagram\.com/[^/]+/reel/([A-Za-z0-9_-]+)',
18
- r'instagram\.com/[^/]+/tv/([A-Za-z0-9_-]+)',
19
- # Stories format (though less common for audio)
20
- r'instagram\.com/stories/[^/]+/([A-Za-z0-9_-]+)',
21
  ]
22
 
23
  for pattern in patterns:
24
- match = re.search(pattern, clean_url)
25
  if match:
26
  return match.group(1)
27
-
28
- # Debug: print the URL structure if no match found
29
- print(f"No shortcode found in URL: {clean_url}")
30
  return None
31
 
32
  def download_reel_audio(url, output_folder="downloads"):
 
4
 
5
  def extract_shortcode(url):
6
  """Extract Instagram shortcode from various URL formats"""
 
 
 
7
  patterns = [
8
+ r'instagram\.com/p/([^/?]+)',
9
+ r'instagram\.com/reel/([^/?]+)',
10
+ r'instagram\.com/tv/([^/?]+)',
 
 
 
 
 
 
 
11
  ]
12
 
13
  for pattern in patterns:
14
+ match = re.search(pattern, url)
15
  if match:
16
  return match.group(1)
 
 
 
17
  return None
18
 
19
  def download_reel_audio(url, output_folder="downloads"):