adriiita commited on
Commit
29ce305
·
verified ·
1 Parent(s): 4e08d4a

Update processors/input_processor.py

Browse files
Files changed (1) hide show
  1. processors/input_processor.py +8 -1
processors/input_processor.py CHANGED
@@ -6,7 +6,12 @@ from langchain_community.document_loaders import (
6
  from langchain_community.document_loaders.generic import GenericLoader
7
  from langchain_community.document_loaders.parsers.audio import OpenAIWhisperParser
8
  from langchain.text_splitter import RecursiveCharacterTextSplitter
9
- from youtube_transcript_api import YouTubeTranscriptApi
 
 
 
 
 
10
  import re
11
 
12
  class ContentProcessor:
@@ -46,6 +51,8 @@ class ContentProcessor:
46
 
47
  except TranscriptsDisabled:
48
  raise Exception("This video does not have subtitles/captions enabled. Please try a different video that has captions available.")
 
 
49
  except Exception as e:
50
  raise Exception(f"Unable to get transcript: {str(e)}. Please ensure the video has captions enabled.")
51
 
 
6
  from langchain_community.document_loaders.generic import GenericLoader
7
  from langchain_community.document_loaders.parsers.audio import OpenAIWhisperParser
8
  from langchain.text_splitter import RecursiveCharacterTextSplitter
9
+ from youtube_transcript_api import (
10
+ YouTubeTranscriptApi,
11
+ TranscriptsDisabled,
12
+ NoTranscriptFound,
13
+ NoTranscriptAvailable
14
+ )
15
  import re
16
 
17
  class ContentProcessor:
 
51
 
52
  except TranscriptsDisabled:
53
  raise Exception("This video does not have subtitles/captions enabled. Please try a different video that has captions available.")
54
+ except NoTranscriptFound:
55
+ raise Exception("No transcript was found for this video. Please try a different video that has captions available.")
56
  except Exception as e:
57
  raise Exception(f"Unable to get transcript: {str(e)}. Please ensure the video has captions enabled.")
58