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

Transcripts present in youtube but api is throwing error #147

Closed soumyasj closed 2 years ago

soumyasj commented 2 years ago

For the following video link https://www.youtube.com/watch?v=4F2N1QUI7hc Transcripts are present in youtube but the api throws the following error Could not retrieve a transcript for the video https://www.youtube.com/watch?v=4F2N1QUI7hc! This is most likely caused by:

Subtitles are disabled for this video

jdepoix commented 2 years ago

When I open that YouTube link it gives me an error that this video is not allowed to be viewed from my country (Germany). Therefore I can't really check what's going on. But it seems very likely to me that this is the reason for your error. Since requests done by this module are not authenticated, videos which are restricted to certain countries probably won't work. However, you could try and use a cookie from a logged in session. Check out the docs to find out how to that.

Please let me know if that fixed the issue, so that I know for future issues!

jdepoix commented 2 years ago

@soumyasj have you had the chance to try it using an existing session? Can I close this issue?

rob70 commented 2 years ago

I ran into a similar issue for 0.4.4 for this video: https://www.youtube.com/watch?v=TJqlmb1FPyI The subtitles show up in my browser, and translation works, too. The youtube channel owner says he has experienced an issue with the subtitles, however: https://twitter.com/JabbarRafique/status/1510022079135027200. It is not an age-restricted video and does not require a login to watch. Thanks.

jdepoix commented 2 years ago

@rob70 have you specified the language? Only russian subtitles are available and if no language is specified english will be used as the default. Therefore, no transcript is found. I can retrieve the transcripts without a problem when running:

YouTubeTranscriptApi.get_transcript("TJqlmb1FPyI", ["ru"])
rob70 commented 2 years ago

Thanks for swift response. This worked out for me as well.

jdepoix commented 2 years ago

I will close this now due to inactivity

soumyasj commented 1 year ago

Greetings, You can close the issue. Thank you.

Regards,Soumya Shamarao JahagirdarMasters' by Research (MS), CVIT, IIIT Hyderabad

On Wed, Mar 30, 2022 at 6:58 PM jdepoix @.***> wrote:

@soumyasj https://github.com/soumyasj have you had the chance to try it using an existing session? Can I close this issue?

— Reply to this email directly, view it on GitHub https://github.com/jdepoix/youtube-transcript-api/issues/147#issuecomment-1083141779, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXAM6EKV6AGNSTKJV6KQQTVCRJJPANCNFSM5PXLMPHQ . You are receiving this because you were mentioned.Message ID: @.***>