[Arte7Bridge] Exclude trailers and sort by v2 (#2664)

This commit is contained in:
Loïc Fürhoff 2022-04-16 23:08:27 +02:00 committed by GitHub
parent 1dec457b7b
commit 669e92357a
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
class Arte7Bridge extends BridgeAbstract {
// const MAINTAINER = 'mitsukarenai';
const NAME = 'Arte +7';
const URI = 'https://www.arte.tv/';
const MAINTAINER = 'imagoiq';
const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = 'Returns newest videos from ARTE +7';
@ -11,11 +11,39 @@ class Arte7Bridge extends BridgeAbstract {
const PARAMETERS = array(
'global' => [
'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'];