2016-11-05 20:24:04 +03:00
|
|
|
<?php
|
2017-02-11 18:16:56 +03:00
|
|
|
class Arte7Bridge extends BridgeAbstract {
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
const MAINTAINER = 'mitsukarenai';
|
|
|
|
const NAME = 'Arte +7';
|
2017-10-12 20:12:31 +03:00
|
|
|
const URI = 'https://www.arte.tv/';
|
2017-02-11 18:16:56 +03:00
|
|
|
const CACHE_TIMEOUT = 1800; // 30min
|
|
|
|
const DESCRIPTION = 'Returns newest videos from ARTE +7';
|
2017-10-12 20:12:31 +03:00
|
|
|
|
|
|
|
const API_TOKEN = 'Nzc1Yjc1ZjJkYjk1NWFhN2I2MWEwMmRlMzAzNjI5NmU3NWU3ODg4ODJjOWMxNTMxYzEzZGRjYjg2ZGE4MmIwOA';
|
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
const PARAMETERS = array(
|
|
|
|
'Catégorie (Français)' => array(
|
|
|
|
'catfr' => array(
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Catégorie',
|
|
|
|
'values' => array(
|
2017-10-12 20:12:31 +03:00
|
|
|
'Toutes les vidéos (français)' => null,
|
|
|
|
'Actu & société' => 'ACT',
|
|
|
|
'Séries & fiction' => 'SER',
|
|
|
|
'Cinéma' => 'CIN',
|
|
|
|
'Arts & spectacles classiques' => 'ARS',
|
|
|
|
'Culture pop' => 'CPO',
|
|
|
|
'Découverte' => 'DEC',
|
|
|
|
'Histoire' => 'HIST',
|
|
|
|
'Science' => 'SCI',
|
|
|
|
'Autre' => 'AUT'
|
2017-02-11 18:16:56 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'Catégorie (Allemand)' => array(
|
|
|
|
'catde' => array(
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Catégorie',
|
|
|
|
'values' => array(
|
2017-10-12 20:12:31 +03:00
|
|
|
'Alle Videos (deutsch)' => null,
|
|
|
|
'Aktuelles & Gesellschaft' => 'ACT',
|
|
|
|
'Fernsehfilme & Serien' => 'SER',
|
|
|
|
'Kino' => 'CIN',
|
|
|
|
'Kunst & Kultur' => 'ARS',
|
|
|
|
'Popkultur & Alternativ' => 'CPO',
|
|
|
|
'Entdeckung' => 'DEC',
|
|
|
|
'Geschichte' => 'HIST',
|
|
|
|
'Wissenschaft' => 'SCI',
|
|
|
|
'Sonstiges' => 'AUT'
|
2017-02-11 18:16:56 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2015-11-03 17:36:19 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
public function collectData(){
|
2017-07-29 20:28:00 +03:00
|
|
|
switch($this->queriedContext) {
|
2017-02-11 18:16:56 +03:00
|
|
|
case 'Catégorie (Français)':
|
|
|
|
$category = $this->getInput('catfr');
|
|
|
|
$lang = 'fr';
|
|
|
|
break;
|
|
|
|
case 'Catégorie (Allemand)':
|
|
|
|
$category = $this->getInput('catde');
|
|
|
|
$lang = 'de';
|
|
|
|
break;
|
|
|
|
}
|
2015-11-03 17:36:19 +03:00
|
|
|
|
2018-03-06 14:26:16 +03:00
|
|
|
$url = 'https://api.arte.tv/api/opa/v3/videos?sort=-lastModified&limit=10&language='
|
2017-10-12 20:12:31 +03:00
|
|
|
. $lang
|
|
|
|
. ($category != null ? '&category.code=' . $category : '');
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2017-10-12 20:12:31 +03:00
|
|
|
$context = array(
|
|
|
|
'http' => array(
|
|
|
|
'header' => 'Authorization: Bearer '. self::API_TOKEN
|
|
|
|
)
|
|
|
|
);
|
2016-08-28 12:50:01 +03:00
|
|
|
|
2017-10-12 20:12:31 +03:00
|
|
|
$input = getContents($url, false, stream_context_create($context)) or die('Could not request ARTE.');
|
|
|
|
$input_json = json_decode($input, true);
|
2016-11-05 14:48:58 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
foreach($input_json['videos'] as $element) {
|
2017-10-12 20:12:31 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
$item = array();
|
2017-10-12 20:12:31 +03:00
|
|
|
$item['uri'] = $element['url'];
|
2017-02-11 18:16:56 +03:00
|
|
|
$item['id'] = $element['id'];
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2017-10-12 20:12:31 +03:00
|
|
|
$item['timestamp'] = strtotime($element['videoRightsBegin']);
|
2017-02-11 18:16:56 +03:00
|
|
|
$item['title'] = $element['title'];
|
|
|
|
|
|
|
|
if(!empty($element['subtitle']))
|
|
|
|
$item['title'] = $element['title'] . ' | ' . $element['subtitle'];
|
|
|
|
|
2017-10-12 20:12:31 +03:00
|
|
|
$item['duration'] = round((int)$element['durationSeconds'] / 60);
|
|
|
|
$item['content'] = $element['teaserText']
|
2017-02-11 18:16:56 +03:00
|
|
|
. '<br><br>'
|
|
|
|
. $item['duration']
|
|
|
|
. 'min<br><a href="'
|
|
|
|
. $item['uri']
|
|
|
|
. '"><img src="'
|
2017-10-12 20:12:31 +03:00
|
|
|
. $element['mainImage']['url']
|
2017-02-11 18:16:56 +03:00
|
|
|
. '" /></a>';
|
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2014-05-26 02:30:46 +04:00
|
|
|
|
|
|
|
}
|