badal commited on
Commit
77821aa
·
1 Parent(s): 2f2406a

fix: url support

Browse files
app/functions/youtube_summarizer.py CHANGED
@@ -10,12 +10,15 @@ headers = {"Authorization": f"Bearer {API_TOKEN}"}
10
  def extract_video_id(youtube_url):
11
  video_id_pattern = r"(?:/shorts/|v=)([a-zA-Z0-9_-]+)(?:&|\?|$)"
12
  match = re.search(video_id_pattern, youtube_url)
 
13
  if match:
14
  video_id = match.group(1)
15
  return video_id
 
 
16
  else:
17
  return None
18
-
19
 
20
  def youtube_summarizer_handler(link):
21
  video_id = extract_video_id(link)
 
10
  def extract_video_id(youtube_url):
11
  video_id_pattern = r"(?:/shorts/|v=)([a-zA-Z0-9_-]+)(?:&|\?|$)"
12
  match = re.search(video_id_pattern, youtube_url)
13
+ data = re.findall(r"(?:v=|\/)([0-9A-Za-z_-]{11}).*", youtube_url)
14
  if match:
15
  video_id = match.group(1)
16
  return video_id
17
+ elif data:
18
+ return data[0]
19
  else:
20
  return None
21
+
22
 
23
  def youtube_summarizer_handler(link):
24
  video_id = extract_video_id(link)