Don't make stats public when uploading to YouTube via API
<p>I'm uploading to YouTube using Python via <a href="https://developers.google.com/youtube/v3/guides/uploading_a_video" rel="nofollow">an officially provided script</a>.</p>

<p>The default settings for my channel (defined on youtube.com/upload_defaults when logged in) have <strong>Make video statistics on the watch page publicly visible</strong> set to disabled.</p>

<p>The response contains the following</p>

<pre><code>'status': {
  'publicStatsViewable': True,
</code></pre>

<p>and the <strong>edit</strong> page (<strong>advanced</strong> tab) of the video reveals that it is in fact <a href="http://i.stack.imgur.com/NyWTP.png" rel="nofollow">turned on</a>.</p>

<p>How to disable publicly visible statistics for a video when uploading via API with Python?</p>

<p>I assume something in this part of the upload script needs to be changed but it is unclear to me which:</p>

<pre><code>body=dict(
    snippet=dict(
      title=options.title,
      description=options.description,
      tags=tags,
      categoryId=options.category
    ),
    status=dict(
      privacyStatus=options.privacyStatus
    )
  )

  # Call the API's videos.insert method to create and upload the video.
  insert_request = youtube.videos().insert(
    part=",".join(body.keys()),
    body=body,
    media_body=MediaFileUpload(options.file, chunksize=-1, resumable=True)
  )

  resumable_upload(insert_request)
</code></pre>

<p>The solution was to modify the body to include <code>status.publicStatsViewable</code>, set to <code>False</code>. Just add the following line to the <code>body</code> construction block:</p>

<pre><code>      publicStatsViewable=False,
</code></pre>

<p>so that it looks like:</p>

<pre><code>body=dict(
    snippet=dict(
      title=options.title,
      description=options.description,
      tags=tags,
      categoryId=options.category
    ),
    status=dict(
      publicStatsViewable=False,
      privacyStatus=options.privacyStatus
    )
  )
</code></pre>

<p>Note that I only tested with the value being a boolean <code>False</code>. I did not test it with using a string.</p>

python youtube-api youtube-api-v3