diff options
Diffstat (limited to 'lib/bbcnext.php')
| -rw-r--r-- | lib/bbcnext.php | 183 |
1 files changed, 95 insertions, 88 deletions
diff --git a/lib/bbcnext.php b/lib/bbcnext.php index 988d248..ed58a4f 100644 --- a/lib/bbcnext.php +++ b/lib/bbcnext.php @@ -1,109 +1,116 @@ <?php require_once __DIR__ . '/rms.php'; +require_once __DIR__ . '/mediaselector.php'; function next_renderFromRms(string $path) { - next_renderExperience(rms_fetch($path)->data); + next_renderExperience(rms_fetch($path)->data); } function next_renderExperience(array $modules) { - foreach ($modules as $m) { - next_renderModule($m); - } + foreach ($modules as $m) { + next_renderModule($m); + } } function next_renderModule(stdClass $module) { - $type = strtr($module->type, '_', '-'); - $titleTag = $type == 'inline-header-module' ? 'h1' : 'h2'; - echo "<$type id=\"$module->id\" module-style=\"$module->style\">"; - echo "<$titleTag>" - . htmlspecialchars($module->title ?? '[no title]') - . "</$titleTag>"; - if (isset($module->description)) { - echo '<module-description>' - . htmlspecialchars($module->description) - . '</module-description>'; - } - echo '<module-items>'; - if (!is_array($module->data)) { - next_renderItem($module->data); - } else { - foreach ($module->data as $item) { - next_renderItem($item); - } - } - echo "</module-items></$type>"; + $type = strtr($module->type, '_', '-'); + $titleTag = $type == 'inline-header-module' ? 'h1' : 'h2'; + echo "<$type id=\"$module->id\" module-style=\"$module->style\">"; + echo "<$titleTag>" + . htmlspecialchars($module->title ?? '[no title]') + . "</$titleTag>"; + if (isset($module->description)) { + echo '<module-description>' + . htmlspecialchars($module->description) + . '</module-description>'; + } + echo '<module-items>'; + if (!is_array($module->data)) { + next_renderItem($module->data); + } else { + foreach ($module->data as $item) { + next_renderItem($item); + } + } + echo "</module-items>"; + if ($module->id == 'aod_play_area') { + $url = mediaselector_findHls($module->data[0]->id); + echo '<audio controls hidden id="hls-player" data-hls="' . $url . '" />'; + echo '<script src="static/hls-player.js" defer></script>'; + } + echo "</$type>"; } function next_renderItem(stdClass $item) { - $type = strtr($item->type, '_', '-'); - $primaryTag = $type == 'segment-item' ? 'primary-title' : 'h3'; - echo "<$type id=\"$item->id\">"; - echo '<item-titles><item-first-titles>'; - echo "<$primaryTag>" - . htmlspecialchars($item->titles?->primary ?? '[no primary]') - . "</$primaryTag>"; - if (isset($item->network)) { - echo '<item-network>' - . htmlspecialchars($item->network->short_title) - . '</item-network>'; - } - echo '</item-first-titles>'; - if (isset($item->titles->secondary)) { - echo '<secondary-title>' - . htmlspecialchars($item->titles->secondary) - . '</secondary-title>'; - } - if (isset($item->titles->tertiary)) { - echo '<tertiary-title>' - . htmlspecialchars($item->titles->tertiary) - . '</tertiary-title>'; - } - echo '</item-titles>'; - if (isset($item->synopses?->short, $item->synopses?->medium)) { - echo '<synopsis><details><summary>' - . htmlspecialchars($item->synopses->short) - . '</summary>' - . htmlspecialchars($item->synopses->long ?? $item->synopses->medium) - . '</details></synopsis>'; - } elseif (isset($item->synopses?->short)) { - echo '<synopsis>' . htmlspecialchars($item->synopses->short) - . '</synopsis>'; - } + $type = strtr($item->type, '_', '-'); + $primaryTag = $type == 'segment-item' ? 'primary-title' : 'h3'; + echo "<$type id=\"$item->id\">"; + echo '<item-titles><item-first-titles>'; + echo "<$primaryTag>" + . htmlspecialchars($item->titles?->primary ?? '[no primary]') + . "</$primaryTag>"; + if (isset($item->network)) { + echo '<item-network>' + . htmlspecialchars($item->network->short_title) + . '</item-network>'; + } + echo '</item-first-titles>'; + if (isset($item->titles->secondary)) { + echo '<secondary-title>' + . htmlspecialchars($item->titles->secondary) + . '</secondary-title>'; + } + if (isset($item->titles->tertiary)) { + echo '<tertiary-title>' + . htmlspecialchars($item->titles->tertiary) + . '</tertiary-title>'; + } + echo '</item-titles>'; + if (isset($item->synopses?->short, $item->synopses?->medium)) { + echo '<synopsis><details><summary>' + . htmlspecialchars($item->synopses->short) + . '</summary>' + . htmlspecialchars($item->synopses->long ?? $item->synopses->medium) + . '</details></synopsis>'; + } elseif (isset($item->synopses?->short)) { + echo '<synopsis>' . htmlspecialchars($item->synopses->short) + . '</synopsis>'; + } - if (isset($item->item)) { - next_renderItem($item->item); - } + if (isset($item->item)) { + next_renderItem($item->item); + } - if (isset($item->offset)) { - echo '<offset-start>' - . gmdate('H:i:s', $item->offset->start) - . '</offset-start>'; - echo '<offset-end>' - . gmdate('H:i:s', $item->offset->end) - . '</offset-end>'; - } + if (isset($item->offset)) { + echo '<offset-start>' + . gmdate('H:i:s', $item->offset->start) + . '</offset-start>'; + echo '<offset-end>' + . gmdate('H:i:s', $item->offset->end) + . '</offset-end>'; + } - if ($type == 'container-item') { - $href = '?path=' . RMS_SOUNDS_CONTAINER . '/' . $item->urn; - echo "<a href=\"$href\">View</a>"; - } elseif ($type == 'playable-item') { - $pid = explode(':', $item->urn)[4]; - $href = '?path=' . RMS_SOUNDS_PLAYABLE . '/' . $pid; - echo "<a href=\"$href\">Listen</a>"; - } + if ($type == 'container-item') { + $href = '?path=' . RMS_SOUNDS_CONTAINER . '/' . $item->urn; + echo "<a href=\"$href\">View</a>"; + } elseif ($type == 'playable-item') { + $pid = explode(':', $item->urn)[4]; + $href = '?path=' . RMS_SOUNDS_PLAYABLE . '/' . $pid; + echo "<a href=\"$href\">Listen</a>"; + } - foreach ($item->uris ?? [] as $uri) { - if ($uri->type != 'link') continue; - echo '<a href="' . htmlspecialchars($uri->uri) . '" target="_blank">' - . htmlspecialchars($uri->label) . '</a>'; - } + foreach ($item->uris ?? [] as $uri) { + if ($uri->type != 'link') continue; + echo '<a href="' . htmlspecialchars($uri->uri) . '" target="_blank">' + . htmlspecialchars($uri->label) . '</a>'; + } - if (isset($item->download) && $item->download->type == 'non_drm') { - $variant = $item->download->quality_variants->high; - echo '<a href="' . htmlspecialchars($variant->file_url) . '">' - . "Download ($variant->label)</a>"; - } + if (isset($item->download) && $item->download->type == 'non_drm') { + $variant = $item->download->quality_variants->high; + echo '<a href="' . htmlspecialchars($variant->file_url) . '">' + . "Download ($variant->label)</a>"; + } - echo "</$type>"; + echo "</$type>"; } |
