HarshanaLF commited on
Commit
fdf75ae
1 Parent(s): ac54f8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -29,14 +29,18 @@ def extract_video_id(url):
29
  def get_youtube_transcript(video_url):
30
  video_id = extract_video_id(video_url)
31
  if not video_id:
32
- return "Video ID could not be extracted."
 
33
  try:
34
  transcript = YouTubeTranscriptApi.get_transcript(video_id)
35
  formatter = TextFormatter()
36
  text_transcript = formatter.format_transcript(transcript)
37
  return text_transcript
38
  except Exception as e:
39
- return f"An error occurred: {e}"
 
 
 
40
 
41
  # Function to summarize YouTube video with selected model
42
  def summarize_youtube_video(url, model_name):
 
29
  def get_youtube_transcript(video_url):
30
  video_id = extract_video_id(video_url)
31
  if not video_id:
32
+ return "Video ID could not be extracted. Please check the URL format."
33
+
34
  try:
35
  transcript = YouTubeTranscriptApi.get_transcript(video_id)
36
  formatter = TextFormatter()
37
  text_transcript = formatter.format_transcript(transcript)
38
  return text_transcript
39
  except Exception as e:
40
+ error_message = str(e)
41
+ if "Subtitles are disabled for this video" in error_message:
42
+ return "Subtitles are disabled for this video. Transcript cannot be retrieved."
43
+ return f"An error occurred while retrieving the transcript: {error_message}"
44
 
45
  # Function to summarize YouTube video with selected model
46
  def summarize_youtube_video(url, model_name):