【发布时间】:2015-10-03 05:21:00
【问题描述】:
在过去的几周里,我和我的同事一直在努力尝试通过 v3 API 为我们的客户 YouTube 视频添加字幕。大约一周后,我们终于可以上传字幕了.但是,我们可以下载上传的原始格式;所以我们知道文件已成功上传。
我们还能够让同步标志起作用,告诉 YouTube 运行脚本并设置视频的时间,但它实际上不起作用。它返回告诉我们它正在同步,但是当我们转到视频的 UI 时,它只显示字幕轨道名称并向我们提供消息“轨道内容未处理。”。我们已经用完了所有的时间,现在我们正在利用自己的时间来解决这个问题,但仍然没有运气。
以前有人遇到过这个问题吗?如果是这样,你能做些什么来让它发挥作用?
我将在下面发布我的代码的 sn-p,显示我们脚本的上传部分。
# Insert a video caption.
# Create a caption snippet with video id, language, name and draft status.
$captionSnippet = new Google_Service_YouTube_CaptionSnippet();
$captionSnippet->setVideoId($videoId);
$captionSnippet->setLanguage($captionLanguage);
$captionSnippet->setName($captionName);
$captionSnippet->setIsDraft( true );
# Create a caption with snippet.
$caption = new Google_Service_YouTube_Caption();
$caption->setSnippet($captionSnippet);
// Setting the defer flag to true tells the client to return a request which can be called
$client->setDefer(false);
// Get the file content's of the uploaded file
$file = file_get_contents( $captionFile['tmp_name'] );
// Create a request for the API's captions.insert method to create and upload a caption.
$insertRequest = $youtube->captions->insert("snippet", $caption, array(
'sync' => true,
'data' => $file,
'mimeType' => 'application/octet-stream',
'uploadType' => 'multipart' )
);
echo '<pre>'; print_r( $insertRequest ); echo '</pre>';
// // Read the caption file and upload it chunk by chunk.
$status = $insertRequest;
fclose($handle);
// If you want to make other calls after the file upload, set setDefer back to false
$client->setDefer(false);
谢谢你,
泰勒·斯坦豪斯
【问题讨论】:
-
这里的问题完全相同。它看起来像 YouTube 上的一个错误。希望很快能看到一些有意义的答案。
-
如果谷歌工程师可以评论这个问题会很好,因为他们显然应该监控这些标签。我今天又试了一次,没有成功。
标签: php youtube youtube-data-api