Does YouTube API forbid to download video captions if you are not it's owner?

杀马特。学长 韩版系。学妹 提交于 2019-12-01 17:41:53

问题


As it seems to me, YouTube API forbids to download video captions if you're not it's owner:

Captions for a video can only be created, retrieved, modified and deleted by the owner of that video.

The link above leads to documentation of YouTube API v2.0, which is deprecated, but it seems that in v3.0 this policy remains the same. If you try to download captions of a video, you'll get the following 403-error:

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.


At the same time you need only API_KEY to list captions of any YouTube video without any authorization (instantiating YouTube object as in this official example):

youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY,
        new HttpRequestInitializer() {
            public void initialize(HttpRequest request)
                throws IOException {
            }
        }).setApplicationName("youtube-cmdline-search-sample").build();

CaptionListResponse captionListResponse = youtube
    .captions()
    .list("snippet", "jNhtbmXzIaM")
    .setKey(API_KEY)
    .execute();

List<Caption> captions = captionListResponse.getItems();
CaptionSnippet snippet;
for (Caption caption : captions) {
    snippet = caption.getSnippet();
    System.out.println("ID: " + caption.getId());
    System.out.println("Name: " + snippet.getName());
    System.out.println("Language: " + snippet.getLanguage());
    System.out.println();
}

So does YouTube API v3.0 really restrict read access to captions while it's public data and there are even services and scripts allowing you to download captions of any YouTube video? How captions of any youtube video can be fetched (solutions via using API preferred)?

来源:https://stackoverflow.com/questions/32033153/does-youtube-api-forbid-to-download-video-captions-if-you-are-not-its-owner

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