From 87fa4ae3ac618e71ef009ba4b202458547a88f88 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 23 Sep 2017 18:05:09 +0200 Subject: [PATCH 01/11] [.travis.yml] Fix warning channel pear.php.net has updated its protocol --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 969c1b32..2ce44f91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - nightly install: + - pear channel-update pear.php.net - pear install PHP_CodeSniffer script: From 1ea091f2151cddb3410d94d72015f1fe5f1c53b9 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 23 Sep 2017 18:11:21 +0200 Subject: [PATCH 02/11] [.travis.yml] Fix Tavis CI build error Travis CI recently updated the default distribution from Ubuntu Precise to Ubuntu Trusty, which causes all builds except nightly to fail. For unknown reasons phpcs is unable to locate "PHP/CodeSniffer/ autoload.php" causing it to fail with a fatal error The root cause of the failure is unknown. We explicitly return to the previous build system (Ubuntu Precise) for builds to work again. See the migration guide for reference: https://docs.travis-ci.com/user/precise-to-trusty-migration-guide/ Notice: Ubuntu Precise is retired as of September 2017 and will be decommissioned in the near future: https://docs.travis-ci.com/user/reference/overview/ --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2ce44f91..75010d8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +dist: precise language: php php: - '5.6' From e671a2ad0234af792af051314a22dc0804ecbc94 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 23 Sep 2017 18:55:47 +0200 Subject: [PATCH 03/11] [.travis.yml] Fix configuration to work with Ubuntu Trusty Travis CI upgraded the linux build environment from Ubuntu Precise to Ubuntu Trusty with Trusty becoming the default build environment as of August 2017: https://docs.travis-ci.com/user/reference/overview/ A bug in the configuration of the Ubuntu Trusty distro causes all builds except nightly to fail. The PHP include_path is set to include_path='.:/home/travis/.phpenv/versions/5.6.31/share/pear' instead of include_path='.:/home/travis/.phpenv/versions/5.6.31/lib/php/pear' which causes phpcs to fail because it cannot resolve import paths. This commit adds a hotfix to .travis.yml that circumvents the issue by overwriting the include_path during initialization. This hotfix should be removed once a solution is found. This bug is tracked via https://github.com/travis-ci/travis-ci/issues/8487 --- .travis.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 75010d8e..7e84736e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -dist: precise +dist: trusty language: php php: - '5.6' @@ -6,6 +6,20 @@ php: - hhvm - nightly +before_install: + # Circumvent a bug in current Travis CI builds using Ubuntu Trusty, where the + # include_path is wrong. + # + # Default is: + # - include_path='.:/home/travis/.phpenv/versions/5.6.31/share/pear' + # + # Should be: + # - include_path='.:/home/travis/.phpenv/versions/5.6.31/lib/php/pear' + # + # This applies to all builds except hhvm and nightly. Once the distro is fixed + # the following line can be removed + - if [[ ${TRAVIS_PHP_VERSION:0:1} == "5" || ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then echo "include_path='.:/home/travis/.phpenv/versions/$(phpenv version-name)/lib/php/pear'" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi + install: - pear channel-update pear.php.net - pear install PHP_CodeSniffer From 4037c3439336d7c09d3ac95221ade742db7c5281 Mon Sep 17 00:00:00 2001 From: LogMANOriginal Date: Sun, 24 Sep 2017 16:59:45 +0200 Subject: [PATCH 04/11] [TwitterBridge] Add category for lists (#545) This adds a new option to generate feeds from Twitter lists using an optional filter (string comparison). --- bridges/TwitterBridge.php | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index d588f6b9..66024cee 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -44,6 +44,25 @@ class TwitterBridge extends BridgeAbstract { 'type' => 'checkbox', 'title' => 'Hide retweets' ) + ), + 'By list' => array( + 'user' => array( + 'name' => 'User', + 'required' => true, + 'exampleValue' => 'sebsauvage', + 'title' => 'Insert a user name' + ), + 'list' => array( + 'name' => 'List', + 'required' => true, + 'title' => 'Insert the list name' + ), + 'filter' => array( + 'name' => 'Filter', + 'exampleValue' => '#rss-bridge', + 'required' => false, + 'title' => 'Specify term to search for' + ) ) ); @@ -57,6 +76,10 @@ class TwitterBridge extends BridgeAbstract { $specific = '@'; $param = 'u'; break; + case 'By list': + $specific = $this->getInput('user'); + $param = 'list'; + break; default: return parent::getName(); } return 'Twitter ' . $specific . $this->getInput($param); @@ -74,6 +97,11 @@ class TwitterBridge extends BridgeAbstract { . urlencode($this->getInput('u')); // Always return without replies! // . ($this->getInput('norep') ? '' : '/with_replies'); + case 'By list': + return self::URI + . urlencode($this->getInput('user')) + . '/lists/' + . str_replace(' ', '-', strtolower($this->getInput('list'))); default: return parent::getURI(); } } @@ -88,6 +116,8 @@ class TwitterBridge extends BridgeAbstract { returnServerError('No results for this query.'); case 'By username': returnServerError('Requested username can\'t be found.'); + case 'By list': + returnServerError('Requested username or list can\'t be found'); } } @@ -132,6 +162,18 @@ class TwitterBridge extends BridgeAbstract { // generate the title $item['title'] = strip_tags($this->fixAnchorSpacing($tweet->find('p.js-tweet-text', 0), '')); + switch($this->queriedContext) { + case 'By list': + // Check if filter applies to list (using raw content) + if(!is_null($this->getInput('filter'))) { + if(stripos($tweet->find('p.js-tweet-text', 0)->plaintext, $this->getInput('filter')) === false) { + continue 2; // switch + for-loop! + } + } + break; + default: + } + $this->processContentLinks($tweet); $this->processEmojis($tweet); From 3059b1ea805e8c3424eb8e9afa0e13a9ea07fc7e Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sun, 24 Sep 2017 17:23:00 +0200 Subject: [PATCH 05/11] [YoutubeBridge] Skip Ads The search might return unrelated videos (Ads) that are inserted between regular search results. This adds a check to skip Ads. Closes #571 --- bridges/YoutubeBridge.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 37ee7c72..1db07352 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -88,7 +88,8 @@ class YoutubeBridge extends BridgeAbstract { $vid = str_replace('yt:video:', '', $element->find('id', 0)->plaintext); $time = strtotime($element->find('published', 0)->plaintext); - $this->ytBridgeAddItem($vid, $title, $author, $desc, $time); + if(strpos($vid, 'googleads') === false) + $this->ytBridgeAddItem($vid, $title, $author, $desc, $time); } $this->request = $this->ytBridgeFixTitle($xml->find('feed > title', 0)->plaintext); } @@ -104,7 +105,7 @@ class YoutubeBridge extends BridgeAbstract { $vid = str_replace('/watch?v=', '', $element->find('a', 0)->href); $vid = substr($vid, 0, strpos($vid, '&') ?: strlen($vid)); $title = $this->ytBridgeFixTitle($element->find($title_selector, 0)->plaintext); - if($title != '[Private Video]') { + if($title != '[Private Video]' && strpos($vid, 'googleads') === false) { $this->ytBridgeQueryVideoInfo($vid, $author, $desc, $time); $this->ytBridgeAddItem($vid, $title, $author, $desc, $time); $count++; From 77657a91541b4bff2d2d1b0f899a3df97b62ea10 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sun, 24 Sep 2017 18:43:11 +0200 Subject: [PATCH 06/11] [.travis.yml] Refactor script --- .travis.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e84736e..794fdbf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,6 @@ dist: trusty +sudo: false language: php -php: - - '5.6' - - '7.0' - - hhvm - - nightly before_install: # Circumvent a bug in current Travis CI builds using Ubuntu Trusty, where the @@ -30,6 +26,13 @@ script: matrix: fast_finish: true + + include: + - php: 5.6 + - php: 7.0 + - php: hhvm + - php: nightly + allow_failures: - php: hhvm - php: nightly \ No newline at end of file From e30ad3feb44a5a55ce687583a5744f4cce5978a0 Mon Sep 17 00:00:00 2001 From: Teromene Date: Mon, 25 Sep 2017 19:14:02 +0200 Subject: [PATCH 07/11] Add support for running rss-bridge from the CLI --- index.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 8986558c..ec4007f2 100644 --- a/index.php +++ b/index.php @@ -28,6 +28,14 @@ define('CACHE_DIR', __DIR__ . '/cache'); // Specify path for whitelist file define('WHITELIST_FILE', __DIR__ . '/whitelist.txt'); + +/* +Move the CLI arguments to the $_GET array, in order to be able to use +rss-bridge from the command line +*/ +parse_str(implode('&', array_slice($argv, 1)), $cliArgs); +$params = array_merge($_GET, $cliArgs); + /* Create a file named 'DEBUG' for enabling debug mode. For further security, you may put whitelisted IP addresses in the file, @@ -124,8 +132,8 @@ try { $whitelist_selection = array_map('strtolower', $whitelist_selection); } - $action = filter_input(INPUT_GET, 'action'); - $bridge = filter_input(INPUT_GET, 'bridge'); + $action = $params['action']; + $bridge = $params['bridge']; if($action === 'display' && !empty($bridge)) { // DEPRECATED: 'nameBridge' scheme is replaced by 'name' in bridge parameter values @@ -134,7 +142,7 @@ try { $bridge = substr($bridge, 0, $pos); } - $format = filter_input(INPUT_GET, 'format') + $format = $params['format'] or returnClientError('You must specify a format!'); // DEPRECATED: 'nameFormat' scheme is replaced by 'name' in format parameter values @@ -152,13 +160,11 @@ try { // Data retrieval $bridge = Bridge::create($bridge); - $noproxy = filter_input(INPUT_GET, '_noproxy', FILTER_VALIDATE_BOOLEAN); + $noproxy = filter_var($params['_noproxy'], FILTER_VALIDATE_BOOLEAN); if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy) { define('NOPROXY', true); } - $params = $_GET; - // Initialize cache $cache = Cache::create('FileCache'); $cache->setPath(CACHE_DIR); From 5a999818272d1af4681035c789332c84465ad9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABlBERTRAND?= Date: Sun, 8 Oct 2017 19:21:10 +0200 Subject: [PATCH 08/11] Updater torrent9 URI --- bridges/Torrent9Bridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/Torrent9Bridge.php b/bridges/Torrent9Bridge.php index 742e777c..40db4acd 100644 --- a/bridges/Torrent9Bridge.php +++ b/bridges/Torrent9Bridge.php @@ -3,7 +3,7 @@ class Torrent9Bridge extends BridgeAbstract { const MAINTAINER = 'lagaisse'; const NAME = 'Torrent9 Bridge'; - const URI = 'http://www.torrent9.biz'; + const URI = 'http://www.torrent9.pe'; const CACHE_TIMEOUT = 86400; // 24h = 86400s const DESCRIPTION = 'Returns latest torrents'; From 8b06299bad4f61a310520746175dadcc9385e3f8 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Wed, 11 Oct 2017 10:03:29 +0200 Subject: [PATCH 09/11] Update GoComicsBridge --- bridges/GoComicsBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/GoComicsBridge.php b/bridges/GoComicsBridge.php index b249ccba..268bd90d 100644 --- a/bridges/GoComicsBridge.php +++ b/bridges/GoComicsBridge.php @@ -20,7 +20,7 @@ class GoComicsBridge extends BridgeAbstract { foreach($html->find('div.comic__container') as $element) { - $img = $element->find('img', 0); + $img = $element->find('.item-comic-image img', 0); $link = $element->find('a.js-item-comic-link', 0); $comic = $img->src; $title = $link->title; From 98b0f0f8badb4bf36dec69f41435143fab48d31d Mon Sep 17 00:00:00 2001 From: teromene Date: Thu, 12 Oct 2017 17:14:34 +0100 Subject: [PATCH 10/11] [Core] Verify the presence of the array keys before accessing them. Fixes #588 --- index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index ec4007f2..799980b5 100644 --- a/index.php +++ b/index.php @@ -132,8 +132,8 @@ try { $whitelist_selection = array_map('strtolower', $whitelist_selection); } - $action = $params['action']; - $bridge = $params['bridge']; + $action = array_key_exists('action', $params) ? $params['action'] : null; + $bridge = array_key_exists('bridge', $params) ? $params['bridge'] : null; if($action === 'display' && !empty($bridge)) { // DEPRECATED: 'nameBridge' scheme is replaced by 'name' in bridge parameter values @@ -160,7 +160,7 @@ try { // Data retrieval $bridge = Bridge::create($bridge); - $noproxy = filter_var($params['_noproxy'], FILTER_VALIDATE_BOOLEAN); + $noproxy = array_key_exists('_noproxy', $params) && filter_var($params['_noproxy'], FILTER_VALIDATE_BOOLEAN); if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy) { define('NOPROXY', true); } From cba65d6d087f14b2ca2fda995745ac8f5f79310d Mon Sep 17 00:00:00 2001 From: teromene Date: Thu, 12 Oct 2017 18:12:31 +0100 Subject: [PATCH 11/11] [Arte7Bridge] Fix Arte7 bridge, use the API --- bridges/Arte7Bridge.php | 80 ++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 3d7ae9de..42b5afcc 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -3,24 +3,28 @@ class Arte7Bridge extends BridgeAbstract { const MAINTAINER = 'mitsukarenai'; const NAME = 'Arte +7'; - const URI = 'http://www.arte.tv/'; + const URI = 'https://www.arte.tv/'; const CACHE_TIMEOUT = 1800; // 30min const DESCRIPTION = 'Returns newest videos from ARTE +7'; + + const API_TOKEN = 'Nzc1Yjc1ZjJkYjk1NWFhN2I2MWEwMmRlMzAzNjI5NmU3NWU3ODg4ODJjOWMxNTMxYzEzZGRjYjg2ZGE4MmIwOA'; + const PARAMETERS = array( 'Catégorie (Français)' => array( 'catfr' => array( 'type' => 'list', 'name' => 'Catégorie', 'values' => array( - 'Toutes les vidéos (français)' => 'toutes-les-videos', - 'Actu & société' => 'actu-société', - 'Séries & fiction' => 'séries-fiction', - 'Cinéma' => 'cinéma', - 'Arts & spectacles classiques' => 'arts-spectacles-classiques', - 'Culture pop' => 'culture-pop', - 'Découverte' => 'découverte', - 'Histoire' => 'histoire', - 'Junior' => 'junior' + 'Toutes les vidéos (français)' => null, + 'Actu & société' => 'ACT', + 'Séries & fiction' => 'SER', + 'Cinéma' => 'CIN', + 'Arts & spectacles classiques' => 'ARS', + 'Culture pop' => 'CPO', + 'Découverte' => 'DEC', + 'Histoire' => 'HIST', + 'Science' => 'SCI', + 'Autre' => 'AUT' ) ) ), @@ -29,15 +33,16 @@ class Arte7Bridge extends BridgeAbstract { 'type' => 'list', 'name' => 'Catégorie', 'values' => array( - 'Alle Videos (deutsch)' => 'alle-videos', - 'Aktuelles & Gesellschaft' => 'aktuelles-gesellschaft', - 'Fernsehfilme & Serien' => 'fernsehfilme-serien', - 'Kino' => 'kino', - 'Kunst & Kultur' => 'kunst-kultur', - 'Popkultur & Alternativ' => 'popkultur-alternativ', - 'Entdeckung' => 'entdeckung', - 'Geschichte' => 'geschichte', - 'Junior' => 'junior' + 'Alle Videos (deutsch)' => null, + 'Aktuelles & Gesellschaft' => 'ACT', + 'Fernsehfilme & Serien' => 'SER', + 'Kino' => 'CIN', + 'Kunst & Kultur' => 'ARS', + 'Popkultur & Alternativ' => 'CPO', + 'Entdeckung' => 'DEC', + 'Geschichte' => 'HIST', + 'Wissenschaft' => 'SCI', + 'Sonstiges' => 'AUT' ) ) ) @@ -55,44 +60,39 @@ class Arte7Bridge extends BridgeAbstract { break; } - $url = self::URI . 'guide/' . $lang . '/plus7/' . $category; - $input = getContents($url) or die('Could not request ARTE.'); + $url = 'https://api.arte.tv/api/opa/v3/videos?sort=broadcastBegin&limit=10&language=' + . $lang + . ($category != null ? '&category.code=' . $category : ''); - if(strpos($input, 'categoryVideoSet') !== false) { - $input = explode('categoryVideoSet="', $input); - $input = explode('}}', $input[1]); - $input = $input[0] . '}}'; - } else { - $input = explode('videoSet="', $input); - $input = explode('}]}', $input[1]); - $input = $input[0] . '}]}'; - } + $context = array( + 'http' => array( + 'header' => 'Authorization: Bearer '. self::API_TOKEN + ) + ); - $input_json = json_decode(html_entity_decode($input, ENT_QUOTES), true); + $input = getContents($url, false, stream_context_create($context)) or die('Could not request ARTE.'); + $input_json = json_decode($input, true); foreach($input_json['videos'] as $element) { + $item = array(); - $item['uri'] = str_replace("autoplay=1", "", $element['url']); + $item['uri'] = $element['url']; $item['id'] = $element['id']; - $hack_broadcast_time = $element['rights_end']; - $hack_broadcast_time = strtok($hack_broadcast_time, 'T'); - $hack_broadcast_time = strtok('T'); - - $item['timestamp'] = strtotime($element['scheduled_on'] . 'T' . $hack_broadcast_time); + $item['timestamp'] = strtotime($element['videoRightsBegin']); $item['title'] = $element['title']; if(!empty($element['subtitle'])) $item['title'] = $element['title'] . ' | ' . $element['subtitle']; - $item['duration'] = round((int)$element['duration'] / 60); - $item['content'] = $element['teaser'] + $item['duration'] = round((int)$element['durationSeconds'] / 60); + $item['content'] = $element['teaserText'] . '

' . $item['duration'] . 'min
'; $this->items[] = $item;