Unable to download closed captions in Youtube API v3

自作多情 提交于 2019-12-06 08:43:12

问题


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


回答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?




回答2:


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.



来源:https://stackoverflow.com/questions/30514097/unable-to-download-closed-captions-in-youtube-api-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!