Manasa1 commited on
Commit
85acead
·
verified ·
1 Parent(s): 17ce9b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -53,8 +53,12 @@ def get_youtube_captions(youtube_url):
53
  Returns:
54
  - The captions of the video in SRT format, or a message if captions are not available.
55
  """
56
- video_id = youtube_url.split("v=")[-1].split("&")[0]
57
-
 
 
 
 
58
  try:
59
  # Fetch transcript for the video
60
  transcript = YouTubeTranscriptApi.get_transcript(video_id)
 
53
  Returns:
54
  - The captions of the video in SRT format, or a message if captions are not available.
55
  """
56
+ # Extract video ID from YouTube URL (for both regular videos and Shorts)
57
+ if "shorts" in youtube_url:
58
+ video_id = youtube_url.split("shorts/")[-1].split("?")[0]
59
+ else:
60
+ video_id = youtube_url.split("v=")[-1].split("&")[0]
61
+
62
  try:
63
  # Fetch transcript for the video
64
  transcript = YouTubeTranscriptApi.get_transcript(video_id)