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

the subtitles are disabled, but it is not true. #230

Closed Botato300 closed 8 months ago

Botato300 commented 8 months ago

To Reproduce

Steps to reproduce the behavior: Simply execute the code.

Video link:

https://youtu.be/Tj_5dU0gjk0 image

What code / cli command are you executing?

For example:

transcript_list = YouTubeTranscriptApi.list_transcripts("Tj_5dU0gjk0")
print(transcript_list)

Which Python version are you using?

Python 3.11.4

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

youtube-transcript-api 0.6.1

Expected behavior

Describe what you expected to happen.

I was hoping to receive the transcripts, as they are available in the video.

Actual behaviour

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

Instead I received the following error message:

  File "C:\Users\Botato300\AppData\Roaming\Python\Python311\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=Tj_5dU0gjk0! 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 8 months ago

Hi @Botato300, when I open the URL https://youtu.be/Tj_5dU0gjk0, the video doesn't allow me to enable subtitles. So it seems to me that the error message is correct in saying that subtitles are disabled for this video. I will close this now, but let me know if that is not the case for you.

Botato300 commented 8 months ago

Hi! But look at the photo! If it has subtitles, I can see them. image

jdepoix commented 8 months ago

Wow, that is strange! For me it doesn't show subtitles:

image

I've never encountered this before. Maybe the subtitles are enabled based on your location? Are you executing the code from you local machine or from some cloud service?

Botato300 commented 8 months ago

Yes, it is strange. I'm running the code locally, on my windows 10 PC. I tried entering the video from incognito and no subtitles appeared! I think it shows the subtitles by account, instead of by location?

jdepoix commented 8 months ago

@Botato300 huh, that's interesting. Are you the uploader by the video of any chance? I don't know any ruling that YouTube can apply to limit transcripts to certain accounts, but that might very well be possible. However, you should be able to work around this using Cookies.

Botato300 commented 8 months ago

No, I did not upload the video. I'll try the cookies, thanks!