diff options
author | MaZderMind | 2016-12-11 21:46:01 +0100 |
---|---|---|
committer | MaZderMind | 2016-12-11 21:46:01 +0100 |
commit | 284878f0f9917b55359cd464b86508cacc472653 (patch) | |
tree | 98014d22b46d7fc9601a3b7bbd26c56afb1cf45c /command/download.php | |
parent | 6e0f7423769174b83d6b5618db7c33d54967099a (diff) |
add cache-file getters and download preparations
Diffstat (limited to 'command/download.php')
-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; } |