PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Gianluca Zanferrari   Zanfi PHP YouTube Downloader   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Zanfi PHP YouTube Downloader
Get information and download a video from YouTube
Author: By
Last change:
Date: 1 year ago
Size: 1,560 bytes
 

Contents

Class file image Download
<?php
require('ZanfiYouTube.php');

// initialize the class with a yotube video ID or a youtube video url
// $ZanfiYouTube = new ZanfiYouTube('WaEKXGlfYj8');
$ZanfiYouTube = new ZanfiYouTube('https://www.youtube.com/watch?v=WaEKXGlfYj8');

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~ Data section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// leave parameter emtpy to print all data
// or give a path like: playbackTracking.videostatsWatchtimeUrl
// $ZanfiYouTube->printVideoInfo('streamingData.adaptiveFormats');

// print array with vieo thumbnails
// $ZanfiYouTube->printFormatted($ZanfiYouTube->arr_Video_thumbnails);

// print the array with video adaptive formats
$ZanfiYouTube->printFormatted($ZanfiYouTube->arr_Video_adaptive_formats);

// print the array with the best video+audio data
// $ZanfiYouTube->printFormatted($ZanfiYouTube->get_best_both());

// print the array with the best audio data
$ZanfiYouTube->printFormatted($ZanfiYouTube->get_best_audio());

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~ Download section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// uncomment where needed

// Starts download of video+audio
// $ZanfiYouTube->download_best_both();

// Starts download of audio
// $ZanfiYouTube->download_best_audio();
// shows the elapsed time for download (use it only after a download...)
// echo('Downloaded ' . $ZanfiYouTube->downloaded_bytes . ' bytes in ' . $ZanfiYouTube->elapsed_time . ' seconds');