是否可以从Youtube视频中提取隐藏式字幕脚本?
我们在youtube上有200多个网络广播,每个网络广播至少有一个小时.Youtube已经关闭了所有视频的标题,但似乎用户无法获得它.
我在此博客中尝试过该网址,但它不适用于我们的视频.
http://googlesystem.blogspot.com/2010/10/download-youtube-captions.html
谢谢
我有以下代码下载带有YouTube视频副标题的xml文件
Sub Test()
Dim http As Object
Dim oStream As Object
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "http://video.google.com/timedtext?lang=en&v=qANA6POtuFo", False
http.send
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write http.responseBody
oStream.SaveToFile ThisWorkbook.Path & "\Sample.xml", 2
oStream.Close
End Sub
Run Code Online (Sandbox Code Playgroud)
但它不适用于其他视频,例如我尝试了这个链接v = 4Z3EJrh7_5k
知道如何使用任何带字幕的视频进行下载吗?
有没有人知道如何获得具有标题的Youtube视频的CC?我知道在API 2.0文档中提到它只适用于视频的所有者...但我能够获得一些视频的标题,即使我不是任何人的拥有者....
可以使用两个API(或API的链接).他们都尝试了timpedtext API.在我提到它们之前,我们应该注意API需要的参数.哪个是:
lang: {en, fr,...}
需要.v: {video ID}
需要.name
:曲目名称,仅在设置时为必填项.(这是我的问题.)tlang
:翻译成语言.可选(如果您想将CC翻译成其他语言,则应设置. API链接是:
http://video.google.com/timedtext?lang=fr&v=PILzP-bIeLo&name=french 请注意,如果删除name = French或将其设置为其他内容,则上述示例将不返回任何内容...
http://www.youtube.com/api/timedtext?v=zzfCVBSsvqA&lang=en 请注意,如果您设置名称=此示例将不返回任何内容= ...
http://www.youtube.com/api/timedtext?v=ZdP0KM49IVk&lang=en 但实际视频有标题.
示例3不返回CC数据.
所以我猜测示例3需要设置名称参数.我的主要问题是如果设置了名称参数,我该如何找到它.如果设置了,我怎么知道它是什么?
如果我的视频有英文字幕,我可以使用如下代码强制显示它们:
hl=en&cc_lang_pref=en&cc_load_policy=1
Run Code Online (Sandbox Code Playgroud)
所以完整的代码是:
<iframe
width="560" height="315"
src="https://www.youtube.com/embed/3I3Rjw_4Ucw?hl=en&cc_lang_pref=en&cc_load_policy=1"
frameborder="0" gesture="media"
allow="encrypted-media" allowfullscreen>
</iframe>
Run Code Online (Sandbox Code Playgroud)
但是,如果视频没有字幕,它似乎不起作用。在这种情况下,我想强制显示 Youtube 自动生成的字幕。是否可以?
我已经构建了一个能够阅读任何 Youtube 视频成绩单 (gapi.client.youtube.captions.download) 的 javascript 代码。auth 2.0 工作正常,我在本地网络服务器上运行我的应用程序一切正常,问题是当我运行请求时出现错误 403:cb=gapi.loaded_0:164 GET https://content.googleapis。 com/youtube/v3/captions/My_API_Key 403 我在 StackOverflow 中没有找到任何解决方案......知道吗?
这是我的js文件:
const CLIENT_ID = 'My_Client_ID';
const DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest"];
const SCOPES = 'https://www.googleapis.com/auth/youtube.readonly';
const authorizeButton = document.getElementById('enter-button');
const signoutButton = document.getElementById('exit-button');
const content = document.getElementById('content');
// default youtube channel
const defaultChannel = 'googledevelopers';
// Load auth2 library
function handleClientLoad(){
gapi.load('client:auth2', initClient);
}
// Init API client library and set up sing in listeners
function initClient(){
gapi.client.init({
discoveryDocs: DISCOVERY_DOCS,
clientId: CLIENT_ID,
scope: SCOPES
}).then(() …
Run Code Online (Sandbox Code Playgroud) javascript youtube google-api-js-client google-apis-explorer