Helpful PHP scripts Pt. 3 - Export all your video details to a .csv file
January 29, 2021 - Erikka Innes in Video list, PHP
In our 3rd installment of helpful PHP scripts 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 check out the API reference documentation for listing videos, which is what we'll use to export our content to a .csv file. The API reference content is here: List all videos
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!
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
- 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
php create_csv.php
- 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.
You can also view the documentation for listing all videos in our API reference content here: List all videos Thanks for checking out our latest installment of Helpful PHP scripts! If you have any question or suggestions, please share them on our community forum.
You May Also Like...
- Helpful PHP Scripts Pt1 - Upload Videos from Google Drive to API Video - Move videos from Google Drive to api.video in bulk.
- Helpful PHP Scripts Pt2 - Upload Videos from an FTP Server - Move videos from an FTP server to api.video in bulk.
- Private Video Upload with a Public Token - Use a delegated token to allow a customer to do a one use video upload.
Erikka Innes
Developer Evangelist
Follow our latest news by subscribing to our newsletter
Create your free account
Start building with video now