1

I know that there were plenty of questions about this from years ago, yet we have a new issue that emerged a few months ago, and Google Cloud support engineer explicitly asked me to post my question to SO.

Up until recently, we were able to download captions from the API. After reviving our codebase, we discovered we could no longer use developerKey to download captions. After using OAuth, as suggested in the error message, we got 403.

The permissions associated with the request are insufficient to download the caption track. The request might not be properly authorized, or the video order might not have enabled third-party contributions for this caption.". Details: "[{'message': 'The permissions associated with the request are not sufficient to download the caption track. The request might not be properly authorized, or the video order might not have enabled third-party contributions for this caption.

The code is very much the same and can be boiled down to

   youtube = build('youtube', 'v3', credentials=creds) # must use oauth
   req_list = youtube.captions().list(part='snippet', videoId="r5exYRYDfy8")
   res = req_list.execute() # works
   req_download = youtube.captions().download(id=res['items'][0]['id'])
   res = req_download.execute() # fails

Where r5exYRYDfy8 is one of the videos for which we were historically able to obtain the captions. I retrieved all videoIds from our cache, for which we previously fetched the captions and none of them work.

It seems that Google is doing some changes to captions in general. For example, the autogenerated captions can no longer be auto-translated while watching a video. Does anyone has any idea how vast these changes are and whether we can rely on captions in our product?

Vojtech Letal
  • 2,168
  • 3
  • 13
  • 17
  • Maybe [my answer](https://stackoverflow.com/a/70013529/7123660) on another similar question may help you. – Benjamin Loison Aug 05 '22 at 11:13
  • @BenjaminLoison I remember reading your response, or a similar one. That is an undocumented endpoint used by youtube to support clients, such as web and mobile apps. Right? If it is so, than using it is against ToS and I will no be able to push it to production. – Vojtech Letal Aug 05 '22 at 12:51
  • You are right but AFAIK there isn't any alternative and Google doesn't really seem to care about it... So IMO it's fair to use this undocumented endpoint until they provide a documented solution that suits your needs. It's a bit hypocritical that *Google Cloud support engineer explicitly asked [you] to post [your] question to SO* as it was already done many times and recently it seems clear that there isn't any solution provided by Google to your problem, so they should work on it instead of moving your question to SO where it doesn't make the situation go forward. – Benjamin Loison Aug 05 '22 at 14:10
  • Maybe `youtube-dl` and `yt-dlp` use another endpoint, this is a way to dig if you're concerned with ToS. – Benjamin Loison Aug 05 '22 at 14:11
  • If it works with a list and doesn't with a download the documentation says that the scopes for both of those methods are the same. I would log it as a bug [issue forum](https://issuetracker.google.com/issues/new?component=186600&template=874803) – Linda Lawton - DaImTo Aug 05 '22 at 16:43
  • It really doesn't make sense to be able to use [Captions: list](https://developers.google.com/youtube/v3/docs/captions/list) but not [Captions: download](https://developers.google.com/youtube/v3/docs/captions/download) only using the YouTube Data API v3 key for unlisted and public videos... – Benjamin Loison Aug 07 '22 at 09:15

1 Answers1

0

It is not possible to download captions for an arbitrary video.

I submitted an issue to Google's issue tracker. #241669016. I've been told this behavior is expected. Only owners of a video can download its captions.

This new behavior is not appropriately documented as of now. I was promised that they would create an internal ticket to update the documentation accordingly.

Vojtech Letal
  • 2,168
  • 3
  • 13
  • 17
  • 1
    So why do sites like `downsub` still work and download subtitles of any youtube video? – Nam Lee Sep 27 '22 at 17:05
  • @NamLêQuý Because you can use a non-public API used directly by the player to get the subtitles, which I could not use. More here: https://stackoverflow.com/a/46915020/5094001 – Vojtech Letal Oct 20 '22 at 14:50
  • 1
    this stopped working currently (11 Dec 2021) – Nam Lee Nov 02 '22 at 22:27