refactor: remove dead code (#4385)

This commit is contained in:
Dag 2025-01-03 05:04:49 +01:00 committed by GitHub
parent 7c6d4a932c
commit c44a76ff17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 52 additions and 106 deletions

View file

@ -32,8 +32,7 @@ class AirBreizhBridge extends BridgeAbstract
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 = [];

View file

@ -146,7 +146,7 @@ EOT;
{
$uri = $this->getURI();
return getSimpleHTMLDOM($uri) ?: returnServerError('Could not request Amazon.');
return getSimpleHTMLDOM($uri);
}
private function scrapePriceFromMetrics($html)

View file

@ -105,8 +105,7 @@ class AssociatedPressNewsBridge extends BridgeAbstract
private function collectCardData()
{
$json = getContents($this->getTagURI())
or returnServerError('Could not request: ' . $this->getTagURI());
$json = getContents($this->getTagURI());
$tagContents = json_decode($json, true);

View file

@ -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) {

View file

@ -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 @@ class BandcampDailyBridge extends BridgeAbstract
$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;

View file

@ -26,8 +26,7 @@ TMPL;
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 @@ URI;
$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.');

View file

@ -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;

View file

@ -53,8 +53,7 @@ class DacksnackBridge extends BridgeAbstract
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 @@ class DacksnackBridge extends BridgeAbstract
$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');

View file

@ -18,8 +18,7 @@ class DagensNyheterDirektBridge extends BridgeAbstract
{
$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');

View file

@ -60,7 +60,7 @@ class FindACrewBridge extends BridgeAbstract
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;

View file

@ -34,8 +34,7 @@ class FurAffinityUserBridge extends BridgeAbstract
$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) {

View file

@ -155,8 +155,7 @@ class GiteaBridge extends BridgeAbstract
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 @@ class GiteaBridge extends BridgeAbstract
];
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 @@ class GiteaBridge extends BridgeAbstract
];
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);

View file

@ -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')) &&

View file

@ -171,8 +171,7 @@ class GogsBridge extends BridgeAbstract
];
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);

View file

@ -109,7 +109,7 @@ class GoogleScholarBridge extends BridgeAbstract
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 @@ class GoogleScholarBridge extends BridgeAbstract
$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"]');

View file

@ -438,8 +438,7 @@ class ItakuBridge extends BridgeAbstract
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 @@ class ItakuBridge extends BridgeAbstract
}
$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 = "<p>{$content_str}</p><br/>"; //TODO: Add link and itaku user mention detection and convert into links.
@ -497,8 +495,7 @@ class ItakuBridge extends BridgeAbstract
$content .= "<a href=\"{$url}\"><b>{$title}</b></a><br/>";
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 .= "<video controls src=\"{$media_data['video']['video']}\" poster=\"{$media['image_xl']}\"/>";
} else {
$content .= "<a href=\"{$url}\"><img src=\"{$src}\"></a>";
@ -523,11 +520,11 @@ class ItakuBridge extends BridgeAbstract
$url = self::URI . '/api/commissions/' . $id . '/?format=json';
$uri = self::URI . '/commissions/' . $id;
$data = $metadata ?? $this->getData($url, true, true)
or returnServerError("Could not load $url");
$data = $metadata ?? $this->getData($url, true, true);
$content_str = nl2br($data['description']);
$content = "<p>{$content_str}</p><br>"; //TODO: Add link and itaku user mention detection and convert into links.
$content = "<p>{$content_str}</p><br>";
//TODO: Add link and itaku user mention detection and convert into links.
if (array_key_exists('tags', $data) && count($data['tags']) > 0) {
// $content .= "🏷 Tag(s): ";
@ -570,8 +567,7 @@ class ItakuBridge extends BridgeAbstract
$content .= "<a href=\"{$uri}\"><b>{$data['thumbnail_detail']['title']}</b></a><br/>";
if ($data['thumbnail_detail']['is_thumbnail_for_video']) {
$url = self::URI . '/api/galleries/images/' . $data['thumbnail_detail']['id'] . '/?format=json';
$media_data = $this->getData($url, true, true)
or returnServerError("Could not load $url");
$media_data = $this->getData($url, true, true);
$content .= "<video controls src=\"{$media_data['video']['video']}\" poster=\"{$data['thumbnail_detail']['image_lg']}\"/>";
} else {
$content .= "<a href=\"{$uri}\"><img src=\"{$data['thumbnail_detail']['image_lg']}\"></a>";
@ -595,8 +591,7 @@ class ItakuBridge extends BridgeAbstract
{
$uri = self::URI . '/images/' . $id;
$url = self::URI . '/api/galleries/images/' . $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['description']);
$content = "<p>{$content_str}</p><br/>"; //TODO: Add link and itaku user mention detection and convert into links.
@ -640,8 +635,7 @@ class ItakuBridge extends BridgeAbstract
if (array_key_exists('is_thumbnail_for_video', $data)) {
$url = self::URI . '/api/galleries/images/' . $data['id'] . '/?format=json';
$media_data = $this->getData($url, true, true)
or returnServerError("Could not load $url");
$media_data = $this->getData($url, true, true);
$content .= "<video controls src=\"{$media_data['video']['video']}\" poster=\"{$data['image_xl']}\"/>";
} else {
if (array_key_exists('video', $data) && is_null($data['video'])) {

View file

@ -9,8 +9,7 @@ class JohannesBlickBridge extends BridgeAbstract
public function collectData()
{
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request: ' . self::URI);
$html = getSimpleHTMLDOM(self::URI);
$html = defaultLinkTo($html, self::URI);
foreach ($html->find('ul[class=easyfolderlisting] > li > a') as $index => $a) {

View file

@ -181,8 +181,7 @@ class JustETFBridge extends BridgeAbstract
if ($this->getInput('full')) {
$uri = $this->extractNewsUri($article);
$html = getSimpleHTMLDOMCached($uri)
or returnServerError('Failed loading full article from ' . $uri);
$html = getSimpleHTMLDOMCached($uri);
$fullArticle = $html->find('div.article', 0)
or returnServerError('No content found! Layout might have changed!');

View file

@ -64,10 +64,6 @@ Returns feeds for bug comments';
DEFAULT_SPAN_TEXT
);
if ($html === false) {
returnServerError('Failed to load page!');
}
$html = defaultLinkTo($html, self::URI);
// Store header information into private members

View file

@ -11,7 +11,7 @@ class LaTeX3ProjectNewslettersBridge extends BridgeAbstract
public function collectData()
{
$html = getSimpleHTMLDOM(static::URI . '/news/latex3-news/') or returnServerError('No contents received!');
$html = getSimpleHTMLDOM(static::URI . '/news/latex3-news/');
$newsContainer = $html->find('article tbody', 0);
foreach ($newsContainer->find('tr') as $row) {

View file

@ -64,10 +64,6 @@ Returns feeds for bug comments';
DEFAULT_SPAN_TEXT
);
if ($html === false) {
returnServerError('Failed to load page!');
}
// Fix relative URLs
defaultLinkTo($html, self::URI);

View file

@ -25,8 +25,7 @@ class OMonlineBridge extends BridgeAbstract
$url = sprintf('%s', self::URI);
}
$html = getSimpleHTMLDOM($url)
or returnServerError('Could not request: ' . $url);
$html = getSimpleHTMLDOM($url);
$html = defaultLinkTo($html, $url);
@ -35,8 +34,7 @@ class OMonlineBridge extends BridgeAbstract
$articlePath = $a->href;
$articlePageHtml = getSimpleHTMLDOMCached($articlePath, self::CACHE_TIMEOUT)
or returnServerError('Could not request: ' . $articlePath);
$articlePageHtml = getSimpleHTMLDOMCached($articlePath, self::CACHE_TIMEOUT);
$articlePageHtml = defaultLinkTo($articlePageHtml, self::URI);

View file

@ -49,8 +49,7 @@ class SchweinfurtBuergerinformationenBridge extends BridgeAbstract
private function getArticleIDsFromPage($page)
{
$url = sprintf(self::URI . '?art_pager=%d', $page);
$html = getSimpleHTMLDOMCached($url, self::INDEX_CACHE_TIMEOUT)
or returnServerError('Could not retrieve ' . $url);
$html = getSimpleHTMLDOMCached($url, self::INDEX_CACHE_TIMEOUT);
$articles = $html->find('div.artikel-uebersicht');
$articleIDs = [];
@ -70,8 +69,7 @@ class SchweinfurtBuergerinformationenBridge extends BridgeAbstract
private function generateItemFromArticle($id)
{
$url = sprintf(self::ARTICLE_URI, $id);
$html = getSimpleHTMLDOMCached($url, self::ARTICLE_CACHE_TIMEOUT)
or returnServerError('Could not retrieve ' . $url);
$html = getSimpleHTMLDOMCached($url, self::ARTICLE_CACHE_TIMEOUT);
$div = $html->find('div#artikel-detail', 0);
$divContent = $div->find('.c-content', 0);

View file

@ -633,8 +633,7 @@ class SkimfeedBridge extends BridgeAbstract
$author = '<a href="' . $anchor->href . '">' . trim($anchor->plaintext) . '</a>';
$uri = $anchor->href;
$box_html = getSimpleHTMLDOM($uri)
or returnServerError('Could not load custom feed!');
$box_html = getSimpleHTMLDOM($uri);
$this->extractFeed($box_html, $author);
}
@ -665,8 +664,7 @@ class SkimfeedBridge extends BridgeAbstract
*/
private function exportBoxChannels()
{
$html = getSimpleHTMLDOMCached(static::URI)
or returnServerError('No contents received from Skimfeed!');
$html = getSimpleHTMLDOMCached(static::URI);
if (!$this->isCompatible($html)) {
returnServerError('Skimfeed version is not compatible!');
@ -722,8 +720,7 @@ EOD;
*/
private function exportTechChannels()
{
$html = getSimpleHTMLDOMCached(static::URI)
or returnServerError('No contents received from Skimfeed!');
$html = getSimpleHTMLDOMCached(static::URI);
if (!$this->isCompatible($html)) {
returnServerError('Skimfeed version is not compatible!');
@ -759,8 +756,7 @@ EOD;
$message .= "\t\t'{$title}' => array(\n";
$channel_html = getSimpleHTMLDOMCached(static::URI . $uri)
or returnServerError('Could not load tech channel ' . $channel->plaintext . '!');
$channel_html = getSimpleHTMLDOMCached(static::URI . $uri);
$boxes = $channel_html->find('#boxx .boxes')
or returnServerError('Could not find boxes!');

View file

@ -30,8 +30,7 @@ class StanfordSIRbookreviewBridge extends BridgeAbstract
break;
}
$html = getSimpleHTMLDOM($url)
or returnServerError('Failed loading content!');
$html = getSimpleHTMLDOM($url);
foreach ($html->find('article') as $element) {
$item = [];
$item['title'] = $element->find('div > h4 > a', 0)->plaintext;

View file

@ -65,7 +65,7 @@ class StockFilingsBridge extends FeedExpander
{
$uri = $this->getSearchUrl();
return getSimpleHTMLDOM($uri) ?: returnServerError('Could not request SEC.');
return getSimpleHTMLDOM($uri);
}
/**

View file

@ -25,9 +25,6 @@ class StorytelBridge extends BridgeAbstract
}
$html = getSimpleHTMLDOM($url);
if (!$html) {
returnServerError('Unable to fetch Storytel list');
}
foreach ($html->find('li.sc-4615116a-1') as $element) {
$item = [];

View file

@ -36,7 +36,7 @@ class TapasBridge extends FeedExpander
$this->id = $this->getInput('title');
}
if ($this->getInput('force_title') || !$this->id) {
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request ' . $this->getURI());
$html = getSimpleHTMLDOM($this->getURI());
$this->id = $html->find('meta[property$=":url"]', 0)->content;
$this->id = str_ireplace(['tapastic://series/', '/info'], '', $this->id);
}

View file

@ -56,8 +56,7 @@ class TestFaktaBridge extends BridgeAbstract
public function collectData()
{
$NEWSURL = self::URI . '/sv';
$html = getSimpleHTMLDOMCached($NEWSURL, 18000) or
returnServerError('Could not request: ' . $NEWSURL);
$html = getSimpleHTMLDOMCached($NEWSURL, 18000);
foreach ($html->find('.row-container') as $element) {
// Debug::log($element);
@ -68,8 +67,7 @@ class TestFaktaBridge extends BridgeAbstract
$figure = $element->find('img', 0);
$preamble = trim($element->find('.text', 0)->plaintext);
$article_html = getSimpleHTMLDOMCached($url, 18000) or
returnServerError('Could not request: ' . $url);
$article_html = getSimpleHTMLDOMCached($url, 18000);
$article_content = $article_html->find('div.content', 0);
$article_text = $article_html->find('article', 0);

View file

@ -10,8 +10,7 @@ class UsesTechbridge extends BridgeAbstract
public function collectData()
{
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not request: ' . self::URI);
$html = getSimpleHTMLDOM(self::URI);
foreach ($html->find('div[class=PersonInner]') as $index => $a) {
$item = []; // Create an empty item

View file

@ -16,8 +16,7 @@ class VproTegenlichtBridge extends BridgeAbstract
public function collectData()
{
$url = sprintf('https://www.vpro.nl/programmas/tegenlicht/lees/artikelen.html');
$dom = getSimpleHTMLDOM($url)
or returnServerError('No contents received!');
$dom = getSimpleHTMLDOM($url);
$dom = $dom->find('ul#browsable-news-overview', 0);
$dom = defaultLinkTo($dom, $this->getURI());
foreach ($dom->find('li') as $article) {

View file

@ -105,10 +105,6 @@ class WikipediaBridge extends BridgeAbstract
// This will automatically send us to the correct main page in any language (try it!)
$html = getSimpleHTMLDOM($this->getURI() . '/wiki');
if (!$html) {
returnServerError('Could not load site: ' . $this->getURI() . '!');
}
/*
* Now read content depending on the language (make sure to create one function per language!)
* We build the function name automatically, just make sure you create a private function ending

View file

@ -304,11 +304,9 @@ class XenForoBridge extends BridgeAbstract
// We can optimize performance by caching all but the last page
if ($page != $lastpage) {
$html = getSimpleHTMLDOMCached($pageurl)
or returnServerError('Error loading contents from ' . $pageurl . '!');
$html = getSimpleHTMLDOMCached($pageurl);
} else {
$html = getSimpleHTMLDOM($pageurl)
or returnServerError('Error loading contents from ' . $pageurl . '!');
$html = getSimpleHTMLDOM($pageurl);
}
$html = defaultLinkTo($html, $hosturl);
@ -347,11 +345,9 @@ class XenForoBridge extends BridgeAbstract
// We can optimize performance by caching all but the last page
if ($page != $lastpage) {
$html = getSimpleHTMLDOMCached($pageurl)
or returnServerError('Error loading contents from ' . $pageurl . '!');
$html = getSimpleHTMLDOMCached($pageurl);
} else {
$html = getSimpleHTMLDOM($pageurl)
or returnServerError('Error loading contents from ' . $pageurl . '!');
$html = getSimpleHTMLDOM($pageurl);
}
$html = defaultLinkTo($html, $hosturl);