Back to ziggeo.com

How can I pull all videos from your servers?

Pulling videos from our servers is simple. The following PHP script is an example on how to do it:

require_once(dirname(__FILE__) . "/Ziggeo/Ziggeo.php");

$opts = getopt("", array("token:", "private:", "target:"));

$ziggeo = new Ziggeo($opts["token"], $opts["private"]);

$skip = 0;
$limit = 100;
$returned = -1;

$videos = array();

while ($returned != 0) {
	$ret = $ziggeo->videos()->index(array(
		"skip" => $skip,
		"limit" => $limit
	));
	$videos = array_merge($videos, $ret);
	$returned = count($ret);
	$skip += count($ret);
}

foreach ($videos as $video) {
	$file_name = $opts["target"] . "/" . $video->token . ".mp4";
	echo $file_name . "\n";
	$file_data = $ziggeo->videos()->download_video($video->token);
	file_put_contents($file_name, $file_data);
}

You could call it as follows:

php pull_videos.php --token APPLICATION_TOKEN --private PRIVATE_KEY --target ~/SAVE_VIDEOS_HERE
Have more questions? Submit a request

Comments