- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Google Apps 脚本将文件从 Google Drive 上传到 YouTube。
我只成功上传了大约 2MB 的视频。
这样做的主要原因是互联网连接速度慢,有时上传不可靠,因此让 Google 云端硬盘处理更容易,但是将大于 25MB 的文件上传到 YouTube 就很难...
脚本需要从“资源”>“高级 Google 服务...”启用“YouTube 数据 API”
函数代码:
// Upload Google Drive file to youtube
function uploadFileToYouTube(file) {
var name = file.getName();
var size = file.getSize();
var type = file.getMimeType();
var blob = file.getBlob();
var access = file.getSharingAccess();
var yt_privacy;
// Attempt to preserve permissions from Drive
switch(access) {
case DriveApp.Access.PRIVATE:
yt_privacy = "private";
break;
case DriveApp.Access.ANYONE:
yt_privacy = "public";
break;
case DriveApp.Access.ANYONE_WITH_LINK:
yt_privacy = "unlisted";
break;
default:
yt_privacy = "private";
}
Logger.log("File: "+name+" Size: "+size+" Type: "+type+" Access: "+access+" YT privacy: "+yt_privacy);
// Actually upload to YouTube....
var vid_res = {
snippet: {
title: name,
description: "Uploaded from Google Drive\nOriginal size: "+size+"\nOriginal filename: "+name+"\nOriginal mime type: "+type,
},
status: {
privacyStatus: yt_privacy
}
}
try {
var yt_upload = YouTube.Videos.insert(vid_res,"snippet,status",blob);
Logger.log(yt_upload);
} catch (e) {
Logger.log('Error uploading: '+ name + " Message: " + e.message);
}
return yt_upload;
}
// Test function. Needs test.avi on your Google drive
function testUpload() {
var file = DriveApp.getFilesByName("test.avi").next();
uploadFileToYouTube(file);
}
日志:
[13-12-30 13:18:34:924 SAST] File: SUNP0017.avi Size: 35258368 Type: video/x-msvideo Access: ANYONE_WITH_LINK YT privacy: unlisted
[13-12-30 13:18:45:924 SAST] Error uploading: SUNP0017.avi Message: We're sorry, a server error occurred. Please wait a bit and try again.
执行记录:
[13-12-30 13:18:33:518 SAST] Starting execution
[13-12-30 13:18:33:527 SAST] DriveApp.getFilesByName([SUNP0017.avi]) [0 seconds]
[13-12-30 13:18:34:799 SAST] (class).next() [1.271 seconds]
[13-12-30 13:18:34:799 SAST] File.getName() [0 seconds]
[13-12-30 13:18:34:799 SAST] File.getSize() [0 seconds]
[13-12-30 13:18:34:799 SAST] File.getMimeType() [0 seconds]
[13-12-30 13:18:34:799 SAST] File.getBlob() [0 seconds]
[13-12-30 13:18:34:921 SAST] File.getSharingAccess() [0.121 seconds]
[13-12-30 13:18:34:924 SAST] Logger.log([File: SUNP0017.avi Size: 35258368 Type: video/x-msvideo Access: ANYONE_WITH_LINK YT privacy: unlisted, []]) [0 seconds]
[13-12-30 13:18:40:474 SAST] Blob.getBytes() [5.549 seconds]
[13-12-30 13:18:40:504 SAST] Blob.getContentType() [0 seconds]
[13-12-30 13:18:45:924 SAST] Logger.log([Error uploading: SUNP0017.avi Message: We're sorry, a server error occurred. Please wait a bit and try again., []]) [0 seconds]
[13-12-30 13:18:45:924 SAST] Execution succeeded [12.398 seconds total runtime]
记录较小的文件:(有效)
[13-12-30 13:19:59:720 SAST] File: SUNP0024.avi Size: 3964928 Type: video/x-msvideo Access: ANYONE_WITH_LINK YT privacy: unlisted
[13-12-30 13:20:01:579 SAST] {id=<removed>, etag="<removed>", status={publicStatsViewable=true, privacyStatus=unlisted, embeddable=true, uploadStatus=uploaded, license=youtube}, snippet={publishedAt=2013-12-30T11:20:00.000Z, title=SUNP0024.avi, channelId=<removed>, description=Uploaded from Google Drive
Original size: 3964928
Original filename: SUNP0024.avi
Original mime type: video/x-msvideo, categoryId=22, channelTitle=Gert van den Berg, thumbnails={default={url=<removed>}, high={url=<removed>}, medium={url=<removed>}}, liveBroadcastContent=none}, kind=youtube#video}
较小文件的成绩单:(有效)
[13-12-30 13:19:58:311 SAST] Starting execution
[13-12-30 13:19:58:320 SAST] DriveApp.getFilesByName([SUNP0024.avi]) [0 seconds]
[13-12-30 13:19:59:549 SAST] (class).next() [1.229 seconds]
[13-12-30 13:19:59:550 SAST] File.getName() [0 seconds]
[13-12-30 13:19:59:554 SAST] File.getSize() [0.002 seconds]
[13-12-30 13:19:59:558 SAST] File.getMimeType() [0.002 seconds]
[13-12-30 13:19:59:559 SAST] File.getBlob() [0 seconds]
[13-12-30 13:19:59:719 SAST] File.getSharingAccess() [0.157 seconds]
[13-12-30 13:19:59:721 SAST] Logger.log([File: SUNP0024.avi Size: 3964928 Type: video/x-msvideo Access: ANYONE_WITH_LINK YT privacy: unlisted, []]) [0 seconds]
[13-12-30 13:20:00:756 SAST] Blob.getBytes() [1.034 seconds]
[13-12-30 13:20:00:759 SAST] Blob.getContentType() [0 seconds]
[13-12-30 13:20:01:579 SAST] Logger.log([{id=<removed>, etag="<removed>", status={publicStatsViewable=true, privacyStatus=unlisted, embeddable=true, uploadStatus=uploaded, license=youtube}, snippet={publishedAt=2013-12-30T11:20:00.000Z, title=SUNP0024.avi, channelId=<removed>, description=Uploaded from Google Drive
Original size: 3964928
Original filename: SUNP0024.avi
Original mime type: video/x-msvideo, categoryId=22, channelTitle=Gert van den Berg, thumbnails={default={url=<removed>}, high={url=<removed>}, medium={url=<removed>}}, liveBroadcastContent=none}, kind=youtube#video}, []]) [0 seconds]
[13-12-30 13:20:01:579 SAST] Execution succeeded [3.26 seconds total runtime]
最佳答案
目前,这是不可能的。 API 中有 blob 限制。由于他们为此创建了不同的方式,因此最好的办法是创建一个 Python 或 PHP 脚本并执行它,而不是 Apps 脚本
关于google-apps-script - 气体 : Blob upload to YouTube fails for most files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20838563/
我想从文档属性中获取数据,将其转换为数组,然后将其推送到工作表中。该工作表恰好位于与脚本所在的电子表格不同的电子表格中,但我已经解决了这个问题。我遇到的问题是将属性中的数据转换为二维数组 [{user
我想要解释 GCC 生成的程序集中与 .cfi_def_cfa_offset 指令一起使用的值。我隐约知道 .cfi 指令涉及调用帧和堆栈展开,但我想更详细地解释为什么,例如,在编译以下 C 程序时
编译以下指令时: movl 4(%ebp), 8(%ebp) 我得到:内存引用太多。 这是怎么回事? 最佳答案 括号前的数字是字节偏移量(这会导致发生内存引用),并且 movl 中不能有两个。您需要先
编译以下指令时: movl 4(%ebp), 8(%ebp) 我得到:内存引用太多。 这是怎么回事? 最佳答案 括号前的数字是字节偏移量(这会导致内存引用发生),并且 movl 中不能有两个。您需要先
编译如下指令时: movl 4(%ebp), 8(%ebp) 我得到:过多的内存引用。 这是怎么回事? 最佳答案 括号前的数字是一个字节偏移量(这会导致内存引用发生),你不能用movl有两个。您需要先
我正在尝试组装以下程序: .text .globl _search2 _search2: pushq %rbp movq %rsp, %rbp movq
我正在尝试在 Google Apps 脚本中创建自定义对话,如下所示: function onOpen() { SpreadsheetApp.getUi() .createMenu('Cu
我如何在谷歌应用程序脚本中创建一个库,我可以在其中仅共享库 key 并且人们可以使用它,而无需正确共享代码?我正在努力寻找解决方案,但我失败了。 我不想与全世界共享图书馆。我只想在不同的谷歌驱动器中使
因此,我将一个 google 表单输入到工作表中,然后从电子表格中,我使用电子表格中的答案模板制作 google 文档。 表单能够在中途保存并稍后通过自定义问题返回,询问他们是否要保存并返回(这会提交
我有一个每天运行的脚本,每天都会将新值设置为谷歌表格。我担心的是每次脚本运行时,它都会覆盖现有数据。我想要的是工作表底部最后一行的数据集,以便有一个延续。我已尝试使用下面的代码,但它不起作用。我该怎么
考虑以下 Google Apps 脚本代码: var ui = SpreadsheetApp.getUi(); var result = ui.prompt( 'How many days in
我在几张纸上使用一个脚本。为了避免每次更改时都更改每张工作表中的脚本,我创建了一个库(顺便说一下,是否有更好的库替代品?)。所以我在其他工作表中这样调用我的函数: myFunction(){ retu
我正在尝试使用 Google Apps 脚本将文件从 Google Drive 上传到 YouTube。 我只成功上传了大约 2MB 的视频。 这样做的主要原因是互联网连接速度慢,有时上传不可靠,因此
我正在向 Amazon S3 服务器运行 URLFetchApp 请求,以提取音频文件并将其重新定位到 Google 云端硬盘。 HTTPResponse 以 XML 格式返回。 我运行以下代码来转换
我编写了一个函数,该函数从电子表格中的原始文本中提取一些所需的信息并将其放入其他列中。但我只想在该列为空时使用此函数(因为,如果它不为空,是因为它的值是手动更新的)。我尝试使用下面的代码,但我发现 s
我正在开发一个个人项目,尝试扩展 10K ft 项目管理系统 API 的限制,并且是 GAS 或 Javascript 的新手,我将不胜感激对我正在尝试执行的代码的帮助。有关此内容的 API 文档可以
使用 Google Apps 脚本,我想解码 HTML,例如: Some text & text ¢ 存储为: Some text & text ¢ 所以,类似的问题:How t
我是一名优秀的程序员,十分优秀!