[PatreonBridge] Resolve creator name in feed name (#3616)

* resolve creators without custom url

* hint how to enter creator with non-custom url

* applied phpcbf
This commit is contained in:
mruac 2023-08-15 23:34:09 +09:30 committed by GitHub
parent 7a1180c80f
commit 28077155ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,13 +6,13 @@ class PatreonBridge extends BridgeAbstract
const URI = 'https://www.patreon.com/';
const CACHE_TIMEOUT = 300; // 5min
const DESCRIPTION = 'Returns posts by creators on Patreon';
const MAINTAINER = 'Roliga';
const PARAMETERS = [ [
const MAINTAINER = 'Roliga, mruac';
const PARAMETERS = [[
'creator' => [
'name' => 'Creator',
'type' => 'text',
'required' => true,
'exampleValue' => 'sanityinc',
'exampleValue' => 'user?u=13425451',
'title' => 'Creator name as seen in their page URL'
]
]];
@ -189,7 +189,13 @@ class PatreonBridge extends BridgeAbstract
public function getName()
{
if (!is_null($this->getInput('creator'))) {
return $this->getInput('creator') . ' posts';
$html = getSimpleHTMLDOMCached($this->getURI());
if ($html) {
preg_match('#"name": "(.*)"#', $html->save(), $matches);
return 'Patreon posts from ' . stripcslashes($matches[1]);
} else {
return $this->getInput('creator') . 'posts from Patreon';
}
}
return parent::getName();