From 539d011cb275425aa45a4573b4a4b61b12b71138 Mon Sep 17 00:00:00 2001 From: Michael Bemmerl Date: Mon, 26 Jan 2026 22:53:29 +0100 Subject: [PATCH 1/4] Rewrite of the Spottschau Bridge --- bridges/SpottschauBridge.php | 43 ++++++++++++++---------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/bridges/SpottschauBridge.php b/bridges/SpottschauBridge.php index a2720274c7f..907f5d780b2 100644 --- a/bridges/SpottschauBridge.php +++ b/bridges/SpottschauBridge.php @@ -4,39 +4,30 @@ class SpottschauBridge extends BridgeAbstract { const NAME = 'Härringers Spottschau Bridge'; const URI = 'https://spottschau.com/'; - const DESCRIPTION = 'Der Fußball-Comic'; + const DESCRIPTION = 'Returns the latest strip from the "Härringers Spottschau" comic.'; const MAINTAINER = 'sal0max'; - const PARAMETERS = []; - const CACHE_TIMEOUT = 3600; // 1 hour + const CACHE_TIMEOUT = 86400; // 24h public function collectData() { - $html = getSimpleHTMLDOM(self::URI); + $html = getSimpleHTMLDOMCached(self::URI, self::CACHE_TIMEOUT) + or returnServerError('Could not retrieve ' . self::URI); - $item = []; - $item['uri'] = urljoin(self::URI, $html->find('div.strip>a', 0)->attr['href']); - $item['title'] = $html->find('div.text>h2', 0)->innertext; + $strip = $html->find('div.strip > a', 0) + or returnServerError('Could not find the proper HTML element of the strip.'); - $date = preg_replace('/.*, /', '', $item['title']); - $date = preg_replace('/\\d\\d\\.\\//', '', $date); - try { - $item['timestamp'] = DateTime::createFromFormat('d.m.y', $date) - ->setTimezone(new DateTimeZone('Europe/Berlin')) - ->setTime(0, 0) - ->getTimestamp(); - } catch (Throwable $ignored) { - $item['timestamp'] = null; - } + defaultLinkTo($strip, self::URI); + // Get URL from image src attribute + $src = $strip->children(0)->src; - $image = $html->find('div.strip>a>img', 0); - $imageUrl = urljoin(self::URI, $image->attr['src']); - $imageAlt = $image->attr['alt']; - - $item['content'] = << -
-EOD; - $this->items[] = $item; + $this->items[] = array( + 'uri' => self::URI, + 'title' => 'Strip der Woche', + 'content' => '', + 'enclosures' => array($src), + 'author' => 'Christoph Härringer', + 'uid' => $src, + ); } } From 8f31bfb421d2680fbdc304a19a3d8020d3316ccc Mon Sep 17 00:00:00 2001 From: Michael Bemmerl Date: Mon, 26 Jan 2026 23:18:22 +0100 Subject: [PATCH 2/4] Fix errors detected by the linter. --- bridges/SpottschauBridge.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridges/SpottschauBridge.php b/bridges/SpottschauBridge.php index 907f5d780b2..88ea4f67d80 100644 --- a/bridges/SpottschauBridge.php +++ b/bridges/SpottschauBridge.php @@ -21,13 +21,13 @@ public function collectData() // Get URL from image src attribute $src = $strip->children(0)->src; - $this->items[] = array( + $this->items[] = [ 'uri' => self::URI, 'title' => 'Strip der Woche', 'content' => '', - 'enclosures' => array($src), + 'enclosures' => [$src], 'author' => 'Christoph Härringer', 'uid' => $src, - ); + ]; } } From 3f945abafbc0fb430d9cf753e9a2cddfb7ec6c78 Mon Sep 17 00:00:00 2001 From: Michael Bemmerl Date: Mon, 26 Jan 2026 23:21:35 +0100 Subject: [PATCH 3/4] Fix linting errors /again/ --- bridges/SpottschauBridge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/SpottschauBridge.php b/bridges/SpottschauBridge.php index 88ea4f67d80..6fcea19d7c0 100644 --- a/bridges/SpottschauBridge.php +++ b/bridges/SpottschauBridge.php @@ -12,10 +12,10 @@ class SpottschauBridge extends BridgeAbstract public function collectData() { $html = getSimpleHTMLDOMCached(self::URI, self::CACHE_TIMEOUT) - or returnServerError('Could not retrieve ' . self::URI); + or throwServerException('Could not retrieve ' . self::URI); $strip = $html->find('div.strip > a', 0) - or returnServerError('Could not find the proper HTML element of the strip.'); + or throwServerException('Could not find the proper HTML element of the strip.'); defaultLinkTo($strip, self::URI); // Get URL from image src attribute From 4a106ec0e1275d05f7fb118b96f7f83857dbd006 Mon Sep 17 00:00:00 2001 From: Michael Bemmerl Date: Tue, 3 Feb 2026 23:57:24 +0100 Subject: [PATCH 4/4] Remove throwServerException since will never be called, because getSimpleHTMLDOMCached never returns FALSE. --- bridges/SpottschauBridge.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bridges/SpottschauBridge.php b/bridges/SpottschauBridge.php index 6fcea19d7c0..89d82b8c6b3 100644 --- a/bridges/SpottschauBridge.php +++ b/bridges/SpottschauBridge.php @@ -11,8 +11,7 @@ class SpottschauBridge extends BridgeAbstract public function collectData() { - $html = getSimpleHTMLDOMCached(self::URI, self::CACHE_TIMEOUT) - or throwServerException('Could not retrieve ' . self::URI); + $html = getSimpleHTMLDOMCached(self::URI, self::CACHE_TIMEOUT); $strip = $html->find('div.strip > a', 0) or throwServerException('Could not find the proper HTML element of the strip.');