jdepoix / youtube-transcript-api

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!
MIT License
2.55k stars 280 forks source link

Error #210

Closed Qiota closed 1 year ago

Qiota commented 1 year ago

DO NOT DELETE THIS! Please take the time to fill this out properly. I am not able to help you if I do not know what you are executing and what error messages you are getting. If you are having problems with a specific video make sure to include the video id.

To Reproduce

Steps to reproduce the behavior:

What code / cli command are you executing?

For example: I am running

YouTubeTranscriptApi.get_transcript ...

Which Python version are you using?

Python x.y

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

youtube-transcript-api x.y.z

Expected behavior

Describe what you expected to happen.

For example: I expected to receive the english transcript

Actual behaviour

Describe what is happening instead of the Expected behavior. Add error messages if there are any.

For example: Instead I received the following error message:

# ... 2023-06-07 19:15:03 ERROR    discord.client Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/runner/Discord-AI-Bot/venv/lib/python3.10/site-packages/discord/client.py", line 441, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 332, in on_message
    yt_transcript = await get_transcript_from_message(message.content)
  File "main.py", line 170, in get_transcript_from_message
    transcript_list = YouTubeTranscriptApi.list_transcripts(video_id)
  File "/home/runner/Discord-AI-Bot/venv/lib/python3.10/site-packages/youtube_transcript_api/_api.py", line 71, in list_transcripts
    return TranscriptListFetcher(http_client).fetch(video_id)
  File "/home/runner/Discord-AI-Bot/venv/lib/python3.10/site-packages/youtube_transcript_api/_transcripts.py", line 48, in fetch
    self._extract_captions_json(self._fetch_video_html(video_id), video_id),
  File "/home/runner/Discord-AI-Bot/venv/lib/python3.10/site-packages/youtube_transcript_api/_transcripts.py", line 62, in _extract_captions_json
    raise TranscriptsDisabled(video_id)
youtube_transcript_api._errors.TranscriptsDisabled: 
Could not retrieve a transcript for the video https://www.youtube.com/watch?v=SUiMr3h50_g! This is most likely caused by:

Subtitles are disabled for this video

If you are sure that the described cause is not responsible for this error and that a transcript should be retrievable, please create an issue at https://github.com/jdepoix/youtube-transcript-api/issues. Please add which version of youtube_transcript_api you are using and provide the information needed to replicate the error. Also make sure that there are no open issues which already describe your problem! ...
jdepoix commented 1 year ago

As the error message already clearly states, this is because subtitles for this video are disabled.