[RedditBridge] Search for specific flairs (#3067)

* flair filter

* syntax

* fix multi & user feeds

* '

* dont replace ,
This commit is contained in:
joshinat0r 2022-10-02 07:34:20 +02:00 committed by GitHub
parent 8dcc21a871
commit 30d964b356
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,6 +41,12 @@ class RedditBridge extends BridgeAbstract
'required' => true, 'required' => true,
'exampleValue' => 'selfhosted', 'exampleValue' => 'selfhosted',
'title' => 'SubReddit name' 'title' => 'SubReddit name'
],
'f' => [
'name' => 'Flair',
'required' => false,
'exampleValue' => 'Proxy',
'title' => 'Flair filter'
] ]
], ],
'multi' => [ 'multi' => [
@ -136,11 +142,22 @@ class RedditBridge extends BridgeAbstract
$keywords = ''; $keywords = '';
} }
if (!($this->getInput('f') === '') && $this->queriedContext == 'single') {
$flair = $this->getInput('f');
$flair = str_replace(' ', '%20', $flair);
$flair = 'flair%3A%22' . $flair . '%22%20';
} else {
$flair = '';
}
foreach ($subreddits as $subreddit) { foreach ($subreddits as $subreddit) {
$name = trim($subreddit); $name = trim($subreddit);
$values = getContents(self::URI $values = getContents(self::URI
. '/search.json?q=' . '/search.json?q='
. $keywords . $keywords
. $flair
. ($user ? 'author%3A' : 'subreddit%3A') . ($user ? 'author%3A' : 'subreddit%3A')
. $name . $name
. '&sort=' . '&sort='