From 9ea982f31fe49a259e66b9f72208cd3944c50f9c Mon Sep 17 00:00:00 2001 From: Dag Date: Fri, 3 Jan 2025 04:56:32 +0100 Subject: [PATCH] refactor: remove dead code --- bridges/AirBreizhBridge.php | 3 +-- bridges/AmazonPriceTrackerBridge.php | 2 +- bridges/AssociatedPressNewsBridge.php | 3 +-- bridges/BAEBridge.php | 2 +- bridges/BandcampDailyBridge.php | 6 ++--- bridges/BundestagParteispendenBridge.php | 6 ++--- bridges/CrewbayBridge.php | 2 +- bridges/DacksnackBridge.php | 6 ++--- bridges/DagensNyheterDirektBridge.php | 3 +-- bridges/FindACrewBridge.php | 2 +- bridges/FurAffinityUserBridge.php | 3 +-- bridges/GiteaBridge.php | 9 +++---- bridges/GlowficBridge.php | 2 +- bridges/GogsBridge.php | 3 +-- bridges/GoogleScholarBridge.php | 4 ++-- bridges/ItakuBridge.php | 24 +++++++------------ bridges/JohannesBlickBridge.php | 3 +-- bridges/JustETFBridge.php | 3 +-- bridges/KernelBugTrackerBridge.php | 4 ---- bridges/LaTeX3ProjectNewslettersBridge.php | 2 +- bridges/MozillaBugTrackerBridge.php | 4 ---- bridges/OMonlineBridge.php | 6 ++--- .../SchweinfurtBuergerinformationenBridge.php | 6 ++--- bridges/SkimfeedBridge.php | 12 ++++------ bridges/StanfordSIRbookreviewBridge.php | 3 +-- bridges/StockFilingsBridge.php | 2 +- bridges/StorytelBridge.php | 3 --- bridges/TapasBridge.php | 2 +- bridges/TestFaktaBridge.php | 6 ++--- bridges/UsesTechBridge.php | 3 +-- bridges/VproTegenlichtBridge.php | 3 +-- bridges/WikipediaBridge.php | 4 ---- bridges/XenForoBridge.php | 12 ++++------ 33 files changed, 52 insertions(+), 106 deletions(-) diff --git a/bridges/AirBreizhBridge.php b/bridges/AirBreizhBridge.php index a822625f47b..272c74ee121 100644 --- a/bridges/AirBreizhBridge.php +++ b/bridges/AirBreizhBridge.php @@ -32,8 +32,7 @@ public function getIcon() public function collectData() { $html = ''; - $html = getSimpleHTMLDOM(static::URI . 'publications/?fwp_publications_thematiques=' . $this->getInput('theme')) - or returnClientError('No results for this query.'); + $html = getSimpleHTMLDOM(static::URI . 'publications/?fwp_publications_thematiques=' . $this->getInput('theme')); foreach ($html->find('article') as $article) { $item = []; diff --git a/bridges/AmazonPriceTrackerBridge.php b/bridges/AmazonPriceTrackerBridge.php index b07bdb7cf0a..5f93eb49b64 100644 --- a/bridges/AmazonPriceTrackerBridge.php +++ b/bridges/AmazonPriceTrackerBridge.php @@ -146,7 +146,7 @@ private function getHtml() { $uri = $this->getURI(); - return getSimpleHTMLDOM($uri) ?: returnServerError('Could not request Amazon.'); + return getSimpleHTMLDOM($uri); } private function scrapePriceFromMetrics($html) diff --git a/bridges/AssociatedPressNewsBridge.php b/bridges/AssociatedPressNewsBridge.php index 0f8846eb416..db62c82692b 100644 --- a/bridges/AssociatedPressNewsBridge.php +++ b/bridges/AssociatedPressNewsBridge.php @@ -105,8 +105,7 @@ private function getTagURI() private function collectCardData() { - $json = getContents($this->getTagURI()) - or returnServerError('Could not request: ' . $this->getTagURI()); + $json = getContents($this->getTagURI()); $tagContents = json_decode($json, true); diff --git a/bridges/BAEBridge.php b/bridges/BAEBridge.php index 6807d5483ab..a0e4c536f71 100644 --- a/bridges/BAEBridge.php +++ b/bridges/BAEBridge.php @@ -29,7 +29,7 @@ class BAEBridge extends BridgeAbstract public function collectData() { $url = $this->getURI(); - $html = getSimpleHTMLDOM($url) or returnClientError('No results for this query.'); + $html = getSimpleHTMLDOM($url); $annonces = $html->find('main article'); foreach ($annonces as $annonce) { diff --git a/bridges/BandcampDailyBridge.php b/bridges/BandcampDailyBridge.php index 57299a17377..1f9a031d1f9 100644 --- a/bridges/BandcampDailyBridge.php +++ b/bridges/BandcampDailyBridge.php @@ -93,8 +93,7 @@ class BandcampDailyBridge extends BridgeAbstract public function collectData() { - $html = getSimpleHTMLDOM($this->getURI()) - or returnServerError('Could not request: ' . $this->getURI()); + $html = getSimpleHTMLDOM($this->getURI()); $html = defaultLinkTo($html, self::URI); @@ -105,8 +104,7 @@ public function collectData() $articlePath = $article->find('a.title', 0)->href; - $articlePageHtml = getSimpleHTMLDOMCached($articlePath, 3600) - or returnServerError('Could not request: ' . $articlePath); + $articlePageHtml = getSimpleHTMLDOMCached($articlePath, 3600); $item['uri'] = $articlePath; $item['title'] = $articlePageHtml->find('article-title', 0)->innertext; diff --git a/bridges/BundestagParteispendenBridge.php b/bridges/BundestagParteispendenBridge.php index cdf398e8b6c..30817d960a1 100644 --- a/bridges/BundestagParteispendenBridge.php +++ b/bridges/BundestagParteispendenBridge.php @@ -26,8 +26,7 @@ public function collectData() https://www.bundestag.de/ajax/filterlist/de/parlament/praesidium/parteienfinanzierung/fundstellen50000/462002-462002 URI; // Get the main page - $html = getSimpleHTMLDOMCached($ajaxUri, self::CACHE_TIMEOUT) - or returnServerError('Could not request AJAX list.'); + $html = getSimpleHTMLDOMCached($ajaxUri, self::CACHE_TIMEOUT); // Build the URL from the first anchor element. The list is sorted by year, descending, so the first element is the current year. $firstAnchor = $html->find('a', 0) @@ -36,8 +35,7 @@ public function collectData() $url = 'https://www.bundestag.de' . $firstAnchor->href; // Get the actual page with the soft money donations - $html = getSimpleHTMLDOMCached($url, self::CACHE_TIMEOUT) - or returnServerError('Could not request ' . $url); + $html = getSimpleHTMLDOMCached($url, self::CACHE_TIMEOUT); $rows = $html->find('table.table > tbody > tr') or returnServerError('Could not find the proper HTML elements.'); diff --git a/bridges/CrewbayBridge.php b/bridges/CrewbayBridge.php index 0ca017c2acf..0fb9def6c14 100644 --- a/bridges/CrewbayBridge.php +++ b/bridges/CrewbayBridge.php @@ -109,7 +109,7 @@ class CrewbayBridge extends BridgeAbstract public function collectData() { $url = $this->getURI(); - $html = getSimpleHTMLDOM($url) or returnClientError('No results for this query.'); + $html = getSimpleHTMLDOM($url); $annonces = $html->find('#SearchResults div.result'); $limit = 0; diff --git a/bridges/DacksnackBridge.php b/bridges/DacksnackBridge.php index 7aab48d1094..a031706e010 100644 --- a/bridges/DacksnackBridge.php +++ b/bridges/DacksnackBridge.php @@ -53,8 +53,7 @@ private function parseSwedishDates($dateString) public function collectData() { $NEWSURL = self::URI; - $html = getSimpleHTMLDOMCached($NEWSURL, 18000) or - returnServerError('Could not request: ' . $NEWSURL); + $html = getSimpleHTMLDOMCached($NEWSURL, 18000); foreach ($html->find('a.main-news-item') as $element) { // Debug::log($element); @@ -64,8 +63,7 @@ public function collectData() $url = self::URI . $element->getAttribute('href'); $published = $this->parseSwedishDates(trim($element->find('.published', 0)->plaintext)); - $article_html = getSimpleHTMLDOMCached($url, 18000) or - returnServerError('Could not request: ' . $url); + $article_html = getSimpleHTMLDOMCached($url, 18000); $article_content = $article_html->find('#ctl00_ContentPlaceHolder1_NewsArticleVeiw_pnlArticle', 0); $figure = self::URI . $article_content->find('img.news-image', 0)->getAttribute('src'); diff --git a/bridges/DagensNyheterDirektBridge.php b/bridges/DagensNyheterDirektBridge.php index f0748b76f23..fa219a09439 100644 --- a/bridges/DagensNyheterDirektBridge.php +++ b/bridges/DagensNyheterDirektBridge.php @@ -18,8 +18,7 @@ public function collectData() { $NEWSURL = self::BASEURL . '/ajax/direkt/'; - $html = getSimpleHTMLDOM($NEWSURL) or - returnServerError('Could not request: ' . $NEWSURL); + $html = getSimpleHTMLDOM($NEWSURL); foreach ($html->find('article') as $element) { $link = $element->find('button', 0)->getAttribute('data-link'); diff --git a/bridges/FindACrewBridge.php b/bridges/FindACrewBridge.php index 9119535b084..0bc181f3409 100644 --- a/bridges/FindACrewBridge.php +++ b/bridges/FindACrewBridge.php @@ -60,7 +60,7 @@ public function collectData() CURLOPT_POSTFIELDS => http_build_query($data) . "\n" ]; - $html = getSimpleHTMLDOM($url, $header, $opts) or returnClientError('No results for this query.'); + $html = getSimpleHTMLDOM($url, $header, $opts); $annonces = $html->find('.css_SrhRst'); $limit = $this->getInput('limit') ?? 10; diff --git a/bridges/FurAffinityUserBridge.php b/bridges/FurAffinityUserBridge.php index fa10d7ae113..1866308dc42 100644 --- a/bridges/FurAffinityUserBridge.php +++ b/bridges/FurAffinityUserBridge.php @@ -34,8 +34,7 @@ public function collectData() $url = self::URI . '/gallery/' . $this->getInput('searchUsername'); - $html = getSimpleHTMLDOM($url, [], $opt) - or returnServerError('Could not load the user\'s gallery page.'); + $html = getSimpleHTMLDOM($url, [], $opt); $submissions = $html->find('section[id=gallery-gallery]', 0)->find('figure'); foreach ($submissions as $submission) { diff --git a/bridges/GiteaBridge.php b/bridges/GiteaBridge.php index f7f426e95bd..8433b6dd979 100644 --- a/bridges/GiteaBridge.php +++ b/bridges/GiteaBridge.php @@ -155,8 +155,7 @@ public function getURI() public function collectData() { - $html = getSimpleHTMLDOM($this->getURI()) - or returnServerError('Could not request ' . $this->getURI()); + $html = getSimpleHTMLDOM($this->getURI()); $html = defaultLinkTo($html, $this->getURI()); $this->title = $html->find('[property="og:title"]', 0)->content; @@ -246,8 +245,7 @@ protected function collectIssuesData($html) ]; if ($this->getInput('include_description')) { - $issue_html = getSimpleHTMLDOMCached($uri, 3600) - or returnServerError('Unable to load issue description'); + $issue_html = getSimpleHTMLDOMCached($uri, 3600); $issue_html = defaultLinkTo($issue_html, $uri); @@ -308,8 +306,7 @@ protected function collectPullRequestsData($html) ]; if ($this->getInput('include_description')) { - $issue_html = getSimpleHTMLDOMCached($uri, 3600) - or returnServerError('Unable to load issue description'); + $issue_html = getSimpleHTMLDOMCached($uri, 3600); $issue_html = defaultLinkTo($issue_html, $uri); diff --git a/bridges/GlowficBridge.php b/bridges/GlowficBridge.php index 0e4b8d93704..7a58a08f4d4 100644 --- a/bridges/GlowficBridge.php +++ b/bridges/GlowficBridge.php @@ -28,7 +28,7 @@ class GlowficBridge extends BridgeAbstract public function collectData() { $url = $this->getAPIURI(); - $metadata = get_headers($url . '/replies', true) or returnClientError('Post did not return reply headers.'); + $metadata = get_headers($url . '/replies', true); $metadata['Last-Page'] = ceil($metadata['Total'] / $metadata['Per-Page']); if ( !is_null($this->getInput('start_page')) && diff --git a/bridges/GogsBridge.php b/bridges/GogsBridge.php index 685e5ba26cf..d838674f6c7 100644 --- a/bridges/GogsBridge.php +++ b/bridges/GogsBridge.php @@ -171,8 +171,7 @@ protected function collectIssuesData($html) ]; if ($this->getInput('include_description')) { - $issue_html = getSimpleHTMLDOMCached($uri, 3600) - or returnServerError('Unable to load issue description'); + $issue_html = getSimpleHTMLDOMCached($uri, 3600); $issue_html = defaultLinkTo($issue_html, $uri); diff --git a/bridges/GoogleScholarBridge.php b/bridges/GoogleScholarBridge.php index 11dc123b22b..3004180fe34 100644 --- a/bridges/GoogleScholarBridge.php +++ b/bridges/GoogleScholarBridge.php @@ -109,7 +109,7 @@ public function collectData() case 'user': $userId = $this->getInput('userId'); $uri = self::URI . '/citations?hl=en&view_op=list_works&sortby=pubdate&user=' . $userId; - $html = getSimpleHTMLDOM($uri) or returnServerError('Could not fetch Google Scholar data.'); + $html = getSimpleHTMLDOM($uri); $publications = $html->find('tr[class="gsc_a_tr"]'); @@ -184,7 +184,7 @@ public function collectData() $uri .= $sortBy ? '&scisbd=1' : ''; $uri .= $numResults ? '&num=' . $numResults : ''; - $html = getSimpleHTMLDOM($uri) or returnServerError('Could not fetch Google Scholar data.'); + $html = getSimpleHTMLDOM($uri); $publications = $html->find('div[class="gs_r gs_or gs_scl"]'); diff --git a/bridges/ItakuBridge.php b/bridges/ItakuBridge.php index b231b14336b..22d7529fc63 100644 --- a/bridges/ItakuBridge.php +++ b/bridges/ItakuBridge.php @@ -438,8 +438,7 @@ private function getFeedData(array $opt, $ownerID = null) private function getOwnerID($username) { $url = self::URI . "/api/user_profiles/{$username}/?format=json"; - $data = $this->getData($url, true, true) - or returnServerError("Could not load $url"); + $data = $this->getData($url, true, true); return $data['owner']; } @@ -451,8 +450,7 @@ private function getPost($id, array $metadata = null) } $uri = self::URI . '/posts/' . $id; $url = self::URI . '/api/posts/' . $id . '/?format=json'; - $data = $metadata ?? $this->getData($url, true, true) - or returnServerError("Could not load $url"); + $data = $metadata ?? $this->getData($url, true, true); $content_str = nl2br($data['content']); $content = "

{$content_str}


"; //TODO: Add link and itaku user mention detection and convert into links. @@ -497,8 +495,7 @@ private function getPost($id, array $metadata = null) $content .= "{$title}
"; if ($media['is_thumbnail_for_video']) { $url = self::URI . '/api/galleries/images/' . $media['id'] . '/?format=json'; - $media_data = $this->getData($url, true, true) - or returnServerError("Could not load $url"); + $media_data = $this->getData($url, true, true); $content .= "