如何改善我的YouTube视频上传数据v3 [英] How to improve my YouTube video upload data v3
问题描述
我有以下问题.Google最近将我的每日查询限制为10,000个,我正在寻找增加或减少块大小的方法.老实说,我不知道我需要增加/减少多少才能使用每次上传的几个查询,请按照下面的代码进行操作:
I have the following problem. Google recently limited my queries per day to 10,000 and I'm looking to increase or decrease my chunksize. I honestly don't know how much I need to increase / decrease to use a few queries per upload, follow the code below that I did:
HTML和javascript代码
</div>
<div id="authorize-button" class="g-signin2" data-theme="dark">Login</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="cors_upload.js"></script>
<script src="upload_video.js" charset="UTF-8"></script>
<script>
let uploader = new UploadVideo();
const CLIENT_ID = "seu cliente id";
const API_KEY = "sua api key";
const DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest"];
const SCOPES = 'https://www.googleapis.com/auth/youtubepartner https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/youtube';
function render() {
//
gapi.signin.render('authorize-button', {
callback: signinCallback,
clientid: CLIENT_ID,
cookiepolicy: 'single_host_origin',
scope: SCOPES,
theme:'dark'
});
}
var signinCallback = function (result) {
console.log('upload-url-token', result.access_token);
if (result.access_token) {
uploader.ready(result.access_token);
$("#authorize-button").hide();
}
};
function initApiClient() {
console.log('API_KEY', API_KEY);
console.log('CLIENT_ID', CLIENT_ID);
handleAuth();
}
function handleAuth() {
gapi.load('client:auth2', function () {
//gapi.client.setApiKey(API_KEY);
gapi.client.init({
apiKey:API_KEY,
discoveryDocs: DISCOVERY_DOCS,
clientId: CLIENT_ID,
scope: SCOPES,
}).then(() => {
});
});
}
upload_video.js和cors_upload.js文件在此存储库中 https://github.com/mesadhan/youtube-data-api-v3-例子
The upload_video.js and cors_upload.js files are in this repository https://github.com/mesadhan/youtube-data-api-v3-example
根据存储库的应用程序,您可以尝试通过上述存储库进行模拟.因此,在哪里可以在代码中插入chunksize来减少上传查询的次数?
according to the application of the repository, you can try to simulate through this repository mentioned above. So, where can I insert chunksize in my code to use fewer upload queries?
注意1:文件cors_upload.js(位于上述存储库中)包含视频的Ajax上传
Note 1: The file cors_upload.js (which is in the aforementioned repository) contains the video's ajax upload
注意2:使用纯JavaScript在ajax中完成上传
Note 2: upload is done in ajax with pure javascript
预先感谢
推荐答案
As per the official docs of Videos.insert
API endpoint, each and every upload of a video has a constant quota cost of 1600 units:
Quota impact: A call to this method has a quota cost of 1600 units.
请勿将您每天的10000个配额解释为可以进行10000个API调用.
Do not interpret your daily quota of 10000 units as that allowing you to make 10000 API calls.
每天10000个配额单位的数量使您最多可以上传6个视频(无论它们的实际大小如何)-如果不考虑可能发出的其他API调用的话.
A daily amount of 10000 quota units allows you to upload no more than 6 videos (regardless of their actual size) -- if not accounting for other API calls that you may issue.
这篇关于如何改善我的YouTube视频上传数据v3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!