This is a python API which allows you to get the transcript/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require an API key nor a headless browser, like other selenium based solutions do!
translationLanguages
key to sometimes be missing from the captions json. This release adjusts the fetching process to initialize translation_languages
with an empty list in case that happens.preserve_formatting
has been added to YouTubeTranscriptApi.get_transcript
, YouTubeTranscriptApi.get_transcripts
, and Transcript.fetch
. If this is set to True
, formatting elements such as <i>
(italics) and <b>
(bold) are no longer removed from the transcript. (thanks to @eseiver!)InvalidVideoId
exception..srt
files using the SRTFormatter
(thanks to @liamrs222!)get_transcript
and get_transcripts
now assert that their input type is correct, as users commonly passed a video id (string) into get_transcripts
although it expects a list. Since a string is an iterable the module tried to find a video for each character of that string, which failed with a not-so-helpful error message. (thanks to @majamil16!)"
in their name (like Estnisch - "Raev"
)TranscriptsDisabled
wasn't raised properly (thanks to @xenova!)FormatterLoader
, which was preventing the WebVTTFormatter
from being loaded properly (thanks to @MAJA-Lin!)WebVTTFormatter
has been fixedYouTubeRequestFailed
exception is raised, wrapping the status code and error messageAs of lately YouTube will occasionally return a page which requires the user to give consent to cookies being saved. Whenever this page was returned this this module was not able to process the response. Now it is able to recognise this case and create a consent cookie if needed.