Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove dead code #4385

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bridges/AirBreizhBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion bridges/AmazonPriceTrackerBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions bridges/AssociatedPressNewsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion bridges/BAEBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions bridges/BandcampDailyBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions bridges/BundestagParteispendenBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.');
Expand Down
2 changes: 1 addition & 1 deletion bridges/CrewbayBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions bridges/DacksnackBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
Expand Down
3 changes: 1 addition & 2 deletions bridges/DagensNyheterDirektBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion bridges/FindACrewBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions bridges/FurAffinityUserBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 3 additions & 6 deletions bridges/GiteaBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion bridges/GlowficBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) &&
Expand Down
3 changes: 1 addition & 2 deletions bridges/GogsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions bridges/GoogleScholarBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"]');

Expand Down Expand Up @@ -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"]');

Expand Down
24 changes: 9 additions & 15 deletions bridges/ItakuBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand All @@ -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 = "<p>{$content_str}</p><br/>"; //TODO: Add link and itaku user mention detection and convert into links.
Expand Down Expand Up @@ -497,8 +495,7 @@ private function getPost($id, array $metadata = null)
$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>";
Expand All @@ -523,11 +520,11 @@ private function getCommission($id, array $metadata = null)
$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): ";
Expand Down Expand Up @@ -570,8 +567,7 @@ private function getCommission($id, array $metadata = null)
$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>";
Expand All @@ -595,8 +591,7 @@ private function getImage($id /* array $metadata = null */) //$metadata disabled
{
$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.
Expand Down Expand Up @@ -640,8 +635,7 @@ private function getImage($id /* array $metadata = null */) //$metadata disabled

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'])) {
Expand Down
3 changes: 1 addition & 2 deletions bridges/JohannesBlickBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions bridges/JustETFBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ private function collectNews($html)
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!');
Expand Down
4 changes: 0 additions & 4 deletions bridges/KernelBugTrackerBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public function collectData()
DEFAULT_SPAN_TEXT
);

if ($html === false) {
returnServerError('Failed to load page!');
}

$html = defaultLinkTo($html, self::URI);

// Store header information into private members
Expand Down
2 changes: 1 addition & 1 deletion bridges/LaTeX3ProjectNewslettersBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions bridges/MozillaBugTrackerBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public function collectData()
DEFAULT_SPAN_TEXT
);

if ($html === false) {
returnServerError('Failed to load page!');
}

// Fix relative URLs
defaultLinkTo($html, self::URI);

Expand Down
6 changes: 2 additions & 4 deletions bridges/OMonlineBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public function collectData()
$url = sprintf('%s', self::URI);
}

$html = getSimpleHTMLDOM($url)
or returnServerError('Could not request: ' . $url);
$html = getSimpleHTMLDOM($url);

$html = defaultLinkTo($html, $url);

Expand All @@ -35,8 +34,7 @@ public function collectData()

$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);

Expand Down
6 changes: 2 additions & 4 deletions bridges/SchweinfurtBuergerinformationenBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public function collectData()
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 = [];
Expand All @@ -70,8 +69,7 @@ private function getArticleIDsFromPage($page)
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);
Expand Down
Loading
Loading