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
|
|
|
|
2021-01-22 07:52:04 +03:00
|
|
|
// const MAINTAINER = 'mitsukarenai';
|
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 = array(
|
2022-03-26 02:03:38 +03:00
|
|
|
'global' => [
|
|
|
|
'video_duration_filter' => [
|
|
|
|
'name' => 'Exclude short videos',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'title' => 'Exclude videos that are shorter than 3 minutes',
|
2022-03-26 02:07:34 +03:00
|
|
|
'defaultValue' => false,
|
2022-03-26 02:03:38 +03:00
|
|
|
],
|
|
|
|
],
|
2022-03-31 12:17:07 +03:00
|
|
|
'Category' => array(
|
|
|
|
'lang' => array(
|
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' => array(
|
2022-03-31 12:17:07 +03:00
|
|
|
'Français' => 'fr',
|
|
|
|
'Deutsch' => 'de',
|
|
|
|
'English' => 'en',
|
|
|
|
'Español' => 'es',
|
|
|
|
'Polski' => 'pl',
|
|
|
|
'Italiano' => 'it'
|
|
|
|
),
|
|
|
|
'title' => 'ex. RC-014095 pour https://www.arte.tv/fr/videos/RC-014095/blow-up/',
|
|
|
|
'exampleValue' => 'RC-014095'
|
|
|
|
),
|
|
|
|
'cat' => array(
|
|
|
|
'type' => 'list',
|
|
|
|
'name' => 'Category',
|
|
|
|
'values' => array(
|
|
|
|
'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'
|
2017-02-11 18:16:56 +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' => array(
|
|
|
|
'lang' => array(
|
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' => array(
|
2022-03-31 12:17:07 +03:00
|
|
|
'Français' => 'fr',
|
|
|
|
'Deutsch' => 'de',
|
|
|
|
'English' => 'en',
|
|
|
|
'Español' => 'es',
|
|
|
|
'Polski' => 'pl',
|
|
|
|
'Italiano' => 'it'
|
2017-02-11 18:16:56 +03:00
|
|
|
)
|
2022-03-31 12:17:07 +03:00
|
|
|
),
|
|
|
|
'col' => array(
|
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'
|
2018-09-12 00:09:47 +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(){
|
2022-03-31 12:17:07 +03:00
|
|
|
$lang = $this->getInput('lang');
|
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-03-31 12:17:07 +03:00
|
|
|
$url = 'https://api.arte.tv/api/opa/v3/videos?sort=-lastModified&limit=15&language='
|
2017-10-12 20:12:31 +03:00
|
|
|
. $lang
|
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 = array(
|
|
|
|
'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-03-26 02:03:38 +03:00
|
|
|
$durationSeconds = $element['durationSeconds'];
|
|
|
|
|
|
|
|
if ($this->getInput('video_duration_filter') && $durationSeconds < 60 * 3) {
|
|
|
|
continue;
|
|
|
|
}
|
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'];
|
|
|
|
|
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
|
|
|
}
|