Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions bridges/PlaySrfBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

class PlaySrfBridge extends BridgeAbstract
{
const NAME = 'Play SRF';
const NAME = 'Play SRF / RTS / RSI / RTR';
const URI = 'https://www.srf.ch/play/tv';
const DESCRIPTION = 'Feed of any show in the Play SRF portal, specified by its ID';
const DESCRIPTION = 'Feed of any show in the Play SRF / RTS / RSI / RTR portals, specified by its ID';
const MAINTAINER = 'giodi';
const PARAMETERS = [
[
'showId' => [
'name' => 'Show Link or ID',
'name' => 'URL of Show Page',
'required' => true,
'title' => 'Insert the URL to the page of a show.',
'exampleValue' => 'https://www.srf.ch/play/tv/sendung/arena?id=09784065-687b-4b60-bd23-9ed0d2d43cdc'
Expand All @@ -35,14 +35,15 @@ class PlaySrfBridge extends BridgeAbstract

public function collectData(): void
{
preg_match('/[a-z0-9]{8}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{12}$/s', $this->getInput('showId'), $matches);
$url = $matches[0];
preg_match('/[a-z0-9]{8}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{4}\-[a-z0-9]{12}$|[0-9]{5,10}$/s', $this->getInput('showId'), $matchShowId);
preg_match('/(?<=https:\/{2}w{3}\.)[first]{3}/', $this->getInput('showId'), $matchRegion);
$showId = $matchShowId[0];
$region = $matchRegion[0];
$embed = $this->getInput('embed');
$limit = $this->getInput('limit');

$raw = getContents('https://www.srf.ch/play/v3/api/srf/production/videos-by-show-id?showId=' . $url);
$raw = getContents('https://www.' . $region . '.ch/play/v3/api/' . $region . '/production/videos-by-show-id?showId=' . $showId);
$jsonShowVideos = json_decode($raw, true);

$this->title = $jsonShowVideos['data']['data'][0]['show']['title'] ?? 'Play SRF';
$episodes = $jsonShowVideos['data']['data'];

Expand All @@ -56,7 +57,7 @@ public function collectData(): void
if ($embed === true) {
$content .= '<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%;">';
$content .= '<iframe style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" width="560" height="315" ';
$content .= 'src="https://www.srf.ch/play/embed?urn=' . $ep['urn'] . '&subdivisions=false" allowfullscreen ';
$content .= 'src="https://www.' . $region . '.ch/play/embed?urn=' . $ep['urn'] . '&subdivisions=false" allowfullscreen ';
$content .= 'allow="geolocation *; autoplay; encrypted-media"></iframe></div>';
}

Expand All @@ -82,4 +83,4 @@ public function getName()
}
return parent::getName();
}
}
}
Loading