How to improve my YouTube video upload data v3 [duplicate]

六月ゝ 毕业季﹏ 提交于 2021-01-07 01:20:51

问题


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 and javascript code

Arquivo Escolher arquivo Enviar
    </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(() => {
        



     });
  });


 }

The upload_video.js and cors_upload.js files are in this repository https://github.com/mesadhan/youtube-data-api-v3-example

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?

Note 1: The file cors_upload.js (which is in the aforementioned repository) contains the video's ajax upload

Note 2: upload is done in ajax with pure javascript

Thanks in advance


回答1:


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.

Do not interpret your daily quota of 10000 units as that allowing you to make 10000 API calls.

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.



来源:https://stackoverflow.com/questions/62474071/how-to-improve-my-youtube-video-upload-data-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!