[TwitterBridge] Add category for lists (#545)

This adds a new option to generate feeds from Twitter lists using
an optional filter (string comparison).
This commit is contained in:
LogMANOriginal 2017-09-24 16:59:45 +02:00 committed by GitHub
parent e671a2ad02
commit 4037c34393

View file

@ -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);