[Arte7Bridge] Exclude trailers and sort by (#2660)

This commit is contained in:
Loïc Fürhoff 2022-04-14 23:20:09 +02:00 committed by GitHub
parent d082bfca4a
commit 924eaf2011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 42 additions and 12 deletions

View File

@ -1,9 +1,9 @@
<?php <?php
class Arte7Bridge extends BridgeAbstract { class Arte7Bridge extends BridgeAbstract {
// const MAINTAINER = 'mitsukarenai';
const NAME = 'Arte +7'; const NAME = 'Arte +7';
const URI = 'https://www.arte.tv/'; const URI = 'https://www.arte.tv/';
const MAINTAINER = 'imagoiq';
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';
@ -11,11 +11,39 @@ class Arte7Bridge extends BridgeAbstract {
const PARAMETERS = array( const PARAMETERS = array(
'global' => [ 'global' => [
'video_duration_filter' => [ 'sort_by' => array(
'name' => 'Exclude short videos', 'type' => 'list',
'name' => 'Sort by',
'required' => false,
'defaultValue' => null,
'values' => array(
'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' => array(
'type' => 'list',
'name' => 'Sort direction',
'required' => false,
'defaultValue' => 'DESC',
'values' => array(
'Ascending' => 'ASC',
'Descending' => 'DESC'
),
),
'exclude_trailers' => [
'name' => 'Exclude trailers',
'type' => 'checkbox', 'type' => 'checkbox',
'title' => 'Exclude videos that are shorter than 3 minutes', 'required' => false,
'defaultValue' => false, 'defaultValue' => false
], ],
], ],
'Category' => array( 'Category' => array(
@ -30,8 +58,6 @@ class Arte7Bridge extends BridgeAbstract {
'Polski' => 'pl', 'Polski' => 'pl',
'Italiano' => 'it' 'Italiano' => 'it'
), ),
'title' => 'ex. RC-014095 pour https://www.arte.tv/fr/videos/RC-014095/blow-up/',
'exampleValue' => 'RC-014095'
), ),
'cat' => array( 'cat' => array(
'type' => 'list', 'type' => 'list',
@ -73,7 +99,6 @@ class Arte7Bridge extends BridgeAbstract {
); );
public function collectData(){ public function collectData(){
$lang = $this->getInput('lang');
switch($this->queriedContext) { switch($this->queriedContext) {
case 'Category': case 'Category':
$category = $this->getInput('cat'); $category = $this->getInput('cat');
@ -85,8 +110,13 @@ class Arte7Bridge extends BridgeAbstract {
break; break;
} }
$url = 'https://api.arte.tv/api/opa/v3/videos?sort=-lastModified&limit=15&language=' $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='
. $lang . $lang
. ($sort_by !== null ? '&sort=' . $sort_direction . $sort_by : '')
. ($category != null ? '&category.code=' . $category : '') . ($category != null ? '&category.code=' . $category : '')
. ($collectionId != null ? '&collections.collectionId=' . $collectionId : ''); . ($collectionId != null ? '&collections.collectionId=' . $collectionId : '');
@ -98,12 +128,12 @@ class Arte7Bridge extends BridgeAbstract {
$input_json = json_decode($input, true); $input_json = json_decode($input, true);
foreach($input_json['videos'] as $element) { foreach($input_json['videos'] as $element) {
$durationSeconds = $element['durationSeconds']; if($this->getInput('exclude_trailers') && $element['platform'] == 'EXTRAIT') {
if ($this->getInput('video_duration_filter') && $durationSeconds < 60 * 3) {
continue; continue;
} }
$durationSeconds = $element['durationSeconds'];
$item = array(); $item = array();
$item['uri'] = $element['url']; $item['uri'] = $element['url'];
$item['id'] = $element['id']; $item['id'] = $element['id'];