forked from blallo/rss-bridge
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
3c61dc2b57
7 changed files with 123 additions and 55 deletions
29
.travis.yml
29
.travis.yml
|
@ -1,11 +1,23 @@
|
|||
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
|
||||
# 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
|
||||
|
||||
script:
|
||||
|
@ -14,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
|
|
@ -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']
|
||||
. '<br><br>'
|
||||
. $item['duration']
|
||||
. 'min<br><a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
. $element['thumbnail_url']
|
||||
. $element['mainImage']['url']
|
||||
. '" /></a>';
|
||||
|
||||
$this->items[] = $item;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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), '<a>'));
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -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++;
|
||||
|
|
18
index.php
18
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 = 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
|
||||
|
@ -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 = array_key_exists('_noproxy', $params) && 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);
|
||||
|
|
Loading…
Reference in a new issue