Rss-Bridge/bridges/Arte7Bridge.php
Pierre Mazière 1b3c8a8aeb [core + bridges] add BridgeAbstract::$inputs and BridgeAbstract::getInput()
Inputs are not stored in BridgeAbstract::$parameters anymore to separate
static data from dynamic data.
The getInput method allows for more readable code.

Also fix an "undefined index 'global'" notice

Probability of breaking bridges: high !

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2016-08-28 13:05:03 +02:00

91 lines
3.8 KiB
PHP

<?php
class Arte7Bridge extends BridgeAbstract{
public $maintainer = "mitsukarenai";
public $name = "Arte +7";
public $uri = "http://www.arte.tv/";
public $description = "Returns newest videos from ARTE +7";
public $parameters = array(
'Catégorie (Français)' => array(
'catfr'=>array(
'type'=>'list',
'name'=>'Catégorie',
'values'=>array(
'Toutes les vidéos (français)'=>'toutes-les-videos',
'Actu & société'=>'actu-société',
'Séries & fiction'=>'séries-fiction',
'Cinéma'=>'cinéma',
'Arts & spectacles classiques'=>'arts-spectacles-classiques',
'Culture pop'=>'culture-pop',
'Découverte'=>'découverte',
'Histoire'=>'histoire',
'Junior'=>'junior'
)
)
),
'Catégorie (Allemand)' => array(
'catde'=>array(
'type'=>'list',
'name'=>'Catégorie',
'values'=>array(
'Alle Videos (deutsch)'=>'alle-videos',
'Aktuelles & Gesellschaft'=>'aktuelles-gesellschaft',
'Fernsehfilme & Serien'=>'fernsehfilme-serien',
'Kino'=>'kino',
'Kunst & Kultur'=>'kunst-kultur',
'Popkultur & Alternativ'=>'popkultur-alternativ',
'Entdeckung'=>'entdeckung',
'Geschichte'=>'geschichte',
'Junior'=>'junior'
)
)
)
);
protected function extractVideoset($category='toutes-les-videos', $lang='fr'){
$url = 'http://www.arte.tv/guide/'.$lang.'/plus7/'.$category;
$input = $this->getContents($url) or die('Could not request ARTE.');
if(strpos($input, 'categoryVideoSet') !== FALSE){
$input = explode('categoryVideoSet: ', $input);
$input = explode('}},', $input[1]);
$input = $input[0].'}}';
}else{
$input = explode('videoSet: ', $input);
$input = explode('}]},', $input[1]);
$input = $input[0].'}]}';
}
$input = json_decode($input, TRUE);
return $input;
}
public function collectData(){
$category='toutes-les-videos'; $lang='fr';
if (!empty($this->getInput('catfr')))
$category=$this->getInput('catfr');
if (!empty($this->getInput('catde')))
{ $category=$this->getInput('catde'); $lang='de'; }
$input_json = $this->extractVideoset($category, $lang);
foreach($input_json['videos'] as $element) {
$item = array();
$item['uri'] = str_replace("autoplay=1", "", $element['url']);
$item['id'] = $element['id'];
$hack_broadcast_time = $element['rights_end'];
$hack_broadcast_time = strtok($hack_broadcast_time, 'T');
$hack_broadcast_time = strtok('T');
$item['timestamp'] = strtotime($element['scheduled_on'].'T'.$hack_broadcast_time);
$item['title'] = $element['title'];
if (!empty($element['subtitle']))
$item['title'] = $element['title'].' | '.$element['subtitle'];
$item['duration'] = round((int)$element['duration']/60);
$item['content'] = $element['teaser'].'<br><br>'.$item['duration'].'min<br><a href="'.$item['uri'].'"><img src="' . $element['thumbnail_url'] . '" /></a>';
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
}
}