aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--command/download.php68
-rw-r--r--model/Conference.php4
-rw-r--r--model/Relive.php5
-rw-r--r--model/Schedule.php7
4 files changed, 83 insertions, 1 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;
}
diff --git a/model/Conference.php b/model/Conference.php
index be62fdb..6c14746 100644
--- a/model/Conference.php
+++ b/model/Conference.php
@@ -221,4 +221,8 @@ class Conference extends ModelBase
public function getRelive() {
return new Relive($this);
}
+
+ public function getExtraFiles() {
+ return $this->get('EXTRA_FILES', []);
+ }
}
diff --git a/model/Relive.php b/model/Relive.php
index 7f0e747..5676b62 100644
--- a/model/Relive.php
+++ b/model/Relive.php
@@ -24,6 +24,11 @@ class Relive
return $this->getConference()->get('CONFERENCE.RELIVE_JSON');
}
+ public function getJsonCache()
+ {
+ return sprintf('/tmp/relive-cache-%s', $this->getConference()->getSlug());
+ }
+
public function getTalks()
{
if(!file_exists($this->getJsonUrl()))
diff --git a/model/Schedule.php b/model/Schedule.php
index eb9fe05..4032ecb 100644
--- a/model/Schedule.php
+++ b/model/Schedule.php
@@ -265,11 +265,16 @@ class Schedule
return ((int)$parts[0] * 60 + (int)$parts[1]) * 60;
}
- private function getScheduleUrl()
+ public function getScheduleUrl()
{
return $this->getConference()->get('SCHEDULE.URL');
}
+ public function getScheduleCache()
+ {
+ return sprintf('/tmp/schedule-cache-%s', $this->getConference()->getSlug());
+ }
+
public function getScheduleToRoomSlugMapping()
{
$mapping = array();