Search code examples
phpyoutube-apigoogle-api-php-clientclosed-captionsyoutube-data-api

Unable to download closed captions in Youtube API v3


Im using the PHP example code given in Youtube API v3 : https://developers.google.com/youtube/v3/docs/captions/download , to download captions from 3rd party, publicly available YouTube videos in my webapp i.e. I have NOT uploaded the content on Youtube.

I am able to get access to the list of caption tracks, but unable to download the caption using the caption track ID from the received list.

The error that shows up upon attempting to DOWNLOAD is:

Error calling GET https:// www.googleapis.com/youtube/v3/captions/Lw0e5xDNU17GFafOl8DcyeOtwzWJTf9V?tfmt=srt&alt=media: (404) Not Found

(I have tried removing tfmt (optional parameter), but still gives an error.)

But the error is different for attempting to DELETE captions:

Error calling DELETE https:// www.googleapis.com/youtube/v3/captions?id=Lw0e5xDNU17GFafOl8DcyeOtwzWJTf9V: (403) Forbidden

Therefore it seems that captions.download is NOT forbidden for users other than owner (just like the captions.list is NOT forbidden) and therefore I would like to use this data for my webapp.

Any help is gratefully received.

Thanks,

Nikhil


Solution

  • I have found another way to access any YouTube video's caption data. The code is written in Ruby.

    Read Youtube transcript (captions) from any public Youtube video

    Works great, I just need to find a way to integrate this with my webapp.