[Arte7Bridge] Fix Arte7 bridge, use the API

This commit is contained in:
teromene 2017-10-12 18:12:31 +01:00
parent 8d418611a2
commit cba65d6d08

View file

@ -3,24 +3,28 @@ class Arte7Bridge extends BridgeAbstract {
const MAINTAINER = 'mitsukarenai'; const MAINTAINER = 'mitsukarenai';
const NAME = 'Arte +7'; const NAME = 'Arte +7';
const URI = 'http://www.arte.tv/'; const URI = 'https://www.arte.tv/';
const CACHE_TIMEOUT = 1800; // 30min const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = 'Returns newest videos from ARTE +7'; const DESCRIPTION = 'Returns newest videos from ARTE +7';
const API_TOKEN = 'Nzc1Yjc1ZjJkYjk1NWFhN2I2MWEwMmRlMzAzNjI5NmU3NWU3ODg4ODJjOWMxNTMxYzEzZGRjYjg2ZGE4MmIwOA';
const PARAMETERS = array( const PARAMETERS = array(
'Catégorie (Français)' => array( 'Catégorie (Français)' => array(
'catfr' => array( 'catfr' => array(
'type' => 'list', 'type' => 'list',
'name' => 'Catégorie', 'name' => 'Catégorie',
'values' => array( 'values' => array(
'Toutes les vidéos (français)' => 'toutes-les-videos', 'Toutes les vidéos (français)' => null,
'Actu & société' => 'actu-société', 'Actu & société' => 'ACT',
'Séries & fiction' => 'séries-fiction', 'Séries & fiction' => 'SER',
'Cinéma' => 'cinéma', 'Cinéma' => 'CIN',
'Arts & spectacles classiques' => 'arts-spectacles-classiques', 'Arts & spectacles classiques' => 'ARS',
'Culture pop' => 'culture-pop', 'Culture pop' => 'CPO',
'Découverte' => 'découverte', 'Découverte' => 'DEC',
'Histoire' => 'histoire', 'Histoire' => 'HIST',
'Junior' => 'junior' 'Science' => 'SCI',
'Autre' => 'AUT'
) )
) )
), ),
@ -29,15 +33,16 @@ class Arte7Bridge extends BridgeAbstract {
'type' => 'list', 'type' => 'list',
'name' => 'Catégorie', 'name' => 'Catégorie',
'values' => array( 'values' => array(
'Alle Videos (deutsch)' => 'alle-videos', 'Alle Videos (deutsch)' => null,
'Aktuelles & Gesellschaft' => 'aktuelles-gesellschaft', 'Aktuelles & Gesellschaft' => 'ACT',
'Fernsehfilme & Serien' => 'fernsehfilme-serien', 'Fernsehfilme & Serien' => 'SER',
'Kino' => 'kino', 'Kino' => 'CIN',
'Kunst & Kultur' => 'kunst-kultur', 'Kunst & Kultur' => 'ARS',
'Popkultur & Alternativ' => 'popkultur-alternativ', 'Popkultur & Alternativ' => 'CPO',
'Entdeckung' => 'entdeckung', 'Entdeckung' => 'DEC',
'Geschichte' => 'geschichte', 'Geschichte' => 'HIST',
'Junior' => 'junior' 'Wissenschaft' => 'SCI',
'Sonstiges' => 'AUT'
) )
) )
) )
@ -55,44 +60,39 @@ class Arte7Bridge extends BridgeAbstract {
break; break;
} }
$url = self::URI . 'guide/' . $lang . '/plus7/' . $category; $url = 'https://api.arte.tv/api/opa/v3/videos?sort=broadcastBegin&limit=10&language='
$input = getContents($url) or die('Could not request ARTE.'); . $lang
. ($category != null ? '&category.code=' . $category : '');
if(strpos($input, 'categoryVideoSet') !== false) { $context = array(
$input = explode('categoryVideoSet="', $input); 'http' => array(
$input = explode('}}', $input[1]); 'header' => 'Authorization: Bearer '. self::API_TOKEN
$input = $input[0] . '}}'; )
} else { );
$input = explode('videoSet="', $input);
$input = explode('}]}', $input[1]);
$input = $input[0] . '}]}';
}
$input_json = json_decode(html_entity_decode($input, ENT_QUOTES), true); $input = getContents($url, false, stream_context_create($context)) or die('Could not request ARTE.');
$input_json = json_decode($input, true);
foreach($input_json['videos'] as $element) { foreach($input_json['videos'] as $element) {
$item = array(); $item = array();
$item['uri'] = str_replace("autoplay=1", "", $element['url']); $item['uri'] = $element['url'];
$item['id'] = $element['id']; $item['id'] = $element['id'];
$hack_broadcast_time = $element['rights_end']; $item['timestamp'] = strtotime($element['videoRightsBegin']);
$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']; $item['title'] = $element['title'];
if(!empty($element['subtitle'])) if(!empty($element['subtitle']))
$item['title'] = $element['title'] . ' | ' . $element['subtitle']; $item['title'] = $element['title'] . ' | ' . $element['subtitle'];
$item['duration'] = round((int)$element['duration'] / 60); $item['duration'] = round((int)$element['durationSeconds'] / 60);
$item['content'] = $element['teaser'] $item['content'] = $element['teaserText']
. '<br><br>' . '<br><br>'
. $item['duration'] . $item['duration']
. 'min<br><a href="' . 'min<br><a href="'
. $item['uri'] . $item['uri']
. '"><img src="' . '"><img src="'
. $element['thumbnail_url'] . $element['mainImage']['url']
. '" /></a>'; . '" /></a>';
$this->items[] = $item; $this->items[] = $item;