youtube-transcript-api icon indicating copy to clipboard operation
youtube-transcript-api copied to clipboard

Parse error on video with auto-generated subtitles

Open PetrKubes97 opened this issue 2 years ago • 0 comments

To Reproduce

Steps to reproduce the behavior:

I am running

transcripts = YouTubeTranscriptApi.list_transcripts(video_url)
transcript = transcripts.find_transcript(language_codes=[desired_language])

if transcript is None:
    return 'no transcript was found', 400

downloaded = transcript.fetch()

Which Python version are you using?

Python 3.9.6

Which version of youtube-transcript-api are you using?

youtube-transcript-api 0.6.2

Expected behavior

Download transcript of the video id 26Ac1VJgd64

Actual behaviour

I get an error

For example: Instead I received the following error message:

    downloaded = transcript.fetch()
  File "/Library/Python/3.9/site-packages/youtube_transcript_api/_transcripts.py", line 292, in fetch
    return _TranscriptParser(preserve_formatting=preserve_formatting).parse(
  File "/Library/Python/3.9/site-packages/youtube_transcript_api/_transcripts.py", line 358, in parse
    for xml_element in ElementTree.fromstring(plain_data)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/xml/etree/ElementTree.py", line 1348, in XML
    return parser.close()
xml.etree.ElementTree.ParseError: no element found: line 1, column 0

PetrKubes97 avatar Feb 25 '24 09:02 PetrKubes97