Merge branch 'master' of https://tildegit.org/tilderadio/site
continuous-integration/drone/pr Build encountered an error Details

This commit is contained in:
Robert Miles 2020-07-02 22:44:11 -04:00
commit 1c1744092b
3 changed files with 39 additions and 60 deletions

View File

@ -1,35 +1,7 @@
<?php
include 'apikey.php';
if (empty($apikey)) {
die("missing api key");
}
$context = stream_context_create([
"http" => [
"method" => "GET",
"header" => "X-API-Key: $apikey\r\n"
]
]);
$from = gmdate("Y-m-d\T00:00:00\Z", strtotime(date("w") ? "last sunday" : "sunday"));
$to = gmdate("Y-m-d\T00:00:00\Z", strtotime(date("w") ? "sunday" : "next sunday"));
$schedule = json_decode(
file_get_contents(
"https://radio.tildeverse.org/api/station/1/streamers/schedule?start=$from&end=$to",
false,
$context
),
true
);
usort($schedule, function ($a, $b) {
return $a["start"] <=> $b["start"];
});
function formatdate($date) {
return gmdate("Ymd\THis\Z", strtotime($date));
}
include 'schedule.php';
// ICS generation. Here be dragons.
// I created the file using a Python script and reverse-engineered it to figure this out.

View File

@ -1,36 +1,6 @@
<?php
include '../header.php';
include 'apikey.php';
if (empty($apikey)) {
die("missing api key");
}
$context = stream_context_create([
"http" => [
"method" => "GET",
"header" => "X-API-Key: $apikey\r\n"
]
]);
$from = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 1 day"));
$to = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 8 days"));
$schedule = json_decode(
file_get_contents(
"https://radio.tildeverse.org/api/station/1/streamers/schedule?start=$from&end=$to",
false,
$context
),
true
);
usort($schedule, function ($a, $b) {
return $a["start"] <=> $b["start"];
});
function formatdate($date) {
return gmdate("D M d H:i", strtotime($date));
}
include 'schedule.php';
?>
<h1><a href="https://tilderadio.org"><img style="width:75px;" src="../logos/tilderadio-green.png">tilderadio.org</a></h1>

37
schedule/schedule.php Normal file
View File

@ -0,0 +1,37 @@
<?php
include 'apikey.php';
if (empty($apikey)) {
die("missing api key");
}
$context = stream_context_create([
"http" => [
"method" => "GET",
"header" => "X-API-Key: $apikey\r\n"
]
]);
// allow ics.php to overwrite $from and $to
if (!isset($from,$to)) {
$from = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 1 day"));
$to = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 8 days"));
}
$schedule = json_decode(
file_get_contents(
"https://radio.tildeverse.org/api/station/1/streamers/schedule?start=$from&end=$to",
false,
$context
),
true
);
usort($schedule, function ($a, $b) {
return $a["start"] <=> $b["start"];
});
function formatdate($date) {
return gmdate("D M d H:i", strtotime($date));
}