mirror of
https://github.com/voc/streaming-website
synced 2024-11-10 14:44:21 +00:00
Merge branch 'master' into events/33c3
This commit is contained in:
commit
9af641e585
4 changed files with 117 additions and 23 deletions
|
@ -72,14 +72,14 @@ see [deploy.sh](deploy.sh)
|
||||||
|
|
||||||
## JSON-API
|
## JSON-API
|
||||||
|
|
||||||
Unter der URL http://streaming.media.ccc.de/streams/v1.json bietet die
|
Unter der URL http://streaming.media.ccc.de/streams/v2.json bietet die
|
||||||
Steaming-Webseite eine Übersicht über alle konfigurierten Räume und Streams in
|
Steaming-Webseite eine Übersicht über alle konfigurierten Räume und Streams in
|
||||||
einem maschinenlesbaren Format an. Dieses kann z.B. genutzt werden, um in den
|
einem maschinenlesbaren Format an. Dieses kann z.B. genutzt werden, um in den
|
||||||
diversen Anwendungen, die sich rund um das Konferenzgeschehen entwickelt haben,
|
diversen Anwendungen, die sich rund um das Konferenzgeschehen entwickelt haben,
|
||||||
Player und Links zu Liveübertragungen anzubieten.
|
Player und Links zu Liveübertragungen anzubieten.
|
||||||
|
|
||||||
Wie die URL vermuten lässt, ist die API versioniert. Dies bedeutet, dass in
|
Wie die URL vermuten lässt, ist die API versioniert. Dies bedeutet, dass in
|
||||||
der `v1.json` keine Felder *entfernt werden* oder ihre *Bedeutung ändern* – es
|
der `v2.json` keine Felder *entfernt werden* oder ihre *Bedeutung ändern* – es
|
||||||
können aber durchaus *neue Felder* hinzukommen. Eine formalere Spezifikation
|
können aber durchaus *neue Felder* hinzukommen. Eine formalere Spezifikation
|
||||||
des JSON-Formats ist tbd. Ein Beispiel kann [hier
|
des JSON-Formats ist tbd. Ein Beispiel kann [hier
|
||||||
betrachtet](https://gist.github.com/MaZderMind/d5737ab867ade7888cb4) werden.
|
betrachtet](https://gist.github.com/MaZderMind/a91f242efb2f446a2237d4596896efd6) werden.
|
||||||
|
|
|
@ -107,6 +107,12 @@ try {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if($route == 'streams/v2.json')
|
||||||
|
{
|
||||||
|
require('view/streams-json-v2.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
else if($route == 'about')
|
else if($route == 'about')
|
||||||
{
|
{
|
||||||
// global about-page
|
// global about-page
|
||||||
|
|
|
@ -2,23 +2,9 @@
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$conferences = Conferences::getActiveConferences();
|
foreach (Conferences::getActiveConferences() as $conference)
|
||||||
|
|
||||||
$struct = array();
|
|
||||||
if(isset($GLOBALS['CONFIG']))
|
|
||||||
$saved_config = $GLOBALS['CONFIG'];
|
|
||||||
|
|
||||||
foreach ($conferences as $conference)
|
|
||||||
{
|
{
|
||||||
/*
|
$overview = $conference->getOverview();
|
||||||
ok. das ist so hacky. EIGENTLICH müsste man aus ModelBase
|
|
||||||
das $GLOBALS tilgen und von der api ne v2 releasen, welche
|
|
||||||
conferences als eigenes Objekt betrachtet
|
|
||||||
*/
|
|
||||||
$GLOBALS['CONFIG'] = $conference['CONFIG'];
|
|
||||||
$GLOBALS['MANDATOR'] = $conference['slug'];
|
|
||||||
|
|
||||||
$overview = new Overview();
|
|
||||||
|
|
||||||
foreach($overview->getGroups() as $group => $rooms)
|
foreach($overview->getGroups() as $group => $rooms)
|
||||||
{
|
{
|
||||||
|
@ -99,14 +85,11 @@ foreach ($conferences as $conference)
|
||||||
}
|
}
|
||||||
|
|
||||||
$struct[] = array(
|
$struct[] = array(
|
||||||
'conference' => $conference['title'],
|
'conference' => $conference->getTitle(),
|
||||||
'group' => $group,
|
'group' => $group,
|
||||||
'rooms' => $roomstruct,
|
'rooms' => $roomstruct,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($saved_config))
|
|
||||||
$GLOBALS['CONFIG'] = $saved_config;
|
|
||||||
|
|
||||||
echo json_encode($struct, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
echo json_encode($struct, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||||
|
|
105
view/streams-json-v2.php
Normal file
105
view/streams-json-v2.php
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
foreach (Conferences::getActiveConferences() as $conference)
|
||||||
|
{
|
||||||
|
$overview = $conference->getOverview();
|
||||||
|
|
||||||
|
$groupstruct = array();
|
||||||
|
foreach($overview->getGroups() as $group => $rooms)
|
||||||
|
{
|
||||||
|
$roomstruct = array();
|
||||||
|
foreach($rooms as $room)
|
||||||
|
{
|
||||||
|
$streams = array();
|
||||||
|
foreach($room->getStreams() as $stream)
|
||||||
|
{
|
||||||
|
$key = $stream->getSelection().'-'.$stream->getLanguage();
|
||||||
|
|
||||||
|
$urls = array();
|
||||||
|
switch($stream->getPlayerType())
|
||||||
|
{
|
||||||
|
case 'video':
|
||||||
|
foreach ($stream->getVideoProtos() as $proto => $display)
|
||||||
|
{
|
||||||
|
$urls[$proto] = array(
|
||||||
|
'display' => $display,
|
||||||
|
'tech' => $stream->getVideoTech($proto),
|
||||||
|
'url' => $stream->getVideoUrl($proto),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'slides':
|
||||||
|
foreach ($stream->getSlidesProtos() as $proto => $display)
|
||||||
|
{
|
||||||
|
$urls[$proto] = array(
|
||||||
|
'display' => $display,
|
||||||
|
'tech' => $stream->getSlidesTech($proto),
|
||||||
|
'url' => $stream->getSlidesUrl($proto),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'audio':
|
||||||
|
foreach ($stream->getAudioProtos() as $proto => $display)
|
||||||
|
{
|
||||||
|
$urls[$proto] = array(
|
||||||
|
'display' => $display,
|
||||||
|
'tech' => $stream->getAudioTech($proto),
|
||||||
|
'url' => $stream->getAudioUrl($proto),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'music':
|
||||||
|
foreach ($stream->getMusicProtos() as $proto => $display)
|
||||||
|
{
|
||||||
|
$urls[$proto] = array(
|
||||||
|
'display' => $display,
|
||||||
|
'tech' => $stream->getMusicTech($proto),
|
||||||
|
'url' => $stream->getMusicUrl($proto),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$streams[] = array(
|
||||||
|
'slug' => $key,
|
||||||
|
'display' => $stream->getDisplay(),
|
||||||
|
'type' => $stream->getPlayerType(),
|
||||||
|
'isTranslated' => $stream->isTranslated(),
|
||||||
|
'videoSize' => $stream->getVideoSize(),
|
||||||
|
'urls' => $urls,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$roomstruct[] = array(
|
||||||
|
'slug' => $room->getSlug(),
|
||||||
|
'schedulename' => $room->getScheduleName(),
|
||||||
|
'thumb' => forceslash(baseurl()).$room->getThumb(),
|
||||||
|
'link' => forceslash(baseurl()).$room->getLink(),
|
||||||
|
'display' => $room->getDisplay(),
|
||||||
|
'streams' => $streams,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$groupstruct[] = array(
|
||||||
|
'group' => $group,
|
||||||
|
'rooms' => $roomstruct,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$struct[] = array(
|
||||||
|
'conference' => $conference->getTitle(),
|
||||||
|
'slug' => $conference->getSlug(),
|
||||||
|
'author' => $conference->getAuthor(),
|
||||||
|
'description' => $conference->getDescription(),
|
||||||
|
'keywords' => $conference->getKeywords(),
|
||||||
|
'startsAt' => $conference->startsAt() ? $conference->startsAt()->format(DateTime::ISO8601) : null,
|
||||||
|
'endsAt' => $conference->endsAt() ? $conference->endsAt()->format(DateTime::ISO8601) : null,
|
||||||
|
'groups' => $groupstruct,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($struct, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
Loading…
Reference in a new issue