2016-11-05 20:24:04 +03:00
|
|
|
<?php
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
class Arte7Bridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2017-02-11 18:16:56 +03:00
|
|
|
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 = [
|
2022-03-26 02:03:38 +03:00
|
|
|
'global' => [
|
2022-04-17 00:08:27 +03:00
|
|
|
'sort_by' => [
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Sort by',
|
|
|
|
'required' => false,
|
|
|
|
'defaultValue' => null,
|
|
|
|
'values' => [
|
|
|
|
'Default' => null,
|
|
|
|
'Video rights start date' => 'videoRightsBegin',
|
|
|
|
'Video rights end date' => 'videoRightsEnd',
|
|
|
|
'Brodcast date' => 'broadcastBegin',
|
|
|
|
'Creation date' => 'creationDate',
|
|
|
|
'Last modified' => 'lastModified',
|
|
|
|
'Number of views' => 'views',
|
|
|
|
'Number of views per period' => 'viewsPeriod',
|
|
|
|
'Available screens' => 'availableScreens',
|
|
|
|
'Episode' => 'episode'
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'sort_direction' => [
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Sort direction',
|
|
|
|
'required' => false,
|
|
|
|
'defaultValue' => 'DESC',
|
|
|
|
'values' => [
|
|
|
|
'Ascending' => 'ASC',
|
|
|
|
'Descending' => 'DESC'
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'exclude_trailers' => [
|
|
|
|
'name' => 'Exclude trailers',
|
2022-03-26 02:03:38 +03:00
|
|
|
'type' => 'checkbox',
|
2022-04-17 00:08:27 +03:00
|
|
|
'required' => false,
|
|
|
|
'defaultValue' => false
|
2022-03-26 02:03:38 +03:00
|
|
|
],
|
|
|
|
],
|
2022-03-31 12:17:07 +03:00
|
|
|
'Category' => [
|
|
|
|
'lang' => [
|
2017-02-11 18:16:56 +03:00
|
|
|
'type' => 'list',
|
2022-03-31 12:17:07 +03:00
|
|
|
'name' => 'Language',
|
2017-02-11 18:16:56 +03:00
|
|
|
'values' => [
|
2022-03-31 12:17:07 +03:00
|
|
|
'Français' => 'fr',
|
|
|
|
'Deutsch' => 'de',
|
|
|
|
'English' => 'en',
|
|
|
|
'Español' => 'es',
|
|
|
|
'Polski' => 'pl',
|
|
|
|
'Italiano' => 'it'
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'cat' => [
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Category',
|
|
|
|
'values' => [
|
|
|
|
'All videos' => null,
|
|
|
|
'News & society' => 'ACT',
|
|
|
|
'Series & fiction' => 'SER',
|
|
|
|
'Cinema' => 'CIN',
|
|
|
|
'Culture' => 'ARS',
|
2017-10-12 20:12:31 +03:00
|
|
|
'Culture pop' => 'CPO',
|
2022-03-31 12:17:07 +03:00
|
|
|
'Discovery' => 'DEC',
|
|
|
|
'History' => 'HIST',
|
2017-10-12 20:12:31 +03:00
|
|
|
'Science' => 'SCI',
|
2022-03-31 12:17:07 +03:00
|
|
|
'Other' => 'AUT'
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
2022-03-31 12:17:07 +03:00
|
|
|
],
|
2017-02-11 18:16:56 +03:00
|
|
|
],
|
2022-03-31 12:17:07 +03:00
|
|
|
'Collection' => [
|
|
|
|
'lang' => [
|
2017-02-11 18:16:56 +03:00
|
|
|
'type' => 'list',
|
2022-03-31 12:17:07 +03:00
|
|
|
'name' => 'Language',
|
2017-02-11 18:16:56 +03:00
|
|
|
'values' => [
|
2022-03-31 12:17:07 +03:00
|
|
|
'Français' => 'fr',
|
|
|
|
'Deutsch' => 'de',
|
|
|
|
'English' => 'en',
|
|
|
|
'Español' => 'es',
|
|
|
|
'Polski' => 'pl',
|
|
|
|
'Italiano' => 'it'
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
2022-03-31 12:17:07 +03:00
|
|
|
],
|
|
|
|
'col' => [
|
2018-09-15 17:49:11 +03:00
|
|
|
'name' => 'Collection id',
|
|
|
|
'required' => true,
|
2022-03-24 13:59:34 +03:00
|
|
|
'title' => 'ex. RC-014095 pour https://www.arte.tv/de/videos/RC-014095/blow-up/',
|
|
|
|
'exampleValue' => 'RC-014095'
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]
|
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) {
|
2022-03-31 12:17:07 +03:00
|
|
|
case 'Category':
|
|
|
|
$category = $this->getInput('cat');
|
|
|
|
$collectionId = null;
|
2017-02-11 18:16:56 +03:00
|
|
|
break;
|
2022-03-31 12:17:07 +03:00
|
|
|
case 'Collection':
|
|
|
|
$collectionId = $this->getInput('col');
|
|
|
|
$category = null;
|
2018-09-12 00:09:47 +03:00
|
|
|
break;
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2015-11-03 17:36:19 +03:00
|
|
|
|
2022-04-17 00:08:27 +03:00
|
|
|
$lang = $this->getInput('lang');
|
|
|
|
$sort_by = $this->getInput('sort_by');
|
|
|
|
$sort_direction = $this->getInput('sort_direction') == 'ASC' ? '' : '-';
|
|
|
|
|
|
|
|
$url = 'https://api.arte.tv/api/opa/v3/videos?limit=15&language='
|
2017-10-12 20:12:31 +03:00
|
|
|
. $lang
|
2022-04-17 00:08:27 +03:00
|
|
|
. ($sort_by != null ? '&sort=' . $sort_direction . $sort_by : '')
|
2018-09-12 00:09:47 +03:00
|
|
|
. ($category != null ? '&category.code=' . $category : '')
|
|
|
|
. ($collectionId != null ? '&collections.collectionId=' . $collectionId : '');
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2018-03-25 15:01:35 +03:00
|
|
|
$header = [
|
|
|
|
'Authorization: Bearer ' . self::API_TOKEN
|
2017-10-12 20:12:31 +03:00
|
|
|
];
|
2016-08-28 12:50:01 +03:00
|
|
|
|
2022-01-02 12:36:09 +03:00
|
|
|
$input = getContents($url, $header);
|
2017-10-12 20:12:31 +03:00
|
|
|
$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) {
|
2022-04-17 00:08:27 +03:00
|
|
|
if ($this->getInput('exclude_trailers') && $element['platform'] == 'EXTRAIT') {
|
2022-03-26 02:03:38 +03:00
|
|
|
continue;
|
|
|
|
}
|
2017-10-12 20:12:31 +03:00
|
|
|
|
2022-04-17 00:08:27 +03:00
|
|
|
$durationSeconds = $element['durationSeconds'];
|
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
$item = [];
|
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'];
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2022-03-26 02:03:38 +03:00
|
|
|
$durationMinutes = round((int)$durationSeconds / 60);
|
2017-10-12 20:12:31 +03:00
|
|
|
$item['content'] = $element['teaserText']
|
2017-02-11 18:16:56 +03:00
|
|
|
. '<br><br>'
|
2022-03-26 02:03:38 +03:00
|
|
|
. $durationMinutes
|
2017-02-11 18:16:56 +03:00
|
|
|
. '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
|
|
|
}
|