From 924eaf20114e238f90bef074a3daafedaebef497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20F=C3=BCrhoff?= Date: Thu, 14 Apr 2022 23:20:09 +0200 Subject: [PATCH] [Arte7Bridge] Exclude trailers and sort by (#2660) --- bridges/Arte7Bridge.php | 54 ++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 4b206e8a..ebcd8eaa 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -1,9 +1,9 @@ [ - 'video_duration_filter' => [ - 'name' => 'Exclude short videos', + 'sort_by' => array( + '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', - 'title' => 'Exclude videos that are shorter than 3 minutes', - 'defaultValue' => false, + 'required' => false, + 'defaultValue' => false ], ], 'Category' => array( @@ -30,8 +58,6 @@ class Arte7Bridge extends BridgeAbstract { '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', @@ -73,7 +99,6 @@ class Arte7Bridge extends BridgeAbstract { ); public function collectData(){ - $lang = $this->getInput('lang'); switch($this->queriedContext) { case 'Category': $category = $this->getInput('cat'); @@ -85,8 +110,13 @@ class Arte7Bridge extends BridgeAbstract { 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 + . ($sort_by !== null ? '&sort=' . $sort_direction . $sort_by : '') . ($category != null ? '&category.code=' . $category : '') . ($collectionId != null ? '&collections.collectionId=' . $collectionId : ''); @@ -98,12 +128,12 @@ class Arte7Bridge extends BridgeAbstract { $input_json = json_decode($input, true); foreach($input_json['videos'] as $element) { - $durationSeconds = $element['durationSeconds']; - - if ($this->getInput('video_duration_filter') && $durationSeconds < 60 * 3) { + if($this->getInput('exclude_trailers') && $element['platform'] == 'EXTRAIT') { continue; } + $durationSeconds = $element['durationSeconds']; + $item = array(); $item['uri'] = $element['url']; $item['id'] = $element['id'];