Helpful PHP Scripts Pt. 3 - Export All Your Video Details to a .csv File
January 29, 2021 - Erikka Innes
In our 3rd installment of helpful PHP scripts (again from Hervé Pita) for bulk video uploads, we'll take a look at how to export all your video data to a .csv file. This script is part of a collection of scripts that help with bulk video uploads. All are 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 them. The scripts you'll find include:
- Ingest Videos from Google Drive - You can transfer all your videos from a folder in Google Drive to your api.video account with this CLI script.
- Ingest Videos from an FTP Server - Transfer all your videos from the FTP server of your choice to your api.video account.
- Export All Your Video Data to .csv - With this script you can grab details about each video in your api.video account and gather it in one .csv spreadsheet.
- Update Metadata for api.video Videos Using CSV - You can update your metadata in bulk with this script.
- Update Video Settings in Bulk Without a CSV File - Update videos to all be public or private or offer an mp4 download or disable an mp4 download.
We'll be talking about Export All Your Video Data to .csv today! You'll be able to see:
- videoId - the unique identifier for referencing the video in API calls
- title - the title of the video
- publishedAt - when a video was published, in ISO-8601 format
- iframe code - the code for embedding your video as an iframe
- thumbnail - the thumbnail image for the video if one was set
- mp4Support - the URL for the mp4 of the video if one is available
- metadata - all key value pairs you set to describe the video (if you didn't set any you won't have them)
You can use the videoId to associate the video with a custom player you created.
Now that you know what kind of data you'll receive, let's get started!
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
- Navigate to the Helpful PHP Scripts repository.
- Click Code and from the drop-down click Download ZIP. (You can also install from the CLI if you prefer.)
- Put the contents of your new .zip file in a folder you want to work from.
- Navigate to the folder containing the contents of your zip file in the terminal.
- In the terminal, type:
composer require api-video/php-sdk
Try the Script
- In the terminal, type
- You're asked what environment you want to use, prod or sandbox. For our walkthrough, choose prod. NOTE: You should choose the environment you have videos for. If you choose one of these environments and don't have videos stored there, you won't get any data to review.
- Provide your API key. You can get this by navigating to my.api.video and copying the appropriate key.
- Your .csv file will build and be output to project_details.csv.
Thanks for checking out our latest installment of Helpful PHP scripts!