From 28077155ca9343c6492fac36fc71078a6633e984 Mon Sep 17 00:00:00 2001 From: mruac Date: Tue, 15 Aug 2023 23:34:09 +0930 Subject: [PATCH] [PatreonBridge] Resolve creator name in feed name (#3616) * resolve creators without custom url * hint how to enter creator with non-custom url * applied phpcbf --- bridges/PatreonBridge.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bridges/PatreonBridge.php b/bridges/PatreonBridge.php index b64102da..23dbf8ae 100644 --- a/bridges/PatreonBridge.php +++ b/bridges/PatreonBridge.php @@ -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();