2016-11-05 18:24:04 +01:00
|
|
|
<?php
|
2017-02-11 16:16:56 +01:00
|
|
|
class Arte7Bridge extends BridgeAbstract {
|
2014-05-26 00:30:46 +02:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
const MAINTAINER = 'mitsukarenai';
|
|
|
|
const NAME = 'Arte +7';
|
2017-10-12 19:12:31 +02:00
|
|
|
const URI = 'https://www.arte.tv/';
|
2017-02-11 16:16:56 +01:00
|
|
|
const CACHE_TIMEOUT = 1800; // 30min
|
|
|
|
const DESCRIPTION = 'Returns newest videos from ARTE +7';
|
2017-10-12 19:12:31 +02:00
|
|
|
|
|
|
|
const API_TOKEN = 'Nzc1Yjc1ZjJkYjk1NWFhN2I2MWEwMmRlMzAzNjI5NmU3NWU3ODg4ODJjOWMxNTMxYzEzZGRjYjg2ZGE4MmIwOA';
|
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
const PARAMETERS = array(
|
|
|
|
'Catégorie (Français)' => array(
|
|
|
|
'catfr' => array(
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Catégorie',
|
|
|
|
'values' => array(
|
2017-10-12 19:12:31 +02: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 16:16:56 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'Catégorie (Allemand)' => array(
|
|
|
|
'catde' => array(
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Catégorie',
|
|
|
|
'values' => array(
|
2017-10-12 19:12:31 +02: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 16:16:56 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2015-11-03 15:36:19 +01:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
public function collectData(){
|
2017-07-29 19:28:00 +02:00
|
|
|
switch($this->queriedContext) {
|
2017-02-11 16:16:56 +01: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 15:36:19 +01:00
|
|
|
|
2018-03-06 12:26:16 +01:00
|
|
|
$url = 'https://api.arte.tv/api/opa/v3/videos?sort=-lastModified&limit=10&language='
|
2017-10-12 19:12:31 +02:00
|
|
|
. $lang
|
|
|
|
. ($category != null ? '&category.code=' . $category : '');
|
2014-05-26 00:30:46 +02:00
|
|
|
|
2018-03-25 14:01:35 +02:00
|
|
|
$header = array(
|
|
|
|
'Authorization: Bearer ' . self::API_TOKEN
|
2017-10-12 19:12:31 +02:00
|
|
|
);
|
2016-08-28 11:50:01 +02:00
|
|
|
|
2018-03-25 14:01:35 +02:00
|
|
|
$input = getContents($url, $header) or die('Could not request ARTE.');
|
2017-10-12 19:12:31 +02:00
|
|
|
$input_json = json_decode($input, true);
|
2016-11-05 12:48:58 +01:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
foreach($input_json['videos'] as $element) {
|
2017-10-12 19:12:31 +02:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
$item = array();
|
2017-10-12 19:12:31 +02:00
|
|
|
$item['uri'] = $element['url'];
|
2017-02-11 16:16:56 +01:00
|
|
|
$item['id'] = $element['id'];
|
2014-05-26 00:30:46 +02:00
|
|
|
|
2017-10-12 19:12:31 +02:00
|
|
|
$item['timestamp'] = strtotime($element['videoRightsBegin']);
|
2017-02-11 16:16:56 +01:00
|
|
|
$item['title'] = $element['title'];
|
|
|
|
|
|
|
|
if(!empty($element['subtitle']))
|
|
|
|
$item['title'] = $element['title'] . ' | ' . $element['subtitle'];
|
|
|
|
|
2017-10-12 19:12:31 +02:00
|
|
|
$item['duration'] = round((int)$element['durationSeconds'] / 60);
|
|
|
|
$item['content'] = $element['teaserText']
|
2017-02-11 16:16:56 +01:00
|
|
|
. '<br><br>'
|
|
|
|
. $item['duration']
|
|
|
|
. 'min<br><a href="'
|
|
|
|
. $item['uri']
|
|
|
|
. '"><img src="'
|
2017-10-12 19:12:31 +02:00
|
|
|
. $element['mainImage']['url']
|
2017-02-11 16:16:56 +01:00
|
|
|
. '" /></a>';
|
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2014-05-26 00:30:46 +02:00
|
|
|
|
|
|
|
}
|