api.video

Features

Documentation

Tutorials

Helpful PHP Scripts Pt 5: Update Video Settings in Bulk Without a CSV File

February 11, 2021 - Erikka Innes

This script is part of a collection of scripts from Hervé Pita that help with bulk video uploads. Everything is available in our Helpful PHP Scripts repository on Github. In each part of this series, we'll walk through how to set up one of the scripts. What you'll find includes:

Today we're going to learn how to use the script that lets you do a bulk update without a CSV file. Rather than choosing custom fields, these are preset. You'll be able to quickly update your videos to all:

  • Be public
  • Be private
  • Support an mp4 download
  • Not support an mp4 download

Prerequisites

For this project you'll need:

  • PHP 5.4 or greater with the command-line interface (CLI) and JSON extension installed
  • The Composer dependency management tool (or another way to manage your dependency management). See the Composer website for installation options.
  • A GitHub account
  • An api.video account
  • Your API key for either production or sandbox

Installation

  1. Navigate to the Helpful PHP Scripts repository.
  2. Click Code and from the drop-down click Download ZIP. (You can also install from the CLI if you prefer.)
  3. Put the contents of your new .zip file in a folder you want to work from.
  4. Navigate to the folder containing the contents of your zip file in the terminal.
  5. In the terminal, type composer require api-video/php-sdk

Try the Script

  1. In the terminal, type php bulk_scripts.php
  2. You're asked what environment you want to use, prod or sandbox (p or s). Choose p.
  3. Provide your API key. Make sure it matches the environment choice you made in the last step. You can get your key by navigating to my.api.video and copying the appropriate key.
  4. Next, you choose what operation to apply to all your videos. The options are private - this makes all your videos private. public - this makes all your videos public. mp4on - this makes all videos offer an mp4 download. mp4off - this makes all videos disable the option of an mp4 download.
  5. The script runs and when it's done, you can check to see the settings are updated. If you made a mistake, you can bulk update again to correct, or if you need to change only some videos, try the script that lets you update some files that you list in a .tsv - Update Metadata for api.video Videos Using CSV

And that's it for today!

Erikka Innes

Developer Evangelist

Get started now

Connect your users with videos