// Requires: PHP 4, Python 2.4 // You can obtain the campaign number from "View Campaigns" page. // You can obtain the code from "My ContextMiner" page. // This script assumes you have 'youtube-dl' available at $ytdlLocation. // 'youtube-dl' can be downloaded from http://rg3.github.com/youtube-dl/ // The videos downloaded from running this PHP script will be stored in // the current directory. $ytdlLocation = "."; // '.' means current directory. Do not put a trailing '/'. if ($argc!=3) { echo "Usage: php downloadYTVideosClient.php \n"; exit; } $cid = trim($argv[1]); $code = trim($argv[2]); $ytList = file_get_contents("http://www.contextminer.org/downloadYTVideosServer.php?cid=$cid&code=$code"); $fout = fopen("yt.temp", 'w'); fwrite($fout, $ytList); fclose($fout); $fin = fopen("yt.temp", 'r'); $line = fgets($fin); $response = trim($line); if ($response == "Success") { while ($line = fgets($fin)) { $ytID = trim($line); $ytURL = "http://www.youtube.com/watch?v=".$ytID; $command = "python " . $ytdlLocation . "/youtube-dl ". $ytURL; echo "Downloading $ytID\n"; system($command); } } else { echo "Invalid campaign ID or code.\n"; } fclose($fin); system ("rm -f yt.temp"); ?>