// Requires: PHP 4 // should have the list of YouTube URLs - one per line if ($argc!=3) { echo "Usage: php extractYTVideoURLs.php \n"; exit; } $urlListFile = trim($argv[1]); $outputFile = trim($argv[2]); $fin = fopen($urlListFile, 'r'); $fout = fopen($outputFile, 'w'); while ($yt_url = fgets($fin)) { $yt_url = trim($yt_url); echo "Processing $yt_url\n"; $html = file_get_contents($yt_url); $fh = fopen('yt.temp', 'w'); fwrite($fh, $html); fwrite($fh, "\n"); fclose($fh); $fh = fopen('yt.temp', 'r'); $previousURL = ""; while ($line = fgets($fh)) { $line = trim($line); if (preg_match("/