mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-26 03:16:33 +03:00
[RtsBridge] Add new bridge for Radio Télévision Suisse (#2442)
This commit is contained in:
parent
7252252e3c
commit
765af484bc
1 changed files with 76 additions and 0 deletions
76
bridges/RtsBridge.php
Normal file
76
bridges/RtsBridge.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
class RtsBridge extends BridgeAbstract {
|
||||
|
||||
const NAME = 'Radio Télévision Suisse';
|
||||
const URI = 'https://www.rts.ch/';
|
||||
const MAINTAINER = 'imagoiq';
|
||||
const DESCRIPTION = 'Returns newest videos from RTS';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'ID de l\'émission' => array(
|
||||
'idShow' => array(
|
||||
'name' => 'Show id',
|
||||
'required' => true,
|
||||
'exampleValue' => 385418,
|
||||
'title' => 'ex. 385418 pour
|
||||
https://www.rts.ch/play/tv/emission/a-bon-entendeur?id=385418'
|
||||
)
|
||||
),
|
||||
'ID de la section' => array(
|
||||
'idSection' => array(
|
||||
'name' => 'Section id',
|
||||
'required' => true,
|
||||
'exampleValue' => 'ce802a54-8877-49cc-acd6-8d244762829b',
|
||||
'title' => 'ex. ce802a54-8877-49cc-acd6-8d244762829b pour
|
||||
https://www.rts.ch/play/tv/detail/humour?id=ce802a54-8877-49cc-acd6-8d244762829b'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData(){
|
||||
switch($this->queriedContext) {
|
||||
case 'ID de l\'émission':
|
||||
$showId = $this->getInput('idShow');
|
||||
|
||||
$url = 'https://www.rts.ch/play/v3/api/rts/production/videos-by-show-id?showId='
|
||||
. $showId;
|
||||
break;
|
||||
case 'ID de la section':
|
||||
$sectionId = $this->getInput('idSection');
|
||||
|
||||
$url = 'https://www.rts.ch/play/v3/api/rts/production/media-section?sectionId='
|
||||
. $sectionId;
|
||||
break;
|
||||
}
|
||||
|
||||
$header = array();
|
||||
$input = getContents($url, $header);
|
||||
$input_json = json_decode($input, true);
|
||||
|
||||
foreach($input_json['data']['data'] as $element) {
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = 'https://www.rts.ch/play/tv/-/video/-?urn=' . $element['urn'];
|
||||
$item['uid'] = $element['id'];
|
||||
|
||||
$item['timestamp'] = strtotime($element['date']);
|
||||
$item['title'] = $element['show']['title'] . ' - ' . $element['title'];
|
||||
|
||||
$item['duration'] = round((int)$element['duration'] / 60000);
|
||||
$durationInHour = date('g\hi', mktime(0, $item['duration']));
|
||||
$durationInMin = date('i\m\i\n', mktime(0, $item['duration']));
|
||||
$durationText = $item['duration'] > 60 ? $durationInHour : $durationInMin;
|
||||
|
||||
$item['content'] = $element['description']
|
||||
. '<br/><br/>'
|
||||
. $durationText
|
||||
. '<br><a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
. $element['imageUrl']
|
||||
. '/scale/width/700" alt=""/></a>';
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue