/*
The PHP5 function below generates a semicolon-separated file like the following:
"Pork and Beans" acoustic with Tay Zonday;http://www.youtube.com/watch?v=QQnT3psRi7Q
12 Angry Men;http://www.youtube.com/watch?v=52y55e3LpDQ
12:01 PM, time-travel short film from 1990;http://www.youtube.com/watch?v=PhRXTX0HFgw
...
*/
function collectData() {
$lines = array();
for ($year = 2005; $year <= 2008; $year++) {
for ($month = 1; $month <= 12; $month++) {
$overviewUrl = 'http://waxy.org/links/archive/' . $year . '/' . padVar($month, 2) . '/index.shtml';
echo '' . $overviewUrl . '
'; doFlush();
$dom = new domdocument;
@$dom->loadHtmlFile($overviewUrl);
$oXpath = new domXpath($dom);
$nodes = $oXpath->query('//div[@class="item"]/a[@href]');
foreach ($nodes as $node) {
$url = $node->getAttribute('href');
if ( striPos($url, 'http://www.youtube.com/watch') !== false ) {
$title = $node->firstChild->nodeValue;
$title = str_iReplace('Video: ', '', $title);
$line = str_iReplace(';', ' ', $title) . ';' . str_iReplace(';', ' ', $url);
$lines[] = $line;
echo misc_toXml($line) . '
';
}
}
}
}
sort($lines);
setFileText( 'waxy.txt', implode("\r\n", $lines) );
}