0

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

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Can you clarify (ie. reformulate) this sentence ```People put as much code in my application for you to simulate there is more code, but I could only put those above.```? – stvar Jun 19 '20 at 18:10
  • @stvar I say: "according to the application of the repository, you can try to simulate through this repository mentioned above" – Jacob de Oliveira Jun 19 '20 at 18:34
  • OK. Then have a look at my answer below. If still confused, just add comments below it. – stvar Jun 19 '20 at 18:35

1 Answers1

2

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.

stvar
  • 6,551
  • 2
  • 13
  • 28
  • so even if i modify the chunksize i will still upload 6 videos a day? – Jacob de Oliveira Jun 19 '20 at 18:38
  • Yes. The actual chunk size has no influence on how the API accounts for the cost of your `Video.list` endpoint call. – stvar Jun 19 '20 at 18:40
  • But any failed attempt at uploading one video (for whatever reason) still accounts for a completed API call; thus decreasing your allocated quota with `1600 + n` units (`n` is very small, depending of which video meta info parts you're setting along with the actual upload of your video). – stvar Jun 19 '20 at 18:44
  • Sorry for the typo above: please read `Videos.insert` instead of `Video.list`. – stvar Jun 19 '20 at 18:47