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.87k stars 326 forks source link

Error: Subtitles don't exist, but actual video has transcripts and closed captioning #140

Closed lolcowgo closed 2 years ago

lolcowgo commented 2 years ago

Hello, Short story, I've been collecting captions on a user and starting on 11/26 captions started not collecting for him (although other users still get captions correctly). Videos are always live streams which do correctly capture normally until this issue, not sure if something can be done from your end. On the video itself a transcript exists along with closed captioning, but again no pulls in the last month. One non-working videoid is here: 6hwQm8M0ycg last working videoid is here: 28TZHDO8R9Y from the user. Any assistance would be appreciated or please let me know if you need any other information. Merry Christmas as well.

The following is my error message: Traceback (most recent call last): File "C:-----\manualVideoCaptionOnly.py", line 21, in getCaptions(YouTubeTranscriptApi.get_transcript(video), video) File "C:\Users------\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\youtube_transcript_api_api.py", line 128, in get_transcript return cls.list_transcripts(video_id, proxies, cookies).find_transcript(languages).fetch() File "C:\Users------\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\youtube_transcript_api_api.py", line 70, in list_transcripts return TranscriptListFetcher(http_client).fetch(video_id) File "C:\Users------\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\youtube_transcript_api_transcripts.py", line 34, in fetch self._extract_captions_json(self._fetch_html(video_id), video_id) File "C:\Users-----\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\youtube_transcript_api_transcripts.py", line 44, 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=6hwQm8M0ycg! 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!

edit Saw in another thread you also asked to provide code that had a similar issue but then it magically worked for him, I use a CSV output and this is just to pull a single video so you'll have to do light editing, and if you or I could please delete my code after you take a look at it I would appreciate it:

removed code

jdepoix commented 2 years ago

Hi @lolcowgo, I can not replicate this error using 28TZHDO8R9Y nor 6hwQm8M0ycg. Is this error consistently showing for you? What version of this module and python are you on?

lolcowgo commented 2 years ago

Thanks for the quick reply, Just did an update to the module from 0.3.1 to 0.4.3 while browsing through your closed section to no success, I am also using python 3.9.9. I have attempted to use OIqN-Mc9dfk to no avail as well, however r3McS_dOX00 works.

jdepoix commented 2 years ago

OIqN-Mc9dfk is age restricted, therefore you can't access its transcripts without authentication. I just realised that this also is the case for 6hwQm8M0ycg, so that most likely is the reason for your error.

Read the READMEs section about cookies to find out how to work around age restrictions.

Let me know if this does the trick so that I can close this issue.

lolcowgo commented 2 years ago

Hello, Thank you very much for that that was the last thing to cross my mind! I'll look around at your link and work with that and if I incorrectly close the thread you can close it for me. Thank you very much for the hasty reply and solving the issue, Merry Christmas and thank you for this useful API.