3

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

  • Try using the URL format for the delete call with the ID as a query parameter instead of the one you are using. Their documentation for the URL of getting could be wrong. Also below they mention that ID is a query parameter. – Brian from state farm May 28 '15 at 18:50
  • Ya good observation that they mention ID as a query parameter in the documentation.. Still tried that Brian & got an error like "Unsupported output format". Will update the exact error message here after sometime. – Nikhil Kulkarni May 29 '15 at 09:32
  • did you find any resolution over this issue, right now i am fetching same kind of issue, and i could not get over it. – manish1706 Jan 03 '18 at 05:22

2 Answers2

1

I just tried the URL you mentioned in a browser and in the API explorer, and in both cases I received a 401 when I had no oAuth token and a 403 when I had an access token (since I'm not the owner), so the endpoints are acting as intended; according to the documentation, downloading captions requires oAuth consent from the owner of the video.

Perhaps, if you're getting 404s instead, there's a problem in the PHP library?

jlmcdonald
  • 13,408
  • 2
  • 54
  • 64
  • 2
    403 error is expected in Delete, insert or upload methods if you are not the owner, but I'm sure you won't get a "403 Forbidden" error when using **list** captions. Similarly I expect download.captions to work for non-owners too. Also, the documentation doesn't say anywhere that only owner can download the captions. The only problem I could think of in PHP library (Google/Service/Youtube.php) is about passing id as path parameter. I tried changing it to query but still error came up saying "Unsupported output format". Then I removed the tmft="srt" parameter, but still it isn't working. – Nikhil Kulkarni May 29 '15 at 05:18
  • 1
    The documentation says exactly that about downloading captions: "This request requires authorization with at least one of the following scopes (read more about authentication and authorization). https://www.googleapis.com/auth/youtube.force-ssl" -- that's the scope that grants an app consent to manage a user's YouTube account, thus indicating that only the owner of a video can make the request. More to the point, if you test in the api explorer, you'll see that if you authorize to a video you do own, you get a 200. Note that this was also the behavior in V2 of the API. – jlmcdonald May 29 '15 at 07:52
  • 1
    After going through this [stackoverflow Q&A](http://stackoverflow.com/questions/18192214/closed-captions-in-youtube-api-v3?rq=1) , It looked like captions could be downloaded by 3rd party (i.e non-owners) too in v3 API. The same line that you mention also exists in listing captions section here: https://developers.google.com/youtube/v3/docs/captions/list , but this works fine. Also no 403 error shows up as in delete method, giving further hope that captions cud be downloaded by third party. – Nikhil Kulkarni May 29 '15 at 09:24
  • The SO question you linked to clearly demonstrates that the user wasn't able to download captions. Ibrahim's update to his answer merely states that V3 finally received a captions endpoint, not that users could download them for videos they don't own. Basically, the download endpoint is working exactly as documented; therefore there's no bug (there is in the list endpoint, on the other hand, because according to the documentation it should also require authorization). You can always file a feature request, as there are certainly use cases for needing captions, but for now it's a no go. – jlmcdonald May 29 '15 at 16:47
1

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.