[Arte7Bridge] feat: add duration filter #662

The feed item was given a "duration" key but that's not used
for anything.

refs https://github.com/RSS-Bridge/rss-bridge/issues/662
This commit is contained in:
Dag 2022-03-26 00:03:38 +01:00
parent 02ba3adcc9
commit 2c00ecb923
1 changed files with 15 additions and 2 deletions

View File

@ -10,6 +10,14 @@ class Arte7Bridge extends BridgeAbstract {
const API_TOKEN = 'Nzc1Yjc1ZjJkYjk1NWFhN2I2MWEwMmRlMzAzNjI5NmU3NWU3ODg4ODJjOWMxNTMxYzEzZGRjYjg2ZGE4MmIwOA'; const API_TOKEN = 'Nzc1Yjc1ZjJkYjk1NWFhN2I2MWEwMmRlMzAzNjI5NmU3NWU3ODg4ODJjOWMxNTMxYzEzZGRjYjg2ZGE4MmIwOA';
const PARAMETERS = array( const PARAMETERS = array(
'global' => [
'video_duration_filter' => [
'name' => 'Exclude short videos',
'type' => 'checkbox',
'title' => 'Exclude videos that are shorter than 3 minutes',
'defaultValue' => '',
],
],
'Catégorie (Français)' => array( 'Catégorie (Français)' => array(
'catfr' => array( 'catfr' => array(
'type' => 'list', 'type' => 'list',
@ -97,6 +105,11 @@ 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('video_duration_filter') && $durationSeconds < 60 * 3) {
continue;
}
$item = array(); $item = array();
$item['uri'] = $element['url']; $item['uri'] = $element['url'];
@ -108,10 +121,10 @@ class Arte7Bridge extends BridgeAbstract {
if(!empty($element['subtitle'])) if(!empty($element['subtitle']))
$item['title'] = $element['title'] . ' | ' . $element['subtitle']; $item['title'] = $element['title'] . ' | ' . $element['subtitle'];
$item['duration'] = round((int)$element['durationSeconds'] / 60); $durationMinutes = round((int)$durationSeconds / 60);
$item['content'] = $element['teaserText'] $item['content'] = $element['teaserText']
. '<br><br>' . '<br><br>'
. $item['duration'] . $durationMinutes
. 'min<br><a href="' . 'min<br><a href="'
. $item['uri'] . $item['uri']
. '"><img src="' . '"><img src="'