diff options
Diffstat (limited to '')
-rw-r--r-- | command/download.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/command/download.php b/command/download.php index d0999b4..8deb454 100644 --- a/command/download.php +++ b/command/download.php @@ -54,4 +54,72 @@ stdout(''); foreach ($conferences as $conference) { stdout('== %s ==', $conference->getSlug()); + + $relive = $conference->getRelive(); + if($relive->isEnabled()) + { + download( + 'relive-json', + $conference, + $relive->getJsonUrl(), + $relive->getJsonCache() + ); + } + + $schedule = $conference->getSchedule(); + if($schedule->isEnabled()) + { + download( + 'schedule-xml', + $conference, + $schedule->getScheduleUrl(), + $schedule->getScheduleCache() + ); + } + + foreach($conference->getExtraFiles() as $file) + { + download( + 'extra-file', + $conference, + $file, + get_file_cache($conference, $file) + ); + } +} + + + + +function get_file_cache($conference, $url) +{ + $info = parse_url($url); + $host = trim(preg_replace('/[^a-z0-9]/i', '_', $info['host']), '_'); + $path = trim(preg_replace('/[^a-z0-9]/i', '_', $info['path']), '_'); + return sprintf('/tmp/file-cache-%s_%s_%s-%s', $conference->getSlug(), $host, $path, md5($url)); +} + +function download($what, $conference, $url, $cache) +{ + stdout( + ' downloading %s from %s to %s', + $what, + $url, + $cache + ); + if(!do_download($url, $cache)) + { + stderr( + '!! download %s for conference %s from %s to %s failed miserably !!', + $what, + $conference->getSlug(), + $url, + $cache + ); + } +} + +function do_download($url, $cache) +{ + return true; } |