8

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)?

Filipp Voronov
  • 4,077
  • 5
  • 25
  • 32
  • 2
    Currently, I believe only the owner of a video can download the captions, but others can download captions for public videos provided the owner has enabled third-party contributions for it. – not_a_bot Aug 17 '15 at 16:11
  • 1
    https://stackoverflow.com/a/70756998 – C-Y Jan 18 '22 at 14:19
  • @not_a_bot So why do sites like `downsub` still work and download subtitles of any youtube video? – Nam Lee Sep 27 '22 at 17:25
  • @NamLee because they scrape the html of the video page. The caption url is somewhere in there – West Jul 27 '23 at 06:36

0 Answers0