From 4037c3439336d7c09d3ac95221ade742db7c5281 Mon Sep 17 00:00:00 2001 From: LogMANOriginal Date: Sun, 24 Sep 2017 16:59:45 +0200 Subject: [PATCH] [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 d588f6b..66024ce 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);