MCPcopy
hub / github.com/jdepoix/youtube-transcript-api / fetch

Method fetch

youtube_transcript_api/_transcripts.py:130–147  ·  view source on GitHub ↗

Loads the actual transcript data. :param preserve_formatting: whether to keep select HTML text formatting

(self, preserve_formatting: bool = False)

Source from the content-addressed store, hash-verified

128 }
129
130 def fetch(self, preserve_formatting: bool = False) -> FetchedTranscript:
131 """
132 Loads the actual transcript data.
133 :param preserve_formatting: whether to keep select HTML text formatting
134 """
135 if "&exp=xpe" in self._url:
136 raise PoTokenRequired(self.video_id)
137 response = self._http_client.get(self._url)
138 snippets = _TranscriptParser(preserve_formatting=preserve_formatting).parse(
139 _raise_http_errors(response, self.video_id).text,
140 )
141 return FetchedTranscript(
142 snippets=snippets,
143 video_id=self.video_id,
144 language=self.language,
145 language_code=self.language_code,
146 is_generated=self.is_generated,
147 )
148
149 def __str__(self) -> str:
150 return '{language_code} ("{language}"){translation_description}'.format(

Calls 5

PoTokenRequiredClass · 0.85
_TranscriptParserClass · 0.85
_raise_http_errorsFunction · 0.85
FetchedTranscriptClass · 0.85
parseMethod · 0.80