Get closed caption “cc” for Youtube video

2019-03-13 04:48发布

Does any one know how to get the CC for any Youtube video that has the caption available? I know on the API 2.0 documentation mentions that it is only available for the owner of the video... but I was able to get some of the video's caption even though I'm not the owner of any....

There are two APIs (or links to API) can be used. they both rout to timpedtext API. before I mention them we should note the parameters the API need. which are:

  • lang: {en, fr,...} required.
  • v: {video ID} required.
  • name: the track name, Required only if it is set. (and with this is my problem.)
  • tlang: translation to language. optional (should be set if you like to translate the CC to other language.

The API links are:

  1. http://video.google.com/timedtext?lang=fr&v=PILzP-bIeLo&name=french Note the above example would return nothing if you remove the name=French or set it to something else...

  2. http://www.youtube.com/api/timedtext?v=zzfCVBSsvqA&lang=en Note this example would return nothing if you set the name=...

  3. http://www.youtube.com/api/timedtext?v=ZdP0KM49IVk&lang=en yet the actual video has caption.

Example 3 does not return the CC data.

So I'm guessing that example 3 need to have the name parameter set. and my main problem is how do I find the name parameter if it is set or not. and if it is set how do I know what is it?

4条回答
一夜七次
2楼-- · 2019-03-13 04:51

Your first example should work without the name= part. This did the job for me:

video.google.com/timedtext?lang={languageID}&v={videoId}

To fetch the english CC version from the previous answer, it would look like this:

http://video.google.com/timedtext?lang=en&v=zzfCVBSsvqA
查看更多
Juvenile、少年°
3楼-- · 2019-03-13 04:53

You can get the list of available captions with http://video.google.com/timedtext?type=list&v=zzfCVBSsvqA request.

Your 3rd video has only automatically generated captions, which you cannot fetch easily.

查看更多
Deceive 欺骗
4楼-- · 2019-03-13 04:54

If video.google.com does not fetch your closed caption file OR you don't want your file in XML format, but would rather SRT (see note below), try:

CC SUBS

NOTE: SRT can be transformed into virtually ANY format - either using free subtitling tools OR by replacing \n\n with |, \n with ; and then | into \n, you get a CSV file that can be opened in a spreadsheet, for example.

查看更多
混吃等死
5楼-- · 2019-03-13 05:10

Here my suggestions after spending some time:

查看更多
登录 后发表回答