mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-10 04:44:56 +02:00
refactor: rename functions (#4655)
returnClientError => throwClientException returnServerError => throwServerException New convenience function: throwRateLimitException Old functions are kept but deprecated.
This commit is contained in:
parent
b39964cee3
commit
f11571ae78
90 changed files with 279 additions and 255 deletions
|
@ -71,7 +71,7 @@ class ARDAudiothekBridge extends BridgeAbstract
|
||||||
|
|
||||||
$pathComponents = explode('/', $path);
|
$pathComponents = explode('/', $path);
|
||||||
if (empty($pathComponents)) {
|
if (empty($pathComponents)) {
|
||||||
returnClientError('Path may not be empty');
|
throwClientException('Path may not be empty');
|
||||||
}
|
}
|
||||||
if (count($pathComponents) < 2) {
|
if (count($pathComponents) < 2) {
|
||||||
$showID = $pathComponents[0];
|
$showID = $pathComponents[0];
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ARDMediathekBridge extends BridgeAbstract
|
||||||
|
|
||||||
$pathComponents = explode('/', $this->getInput('path'));
|
$pathComponents = explode('/', $this->getInput('path'));
|
||||||
if (empty($pathComponents)) {
|
if (empty($pathComponents)) {
|
||||||
returnClientError('Path may not be empty');
|
throwClientException('Path may not be empty');
|
||||||
}
|
}
|
||||||
if (count($pathComponents) < 2) {
|
if (count($pathComponents) < 2) {
|
||||||
$showID = $pathComponents[0];
|
$showID = $pathComponents[0];
|
||||||
|
|
|
@ -57,7 +57,7 @@ class AllocineFRBridge extends BridgeAbstract
|
||||||
if (array_key_exists($category, $categories)) {
|
if (array_key_exists($category, $categories)) {
|
||||||
return static::URI . $this->getLastSeasonURI($categories[$category]);
|
return static::URI . $this->getLastSeasonURI($categories[$category]);
|
||||||
} else {
|
} else {
|
||||||
returnClientError('Emission inconnue');
|
throwClientException('Emission inconnue');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ class AnidexBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($results) && empty($this->getInput('q'))) {
|
if (empty($results) && empty($this->getInput('q'))) {
|
||||||
returnServerError('No results from Anidex: ' . $search_url);
|
throwServerException('No results from Anidex: ' . $search_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Process each item individually
|
//Process each item individually
|
||||||
|
|
|
@ -71,7 +71,7 @@ class AppleMusicBridge extends BridgeAbstract
|
||||||
$result = $json->results;
|
$result = $json->results;
|
||||||
|
|
||||||
if (!is_array($result) || count($result) == 0) {
|
if (!is_array($result) || count($result) == 0) {
|
||||||
returnServerError('There is no artist with id "' . $this->getInput('artist') . '".');
|
throwServerException('There is no artist with id "' . $this->getInput('artist') . '".');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -66,10 +66,10 @@ class AssociatedPressNewsBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
switch ($this->getInput('topic')) {
|
switch ($this->getInput('topic')) {
|
||||||
case 'Podcasts':
|
case 'Podcasts':
|
||||||
returnClientError('Podcasts topic feed is not supported');
|
throwClientException('Podcasts topic feed is not supported');
|
||||||
break;
|
break;
|
||||||
case 'PressReleases':
|
case 'PressReleases':
|
||||||
returnClientError('PressReleases topic feed is not supported');
|
throwClientException('PressReleases topic feed is not supported');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->collectCardData();
|
$this->collectCardData();
|
||||||
|
@ -110,7 +110,7 @@ class AssociatedPressNewsBridge extends BridgeAbstract
|
||||||
$tagContents = json_decode($json, true);
|
$tagContents = json_decode($json, true);
|
||||||
|
|
||||||
if (empty($tagContents['tagObjs'])) {
|
if (empty($tagContents['tagObjs'])) {
|
||||||
returnClientError('Topic not found: ' . $this->getInput('topic'));
|
throwClientException('Topic not found: ' . $this->getInput('topic'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->feedName = $tagContents['tagObjs'][0]['name'];
|
$this->feedName = $tagContents['tagObjs'][0]['name'];
|
||||||
|
|
|
@ -94,7 +94,7 @@ class BakaUpdatesMangaReleasesBridge extends BridgeAbstract
|
||||||
// content is an unstructured pile of divs, ugly to parse
|
// content is an unstructured pile of divs, ugly to parse
|
||||||
$cols = $html->find('div#main_content div.row > div.text');
|
$cols = $html->find('div#main_content div.row > div.text');
|
||||||
if (!$cols) {
|
if (!$cols) {
|
||||||
returnServerError('No releases');
|
throwServerException('No releases');
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = array_slice(
|
$rows = array_slice(
|
||||||
|
|
|
@ -123,7 +123,7 @@ class BandcampBridge extends BridgeAbstract
|
||||||
$json = json_decode($content);
|
$json = json_decode($content);
|
||||||
|
|
||||||
if ($json->ok !== true) {
|
if ($json->ok !== true) {
|
||||||
returnServerError('Invalid response');
|
throwServerException('Invalid response');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($json->items as $entry) {
|
foreach ($json->items as $entry) {
|
||||||
|
@ -165,7 +165,7 @@ class BandcampBridge extends BridgeAbstract
|
||||||
|
|
||||||
$regex = '/band_id=(\d+)/';
|
$regex = '/band_id=(\d+)/';
|
||||||
if (preg_match($regex, $html, $matches) == false) {
|
if (preg_match($regex, $html, $matches) == false) {
|
||||||
returnServerError('Unable to find band ID on: ' . $this->getURI());
|
throwServerException('Unable to find band ID on: ' . $this->getURI());
|
||||||
}
|
}
|
||||||
$band_id = $matches[1];
|
$band_id = $matches[1];
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ class BandcampBridge extends BridgeAbstract
|
||||||
case 'By album':
|
case 'By album':
|
||||||
$regex = '/album=(\d+)/';
|
$regex = '/album=(\d+)/';
|
||||||
if (preg_match($regex, $html, $matches) == false) {
|
if (preg_match($regex, $html, $matches) == false) {
|
||||||
returnServerError('Unable to find album ID on: ' . $this->getURI());
|
throwServerException('Unable to find album ID on: ' . $this->getURI());
|
||||||
}
|
}
|
||||||
$album_id = $matches[1];
|
$album_id = $matches[1];
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ class BlueskyBridge extends BridgeAbstract
|
||||||
//valid DID
|
//valid DID
|
||||||
$did = $user_id;
|
$did = $user_id;
|
||||||
} else {
|
} else {
|
||||||
returnClientError('Invalid ATproto handle or DID provided.');
|
throwClientException('Invalid ATproto handle or DID provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$filter = $this->getInput('feed_filter') ?: 'posts_and_author_threads';
|
$filter = $this->getInput('feed_filter') ?: 'posts_and_author_threads';
|
||||||
|
|
|
@ -98,7 +98,7 @@ class BugzillaBridge extends BridgeAbstract
|
||||||
|
|
||||||
// Array of comments is here
|
// Array of comments is here
|
||||||
if (!isset($json['bugs'][$this->bugid]['comments'])) {
|
if (!isset($json['bugs'][$this->bugid]['comments'])) {
|
||||||
returnClientError('Cannot find REST endpoint');
|
throwClientException('Cannot find REST endpoint');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($json['bugs'][$this->bugid]['comments'] as $comment) {
|
foreach ($json['bugs'][$this->bugid]['comments'] as $comment) {
|
||||||
|
@ -131,7 +131,7 @@ class BugzillaBridge extends BridgeAbstract
|
||||||
|
|
||||||
// Array of changesets which contain an array of changes
|
// Array of changesets which contain an array of changes
|
||||||
if (!isset($json['bugs']['0']['history'])) {
|
if (!isset($json['bugs']['0']['history'])) {
|
||||||
returnClientError('Cannot find REST endpoint');
|
throwClientException('Cannot find REST endpoint');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($json['bugs']['0']['history'] as $changeset) {
|
foreach ($json['bugs']['0']['history'] as $changeset) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ URI;
|
||||||
|
|
||||||
// Build the URL from the first anchor element. The list is sorted by year, descending, so the first element is the current year.
|
// 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)
|
$firstAnchor = $html->find('a', 0)
|
||||||
or returnServerError('Could not find the proper HTML element.');
|
or throwServerException('Could not find the proper HTML element.');
|
||||||
|
|
||||||
$url = $firstAnchor->href;
|
$url = $firstAnchor->href;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ URI;
|
||||||
$html = getSimpleHTMLDOMCached($url, self::CACHE_TIMEOUT);
|
$html = getSimpleHTMLDOMCached($url, self::CACHE_TIMEOUT);
|
||||||
|
|
||||||
$rows = $html->find('table.table > tbody > tr')
|
$rows = $html->find('table.table > tbody > tr')
|
||||||
or returnServerError('Could not find the proper HTML elements.');
|
or throwServerException('Could not find the proper HTML elements.');
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$item = $this->generateItemFromRow($row);
|
$item = $this->generateItemFromRow($row);
|
||||||
|
|
|
@ -50,7 +50,7 @@ class CNETBridge extends SitemapBridge
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($links)) {
|
if (empty($links)) {
|
||||||
returnClientError('Failed to retrieve article list');
|
throwClientException('Failed to retrieve article list');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($links as $article_uri) {
|
foreach ($links as $article_uri) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ class CVEDetailsBridge extends BridgeAbstract
|
||||||
|
|
||||||
$vendor = $html->find('#contentdiv h1 > a', 0);
|
$vendor = $html->find('#contentdiv h1 > a', 0);
|
||||||
if ($vendor == null) {
|
if ($vendor == null) {
|
||||||
returnServerError('Invalid Vendor ID ' . $this->getInput('vendor_id') . ' or Product ID ' . $this->getInput('product_id'));
|
throwServerException('Invalid Vendor ID ' . $this->getInput('vendor_id') . ' or Product ID ' . $this->getInput('product_id'));
|
||||||
}
|
}
|
||||||
$this->vendor = $vendor->innertext;
|
$this->vendor = $vendor->innertext;
|
||||||
|
|
||||||
|
|
|
@ -72,14 +72,14 @@ class CachetBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
$ping = getContents(urljoin($this->getURI(), '/api/v1/ping'));
|
$ping = getContents(urljoin($this->getURI(), '/api/v1/ping'));
|
||||||
if (!$this->validatePing($ping)) {
|
if (!$this->validatePing($ping)) {
|
||||||
returnClientError('Provided URI is invalid!');
|
throwClientException('Provided URI is invalid!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = urljoin($this->getURI(), '/api/v1/incidents?sort=id&order=desc');
|
$url = urljoin($this->getURI(), '/api/v1/incidents?sort=id&order=desc');
|
||||||
$incidents = getContents($url);
|
$incidents = getContents($url);
|
||||||
$incidents = json_decode($incidents);
|
$incidents = json_decode($incidents);
|
||||||
if ($incidents === null) {
|
if ($incidents === null) {
|
||||||
returnClientError('/api/v1/incidents returned no valid json');
|
throwClientException('/api/v1/incidents returned no valid json');
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($incidents->data, function ($a, $b) {
|
usort($incidents->data, function ($a, $b) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ class CastorusBridge extends BridgeAbstract
|
||||||
$title = $activity->find('a', 0);
|
$title = $activity->find('a', 0);
|
||||||
|
|
||||||
if (!$title) {
|
if (!$title) {
|
||||||
returnServerError('Cannot find title!');
|
throwServerException('Cannot find title!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim($title->plaintext);
|
return trim($title->plaintext);
|
||||||
|
@ -48,7 +48,7 @@ class CastorusBridge extends BridgeAbstract
|
||||||
$url = $activity->find('a', 0);
|
$url = $activity->find('a', 0);
|
||||||
|
|
||||||
if (!$url) {
|
if (!$url) {
|
||||||
returnServerError('Cannot find url!');
|
throwServerException('Cannot find url!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::URI . $url->href;
|
return self::URI . $url->href;
|
||||||
|
@ -62,7 +62,7 @@ class CastorusBridge extends BridgeAbstract
|
||||||
$nodes = $activity->find('*');
|
$nodes = $activity->find('*');
|
||||||
|
|
||||||
if (!$nodes) {
|
if (!$nodes) {
|
||||||
returnServerError('Cannot find nodes!');
|
throwServerException('Cannot find nodes!');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
|
@ -78,7 +78,7 @@ class CastorusBridge extends BridgeAbstract
|
||||||
$price = $activity->find('span', 1);
|
$price = $activity->find('span', 1);
|
||||||
|
|
||||||
if (!$price) {
|
if (!$price) {
|
||||||
returnServerError('Cannot find price!');
|
throwServerException('Cannot find price!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $price->innertext;
|
return $price->innertext;
|
||||||
|
@ -92,13 +92,13 @@ class CastorusBridge extends BridgeAbstract
|
||||||
$html = getSimpleHTMLDOM(self::URI);
|
$html = getSimpleHTMLDOM(self::URI);
|
||||||
|
|
||||||
if (!$html) {
|
if (!$html) {
|
||||||
returnServerError('Could not load data from ' . self::URI . '!');
|
throwServerException('Could not load data from ' . self::URI . '!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$activities = $html->find('div#activite > li');
|
$activities = $html->find('div#activite > li');
|
||||||
|
|
||||||
if (!$activities) {
|
if (!$activities) {
|
||||||
returnServerError('Failed to find activities!');
|
throwServerException('Failed to find activities!');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($activities as $activity) {
|
foreach ($activities as $activity) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ class CeskaTelevizeBridge extends BridgeAbstract
|
||||||
|
|
||||||
$validUrl = '/^(https:\/\/www\.ceskatelevize\.cz\/porady\/\d+-[a-z0-9-]+\/)(bonus\/)?$/';
|
$validUrl = '/^(https:\/\/www\.ceskatelevize\.cz\/porady\/\d+-[a-z0-9-]+\/)(bonus\/)?$/';
|
||||||
if (!preg_match($validUrl, $url, $match)) {
|
if (!preg_match($validUrl, $url, $match)) {
|
||||||
returnServerError('Invalid url');
|
throwServerException('Invalid url');
|
||||||
}
|
}
|
||||||
|
|
||||||
$category = $match[4] ?? 'nove';
|
$category = $match[4] ?? 'nove';
|
||||||
|
@ -63,7 +63,7 @@ class CeskaTelevizeBridge extends BridgeAbstract
|
||||||
} elseif (strpos($string, 'včera') !== false) {
|
} elseif (strpos($string, 'včera') !== false) {
|
||||||
return strtotime('yesterday');
|
return strtotime('yesterday');
|
||||||
} elseif (!preg_match('/(\d+).(\d+).((\d+))?/', $string, $match)) {
|
} elseif (!preg_match('/(\d+).(\d+).((\d+))?/', $string, $match)) {
|
||||||
returnServerError('Could not get date from Česká televize string');
|
throwServerException('Could not get date from Česká televize string');
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = sprintf('%04d-%02d-%02d', $match[3] ?? date('Y'), $match[2], $match[1]);
|
$date = sprintf('%04d-%02d-%02d', $match[3] ?? date('Y'), $match[2], $match[1]);
|
||||||
|
|
|
@ -217,7 +217,7 @@ class CssSelectorBridge extends BridgeAbstract
|
||||||
$links = $page->find($url_selector);
|
$links = $page->find($url_selector);
|
||||||
|
|
||||||
if (empty($links)) {
|
if (empty($links)) {
|
||||||
returnClientError('No results for URL selector');
|
throwClientException('No results for URL selector');
|
||||||
}
|
}
|
||||||
|
|
||||||
$link_to_item = [];
|
$link_to_item = [];
|
||||||
|
@ -245,13 +245,13 @@ class CssSelectorBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($link_to_item)) {
|
if (empty($link_to_item)) {
|
||||||
returnClientError('The provided URL selector matches some elements, but they do not contain links.');
|
throwClientException('The provided URL selector matches some elements, but they do not contain links.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$links = $this->filterUrlList(array_keys($link_to_item), $url_pattern, $limit);
|
$links = $this->filterUrlList(array_keys($link_to_item), $url_pattern, $limit);
|
||||||
|
|
||||||
if (empty($links)) {
|
if (empty($links)) {
|
||||||
returnClientError('No results for URL pattern');
|
throwClientException('No results for URL pattern');
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
|
@ -274,7 +274,7 @@ class CssSelectorBridge extends BridgeAbstract
|
||||||
protected function expandEntryWithSelector($entry_url, $content_selector, $content_cleanup = null, $title_cleanup = null, $title_default = null)
|
protected function expandEntryWithSelector($entry_url, $content_selector, $content_cleanup = null, $title_cleanup = null, $title_default = null)
|
||||||
{
|
{
|
||||||
if (empty($content_selector)) {
|
if (empty($content_selector)) {
|
||||||
returnClientError('Please specify a content selector');
|
throwClientException('Please specify a content selector');
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry_html = getSimpleHTMLDOMCached($entry_url);
|
$entry_html = getSimpleHTMLDOMCached($entry_url);
|
||||||
|
|
|
@ -187,7 +187,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||||
// Fetch the elements from the article pages.
|
// Fetch the elements from the article pages.
|
||||||
if ($use_article_pages) {
|
if ($use_article_pages) {
|
||||||
if (empty($article_page_content_selector)) {
|
if (empty($article_page_content_selector)) {
|
||||||
returnClientError('`Article selector` is required when `Load article page` is enabled');
|
throwClientException('`Article selector` is required when `Load article page` is enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_keys($entry_elements) as $uri) {
|
foreach (array_keys($entry_elements) as $uri) {
|
||||||
|
@ -307,7 +307,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||||
|
|
||||||
$entryElements = $page->find($entry_selector);
|
$entryElements = $page->find($entry_selector);
|
||||||
if (empty($entryElements)) {
|
if (empty($entryElements)) {
|
||||||
returnClientError('No entry elements for entry selector');
|
throwClientException('No entry elements for entry selector');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract URIs with the associated entry element
|
// Extract URIs with the associated entry element
|
||||||
|
@ -327,7 +327,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($links_with_elements)) {
|
if (empty($links_with_elements)) {
|
||||||
returnClientError('The provided URL selector matches some elements, but they do not
|
throwClientException('The provided URL selector matches some elements, but they do not
|
||||||
contain links.');
|
contain links.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||||
$filtered_urls = $this->filterUrlList(array_keys($links_with_elements), $url_pattern, $limit);
|
$filtered_urls = $this->filterUrlList(array_keys($links_with_elements), $url_pattern, $limit);
|
||||||
|
|
||||||
if (empty($filtered_urls)) {
|
if (empty($filtered_urls)) {
|
||||||
returnClientError('No results for URL pattern');
|
throwClientException('No results for URL pattern');
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
|
@ -359,7 +359,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||||
$article_content = $entry_html->find($content_selector, 0);
|
$article_content = $entry_html->find($content_selector, 0);
|
||||||
|
|
||||||
if (is_null($article_content)) {
|
if (is_null($article_content)) {
|
||||||
returnClientError('Could not get article content at URL: ' . $entry_url);
|
throwClientException('Could not get article content at URL: ' . $entry_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
$article_content = defaultLinkTo($article_content, $entry_url);
|
$article_content = defaultLinkTo($article_content, $entry_url);
|
||||||
|
@ -370,7 +370,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
$date = date_parse_from_format($format, $timeStr);
|
$date = date_parse_from_format($format, $timeStr);
|
||||||
if ($date['error_count'] != 0) {
|
if ($date['error_count'] != 0) {
|
||||||
returnClientError('Error while parsing time string');
|
throwClientException('Error while parsing time string');
|
||||||
}
|
}
|
||||||
|
|
||||||
$timestamp = mktime(
|
$timestamp = mktime(
|
||||||
|
@ -383,7 +383,7 @@ class CssSelectorComplexBridge extends BridgeAbstract
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($timestamp == false) {
|
if ($timestamp == false) {
|
||||||
returnClientError('Error while creating timestamp');
|
throwClientException('Error while creating timestamp');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $timestamp;
|
return $timestamp;
|
||||||
|
|
|
@ -75,7 +75,7 @@ apple-icon-5c6fa9f2bce280428589c6195b7f1924206a53b782b371cfe2d02da932c8c173.png'
|
||||||
$html = defaultLinkTo($html, static::URI);
|
$html = defaultLinkTo($html, static::URI);
|
||||||
|
|
||||||
$articles = $html->find('div.crayons-story')
|
$articles = $html->find('div.crayons-story')
|
||||||
or returnServerError('Could not find articles!');
|
or throwServerException('Could not find articles!');
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
|
|
@ -204,13 +204,13 @@ class Drive2ruBridge extends BridgeAbstract
|
||||||
break;
|
break;
|
||||||
case 'Бортжурналы (По модели или марке)':
|
case 'Бортжурналы (По модели или марке)':
|
||||||
if (!preg_match('/^https:\/\/www.drive2.ru\/experience/', $this->getInput('url'))) {
|
if (!preg_match('/^https:\/\/www.drive2.ru\/experience/', $this->getInput('url'))) {
|
||||||
returnServerError('Invalid url');
|
throwServerException('Invalid url');
|
||||||
}
|
}
|
||||||
$this->getLogbooksContent($this->getInput('url'));
|
$this->getLogbooksContent($this->getInput('url'));
|
||||||
break;
|
break;
|
||||||
case 'Личные блоги':
|
case 'Личные блоги':
|
||||||
if (!preg_match('/^[a-zA-Z0-9-]{3,16}$/', $this->getInput('username'))) {
|
if (!preg_match('/^[a-zA-Z0-9-]{3,16}$/', $this->getInput('username'))) {
|
||||||
returnServerError('Invalid username');
|
throwServerException('Invalid username');
|
||||||
}
|
}
|
||||||
$this->getUserContent('https://www.drive2.ru/users/' . $this->getInput('username'));
|
$this->getUserContent('https://www.drive2.ru/users/' . $this->getInput('username'));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -160,7 +160,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Check if page contains articles and split by class
|
// Check if page contains articles and split by class
|
||||||
$articles = $html->find('.com-news-feature-prerex') or
|
$articles = $html->find('.com-news-feature-prerex') or
|
||||||
returnServerError('No articles found! Layout might have changed!');
|
throwServerException('No articles found! Layout might have changed!');
|
||||||
|
|
||||||
// Articles loop
|
// Articles loop
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
@ -189,7 +189,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Check if page contains articles and split by class
|
// Check if page contains articles and split by class
|
||||||
$articles = $html->find('.com-news-common-prerex') or
|
$articles = $html->find('.com-news-common-prerex') or
|
||||||
returnServerError('No articles found! Layout might have changed!');
|
throwServerException('No articles found! Layout might have changed!');
|
||||||
|
|
||||||
// Articles loop
|
// Articles loop
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
@ -225,7 +225,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Check if page contains articles and split by class
|
// Check if page contains articles and split by class
|
||||||
$articles = $html->find('.com-news-common-prerex') or
|
$articles = $html->find('.com-news-common-prerex') or
|
||||||
returnServerError('No articles found! Layout might have changed!');
|
throwServerException('No articles found! Layout might have changed!');
|
||||||
|
|
||||||
// Articles loop
|
// Articles loop
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
@ -273,7 +273,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Return URI of the article
|
// Return URI of the article
|
||||||
$element = $article->find('a', 0) or
|
$element = $article->find('a', 0) or
|
||||||
returnServerError('Anchor not found!');
|
throwServerException('Anchor not found!');
|
||||||
|
|
||||||
return $element->href;
|
return $element->href;
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Check if date is set
|
// Check if date is set
|
||||||
$element = $article->find('div.com-news-common-prerex__date', 0) or
|
$element = $article->find('div.com-news-common-prerex__date', 0) or
|
||||||
returnServerError('Date not found!');
|
throwServerException('Date not found!');
|
||||||
|
|
||||||
return $element->plaintext;
|
return $element->plaintext;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract description
|
// Extract description
|
||||||
$element = $article->find('ul.ws-product-information__piece-description', 0)->find('li', 0) or
|
$element = $article->find('ul.ws-product-information__piece-description', 0)->find('li', 0) or
|
||||||
returnServerError('Description not found!');
|
throwServerException('Description not found!');
|
||||||
|
|
||||||
return $element->innertext;
|
return $element->innertext;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract description
|
// Extract description
|
||||||
$element = $article->find('div.ws-product-price-validity', 0)->find('div', 0) or
|
$element = $article->find('div.ws-product-price-validity', 0)->find('div', 0) or
|
||||||
returnServerError('Description not found!');
|
throwServerException('Description not found!');
|
||||||
|
|
||||||
return $element->innertext;
|
return $element->innertext;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract description
|
// Extract description
|
||||||
$element = $article->find('div.ws-product-price-validity', 0)->find('div', 1) or
|
$element = $article->find('div.ws-product-price-validity', 0)->find('div', 1) or
|
||||||
returnServerError('Description not found!');
|
throwServerException('Description not found!');
|
||||||
|
|
||||||
return $element->innertext;
|
return $element->innertext;
|
||||||
}
|
}
|
||||||
|
@ -454,7 +454,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract title
|
// Extract title
|
||||||
$element = $article->find('img', 0) or
|
$element = $article->find('img', 0) or
|
||||||
returnServerError('Title not found!');
|
throwServerException('Title not found!');
|
||||||
|
|
||||||
return $element->alt;
|
return $element->alt;
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,7 @@ class ElektroARGOSBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract title
|
// Extract title
|
||||||
$element = $article->find('div.com-news-common-prerex__right-box', 0)->find('h3', 0)
|
$element = $article->find('div.com-news-common-prerex__right-box', 0)->find('h3', 0)
|
||||||
or returnServerError('Title not found!');
|
or throwServerException('Title not found!');
|
||||||
|
|
||||||
return $element->plaintext;
|
return $element->plaintext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,13 +85,13 @@ class FB2Bridge extends BridgeAbstract
|
||||||
$pageInfo = $this->getPageInfos($page, $cookies);
|
$pageInfo = $this->getPageInfos($page, $cookies);
|
||||||
|
|
||||||
if ($pageInfo['userId'] === null) {
|
if ($pageInfo['userId'] === null) {
|
||||||
returnClientError(
|
throwClientException(
|
||||||
<<<EOD
|
<<<EOD
|
||||||
Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge
|
Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge
|
||||||
EOD
|
EOD
|
||||||
);
|
);
|
||||||
} elseif ($pageInfo['userId'] == -1) {
|
} elseif ($pageInfo['userId'] == -1) {
|
||||||
returnClientError(
|
throwClientException(
|
||||||
<<<EOD
|
<<<EOD
|
||||||
This page is not accessible without being logged in.
|
This page is not accessible without being logged in.
|
||||||
EOD
|
EOD
|
||||||
|
|
|
@ -155,7 +155,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
returnClientError('Unknown context: "' . $this->queriedContext . '"!');
|
throwClientException('Unknown context: "' . $this->queriedContext . '"!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit = $this->getInput('limit') ?: -1;
|
$limit = $this->getInput('limit') ?: -1;
|
||||||
|
@ -184,7 +184,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
$html = getSimpleHTMLDOM($touchURI, $header);
|
$html = getSimpleHTMLDOM($touchURI, $header);
|
||||||
|
|
||||||
if (!$this->isPublicGroup($html)) {
|
if (!$this->isPublicGroup($html)) {
|
||||||
returnClientError('This group is not public! RSS-Bridge only supports public groups!');
|
throwClientException('This group is not public! RSS-Bridge only supports public groups!');
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultLinkTo($html, substr(self::URI, 0, strlen(self::URI) - 1));
|
defaultLinkTo($html, substr(self::URI, 0, strlen(self::URI) - 1));
|
||||||
|
@ -192,7 +192,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
$this->groupName = $this->extractGroupName($html);
|
$this->groupName = $this->extractGroupName($html);
|
||||||
|
|
||||||
$posts = $html->find('div.story_body_container')
|
$posts = $html->find('div.story_body_container')
|
||||||
or returnServerError('Failed finding posts!');
|
or throwServerException('Failed finding posts!');
|
||||||
|
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
@ -224,7 +224,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
|
|
||||||
return explode('/', $urlparts['path'])[2];
|
return explode('/', $urlparts['path'])[2];
|
||||||
} elseif (strpos($group, '/') !== false) {
|
} elseif (strpos($group, '/') !== false) {
|
||||||
returnClientError('The group you provided is invalid: ' . $group);
|
throwClientException('The group you provided is invalid: ' . $group);
|
||||||
} else {
|
} else {
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
$provided_host !== $facebook_host
|
$provided_host !== $facebook_host
|
||||||
&& 'www.' . $provided_host !== $facebook_host
|
&& 'www.' . $provided_host !== $facebook_host
|
||||||
) {
|
) {
|
||||||
returnClientError('The host you provided is invalid! Received "'
|
throwClientException('The host you provided is invalid! Received "'
|
||||||
. $provided_host
|
. $provided_host
|
||||||
. '", expected "'
|
. '", expected "'
|
||||||
. $facebook_host
|
. $facebook_host
|
||||||
|
@ -268,7 +268,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
private function extractGroupName($html)
|
private function extractGroupName($html)
|
||||||
{
|
{
|
||||||
$ogtitle = $html->find('._de1', 0)
|
$ogtitle = $html->find('._de1', 0)
|
||||||
or returnServerError('Unable to find group title!');
|
or throwServerException('Unable to find group title!');
|
||||||
|
|
||||||
return html_entity_decode($ogtitle->plaintext, ENT_QUOTES);
|
return html_entity_decode($ogtitle->plaintext, ENT_QUOTES);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
private function extractGroupPostURI($post)
|
private function extractGroupPostURI($post)
|
||||||
{
|
{
|
||||||
$elements = $post->find('a')
|
$elements = $post->find('a')
|
||||||
or returnServerError('Unable to find URI!');
|
or throwServerException('Unable to find URI!');
|
||||||
|
|
||||||
foreach ($elements as $anchor) {
|
foreach ($elements as $anchor) {
|
||||||
// Find the one that is a permalink
|
// Find the one that is a permalink
|
||||||
|
@ -292,7 +292,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
private function extractGroupPostContent($post)
|
private function extractGroupPostContent($post)
|
||||||
{
|
{
|
||||||
$content = $post->find('div._5rgt', 0)
|
$content = $post->find('div._5rgt', 0)
|
||||||
or returnServerError('Unable to find user content!');
|
or throwServerException('Unable to find user content!');
|
||||||
|
|
||||||
$context_text = $content->innertext;
|
$context_text = $content->innertext;
|
||||||
if ($content->next_sibling() !== null) {
|
if ($content->next_sibling() !== null) {
|
||||||
|
@ -304,7 +304,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
private function extractGroupPostAuthor($post)
|
private function extractGroupPostAuthor($post)
|
||||||
{
|
{
|
||||||
$element = $post->find('h3 a', 0)
|
$element = $post->find('h3 a', 0)
|
||||||
or returnServerError('Unable to find author information!');
|
or throwServerException('Unable to find author information!');
|
||||||
|
|
||||||
return $element->plaintext;
|
return $element->plaintext;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ class FacebookBridge extends BridgeAbstract
|
||||||
private function extractGroupPostTitle($post)
|
private function extractGroupPostTitle($post)
|
||||||
{
|
{
|
||||||
$element = $post->find('h3', 0)
|
$element = $post->find('h3', 0)
|
||||||
or returnServerError('Unable to find title!');
|
or throwServerException('Unable to find title!');
|
||||||
|
|
||||||
if (strpos($element->plaintext, 'shared') === false) {
|
if (strpos($element->plaintext, 'shared') === false) {
|
||||||
$content = strip_tags($this->extractGroupPostContent($post));
|
$content = strip_tags($this->extractGroupPostContent($post));
|
||||||
|
@ -370,14 +370,14 @@ class FacebookBridge extends BridgeAbstract
|
||||||
!array_key_exists('path', $urlparts)
|
!array_key_exists('path', $urlparts)
|
||||||
|| $urlparts['path'] === '/'
|
|| $urlparts['path'] === '/'
|
||||||
) {
|
) {
|
||||||
returnClientError('The URL you provided doesn\'t contain the user name!');
|
throwClientException('The URL you provided doesn\'t contain the user name!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return explode('/', $urlparts['path'])[1];
|
return explode('/', $urlparts['path'])[1];
|
||||||
} else {
|
} else {
|
||||||
// First character cannot be a forward slash
|
// First character cannot be a forward slash
|
||||||
if (strpos($user, '/') === 0) {
|
if (strpos($user, '/') === 0) {
|
||||||
returnClientError('Remove leading slash "/" from the username!');
|
throwClientException('Remove leading slash "/" from the username!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
@ -572,7 +572,7 @@ EOD;
|
||||||
$loginForm = $html->find('._585r', 0);
|
$loginForm = $html->find('._585r', 0);
|
||||||
|
|
||||||
if ($loginForm != null) {
|
if ($loginForm != null) {
|
||||||
returnServerError('You must be logged in to view this page. This is not supported by RSS-Bridge.');
|
throwServerException('You must be logged in to view this page. This is not supported by RSS-Bridge.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$mainColumn = $html->find('#pagelet_timeline_main_column');
|
$mainColumn = $html->find('#pagelet_timeline_main_column');
|
||||||
|
|
|
@ -40,7 +40,7 @@ class FeedExpanderExampleBridge extends FeedExpander
|
||||||
parent::collectExpandableDatas('http://segfault.linuxmint.com/feed/atom/');
|
parent::collectExpandableDatas('http://segfault.linuxmint.com/feed/atom/');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnClientError('Unknown version ' . $this->getInput('version') . '!');
|
throwClientException('Unknown version ' . $this->getInput('version') . '!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ class FlickrBridge extends BridgeAbstract
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
returnClientError('Invalid context: ' . $this->queriedContext);
|
throwClientException('Invalid context: ' . $this->queriedContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
$model_json = $this->extractJsonModel($html);
|
$model_json = $this->extractJsonModel($html);
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Formula1Bridge extends BridgeAbstract
|
||||||
'locale: en'
|
'locale: en'
|
||||||
]));
|
]));
|
||||||
if (property_exists($json, 'error')) {
|
if (property_exists($json, 'error')) {
|
||||||
returnServerError($json->message);
|
throwServerException($json->message);
|
||||||
}
|
}
|
||||||
$list = $json->items;
|
$list = $json->items;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class FunkBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnServerError('Unknown context!');
|
throwServerException('Unknown context!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class GitHubGistBridge extends BridgeAbstract
|
||||||
$html = defaultLinkTo($html, $this->getURI());
|
$html = defaultLinkTo($html, $this->getURI());
|
||||||
|
|
||||||
$fileinfo = $html->find('[class~="file-info"]', 0)
|
$fileinfo = $html->find('[class~="file-info"]', 0)
|
||||||
or returnServerError('Could not find file info!');
|
or throwServerException('Could not find file info!');
|
||||||
|
|
||||||
$this->filename = $fileinfo->plaintext;
|
$this->filename = $fileinfo->plaintext;
|
||||||
|
|
||||||
|
@ -68,18 +68,18 @@ class GitHubGistBridge extends BridgeAbstract
|
||||||
|
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
$uri = $comment->find('a[href*=#gistcomment]', 0)
|
$uri = $comment->find('a[href*=#gistcomment]', 0)
|
||||||
or returnServerError('Could not find comment anchor!');
|
or throwServerException('Could not find comment anchor!');
|
||||||
|
|
||||||
$title = $comment->find('h3', 0);
|
$title = $comment->find('h3', 0);
|
||||||
|
|
||||||
$datetime = $comment->find('[datetime]', 0)
|
$datetime = $comment->find('[datetime]', 0)
|
||||||
or returnServerError('Could not find comment datetime!');
|
or throwServerException('Could not find comment datetime!');
|
||||||
|
|
||||||
$author = $comment->find('a.author', 0)
|
$author = $comment->find('a.author', 0)
|
||||||
or returnServerError('Could not find author name!');
|
or throwServerException('Could not find author name!');
|
||||||
|
|
||||||
$message = $comment->find('[class~="comment-body"]', 0)
|
$message = $comment->find('[class~="comment-body"]', 0)
|
||||||
or returnServerError('Could not find comment body!');
|
or throwServerException('Could not find comment body!');
|
||||||
|
|
||||||
$item = [];
|
$item = [];
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ class GiteaBridge extends BridgeAbstract
|
||||||
protected function collectReleasesData($html)
|
protected function collectReleasesData($html)
|
||||||
{
|
{
|
||||||
$releases = $html->find('#release-list > li')
|
$releases = $html->find('#release-list > li')
|
||||||
or returnServerError('Unable to find releases');
|
or throwServerException('Unable to find releases');
|
||||||
|
|
||||||
foreach ($releases as $release) {
|
foreach ($releases as $release) {
|
||||||
$this->items[] = [
|
$this->items[] = [
|
||||||
|
@ -203,7 +203,7 @@ class GiteaBridge extends BridgeAbstract
|
||||||
protected function collectTagsData($html)
|
protected function collectTagsData($html)
|
||||||
{
|
{
|
||||||
$tags = $html->find('table#tags-table > tbody > tr')
|
$tags = $html->find('table#tags-table > tbody > tr')
|
||||||
or returnServerError('Unable to find tags');
|
or throwServerException('Unable to find tags');
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
$this->items[] = [
|
$this->items[] = [
|
||||||
|
@ -216,7 +216,7 @@ class GiteaBridge extends BridgeAbstract
|
||||||
protected function collectCommitsData($html)
|
protected function collectCommitsData($html)
|
||||||
{
|
{
|
||||||
$commits = $html->find('#commits-table tbody tr')
|
$commits = $html->find('#commits-table tbody tr')
|
||||||
or returnServerError('Unable to find commits');
|
or throwServerException('Unable to find commits');
|
||||||
|
|
||||||
foreach ($commits as $commit) {
|
foreach ($commits as $commit) {
|
||||||
$this->items[] = [
|
$this->items[] = [
|
||||||
|
@ -232,7 +232,7 @@ class GiteaBridge extends BridgeAbstract
|
||||||
protected function collectIssuesData($html)
|
protected function collectIssuesData($html)
|
||||||
{
|
{
|
||||||
$issues = $html->find('.issue.list li')
|
$issues = $html->find('.issue.list li')
|
||||||
or returnServerError('Unable to find issues');
|
or throwServerException('Unable to find issues');
|
||||||
|
|
||||||
foreach ($issues as $issue) {
|
foreach ($issues as $issue) {
|
||||||
$uri = $issue->find('a', 0)->href;
|
$uri = $issue->find('a', 0)->href;
|
||||||
|
@ -259,7 +259,7 @@ class GiteaBridge extends BridgeAbstract
|
||||||
protected function collectSingleIssueOrPrData($html)
|
protected function collectSingleIssueOrPrData($html)
|
||||||
{
|
{
|
||||||
$comments = $html->find('.comment')
|
$comments = $html->find('.comment')
|
||||||
or returnServerError('Unable to find comments');
|
or throwServerException('Unable to find comments');
|
||||||
|
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
if (
|
if (
|
||||||
|
@ -293,7 +293,7 @@ class GiteaBridge extends BridgeAbstract
|
||||||
protected function collectPullRequestsData($html)
|
protected function collectPullRequestsData($html)
|
||||||
{
|
{
|
||||||
$issues = $html->find('.issue.list li')
|
$issues = $html->find('.issue.list li')
|
||||||
or returnServerError('Unable to find pull requests');
|
or throwServerException('Unable to find pull requests');
|
||||||
|
|
||||||
foreach ($issues as $issue) {
|
foreach ($issues as $issue) {
|
||||||
$uri = $issue->find('a', 0)->href;
|
$uri = $issue->find('a', 0)->href;
|
||||||
|
|
|
@ -98,7 +98,7 @@ class GlassdoorBridge extends BridgeAbstract
|
||||||
private function collectBlogData($html, $limit)
|
private function collectBlogData($html, $limit)
|
||||||
{
|
{
|
||||||
$posts = $html->find('div.post')
|
$posts = $html->find('div.post')
|
||||||
or returnServerError('Unable to find blog posts!');
|
or throwServerException('Unable to find blog posts!');
|
||||||
|
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
@ -121,7 +121,7 @@ class GlassdoorBridge extends BridgeAbstract
|
||||||
private function collectReviewData($html, $limit)
|
private function collectReviewData($html, $limit)
|
||||||
{
|
{
|
||||||
$reviews = $html->find('#ReviewsFeed li[id^="empReview]')
|
$reviews = $html->find('#ReviewsFeed li[id^="empReview]')
|
||||||
or returnServerError('Unable to find reviews!');
|
or throwServerException('Unable to find reviews!');
|
||||||
|
|
||||||
foreach ($reviews as $review) {
|
foreach ($reviews as $review) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
@ -163,7 +163,7 @@ class GlassdoorBridge extends BridgeAbstract
|
||||||
FILTER_FLAG_PATH_REQUIRED
|
FILTER_FLAG_PATH_REQUIRED
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
returnClientError('The specified URL is invalid!');
|
throwClientException('The specified URL is invalid!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = filter_var($uri, FILTER_SANITIZE_URL);
|
$uri = filter_var($uri, FILTER_SANITIZE_URL);
|
||||||
|
@ -189,7 +189,7 @@ class GlassdoorBridge extends BridgeAbstract
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!in_array($parts[1], $allowed_strings)) {
|
if (!in_array($parts[1], $allowed_strings)) {
|
||||||
returnClientError('Please specify a URL pointing to the companies review page!');
|
throwClientException('Please specify a URL pointing to the companies review page!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $uri;
|
return $uri;
|
||||||
|
|
|
@ -141,7 +141,7 @@ class GogsBridge extends BridgeAbstract
|
||||||
protected function collectCommitsData($html)
|
protected function collectCommitsData($html)
|
||||||
{
|
{
|
||||||
$commits = $html->find('#commits-table tbody tr')
|
$commits = $html->find('#commits-table tbody tr')
|
||||||
or returnServerError('Unable to find commits');
|
or throwServerException('Unable to find commits');
|
||||||
|
|
||||||
foreach ($commits as $commit) {
|
foreach ($commits as $commit) {
|
||||||
$this->items[] = [
|
$this->items[] = [
|
||||||
|
@ -157,7 +157,7 @@ class GogsBridge extends BridgeAbstract
|
||||||
protected function collectIssuesData($html)
|
protected function collectIssuesData($html)
|
||||||
{
|
{
|
||||||
$issues = $html->find('.issue.list li')
|
$issues = $html->find('.issue.list li')
|
||||||
or returnServerError('Unable to find issues');
|
or throwServerException('Unable to find issues');
|
||||||
|
|
||||||
foreach ($issues as $issue) {
|
foreach ($issues as $issue) {
|
||||||
$uri = $issue->find('a', 0)->href;
|
$uri = $issue->find('a', 0)->href;
|
||||||
|
@ -185,7 +185,7 @@ class GogsBridge extends BridgeAbstract
|
||||||
protected function collectSingleIssueData($html)
|
protected function collectSingleIssueData($html)
|
||||||
{
|
{
|
||||||
$comments = $html->find('.comments .comment')
|
$comments = $html->find('.comments .comment')
|
||||||
or returnServerError('Unable to find comments');
|
or throwServerException('Unable to find comments');
|
||||||
|
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
$this->items[] = [
|
$this->items[] = [
|
||||||
|
@ -203,7 +203,7 @@ class GogsBridge extends BridgeAbstract
|
||||||
protected function collectReleasesData($html)
|
protected function collectReleasesData($html)
|
||||||
{
|
{
|
||||||
$releases = $html->find('#release-list li')
|
$releases = $html->find('#release-list li')
|
||||||
or returnServerError('Unable to find releases');
|
or throwServerException('Unable to find releases');
|
||||||
|
|
||||||
foreach ($releases as $release) {
|
foreach ($releases as $release) {
|
||||||
$this->items[] = [
|
$this->items[] = [
|
||||||
|
|
|
@ -26,7 +26,7 @@ class GoogleSearchBridge extends BridgeAbstract
|
||||||
// todo: wrap this in try..catch because 429 too many requests happens a lot
|
// todo: wrap this in try..catch because 429 too many requests happens a lot
|
||||||
$dom = getSimpleHTMLDOM($this->getURI(), ['Accept-language: en-US']);
|
$dom = getSimpleHTMLDOM($this->getURI(), ['Accept-language: en-US']);
|
||||||
if (!$dom) {
|
if (!$dom) {
|
||||||
returnServerError('No results for this query.');
|
throwServerException('No results for this query.');
|
||||||
}
|
}
|
||||||
$result = $dom->find('div[id=res]', 0);
|
$result = $dom->find('div[id=res]', 0);
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ class I4wifiBridge extends BridgeAbstract
|
||||||
private function collectNews($html)
|
private function collectNews($html)
|
||||||
{
|
{
|
||||||
$articles = $html->find('.timeline-item.timeline-item-right')
|
$articles = $html->find('.timeline-item.timeline-item-right')
|
||||||
or returnServerError('No articles found! Layout might have changed!');
|
or throwServerException('No articles found! Layout might have changed!');
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
@ -157,7 +157,7 @@ class I4wifiBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Return URI of the article
|
// Return URI of the article
|
||||||
$element = $article->find('a', 0)
|
$element = $article->find('a', 0)
|
||||||
or returnServerError('Anchor not found!');
|
or throwServerException('Anchor not found!');
|
||||||
|
|
||||||
return $element->href;
|
return $element->href;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ class I4wifiBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Check if date is set
|
// Check if date is set
|
||||||
$element = $article->find('.timeline-item-info', 0)
|
$element = $article->find('.timeline-item-info', 0)
|
||||||
or returnServerError('Date not found!');
|
or throwServerException('Date not found!');
|
||||||
|
|
||||||
// Format date
|
// Format date
|
||||||
return $this->fixDate($element->plaintext);
|
return $this->fixDate($element->plaintext);
|
||||||
|
@ -188,7 +188,7 @@ class I4wifiBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract description
|
// Extract description
|
||||||
$element = $article->find('p', 0)
|
$element = $article->find('p', 0)
|
||||||
or returnServerError('Description not found!');
|
or throwServerException('Description not found!');
|
||||||
|
|
||||||
return $element->innertext;
|
return $element->innertext;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ class I4wifiBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract title
|
// Extract title
|
||||||
$element = $article->find('img', 0)
|
$element = $article->find('img', 0)
|
||||||
or returnServerError('Title not found!');
|
or throwServerException('Title not found!');
|
||||||
|
|
||||||
return $element->alt;
|
return $element->alt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class IPBBridge extends FeedExpander
|
||||||
switch (parse_url($this->getInput('uri'), PHP_URL_PATH)) {
|
switch (parse_url($this->getInput('uri'), PHP_URL_PATH)) {
|
||||||
case null:
|
case null:
|
||||||
case '/index.php':
|
case '/index.php':
|
||||||
returnClientError('Provided URI is invalid!');
|
throwClientException('Provided URI is invalid!');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -75,7 +75,7 @@ class IPBBridge extends FeedExpander
|
||||||
$this->collectForum($html);
|
$this->collectForum($html);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnClientError('Unknown type!');
|
throwClientException('Unknown type!');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ class IPBBridge extends FeedExpander
|
||||||
$this->collectForumTable($html);
|
$this->collectForumTable($html);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnClientError('Unknown forum format!');
|
throwClientException('Unknown forum format!');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ class IPBBridge extends FeedExpander
|
||||||
$this->collectTopicHistory($html, $limit, 'collectTopicDiv');
|
$this->collectTopicHistory($html, $limit, 'collectTopicDiv');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnClientError('Unknown topic format!');
|
throwClientException('Unknown topic format!');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ class IPBBridge extends FeedExpander
|
||||||
{
|
{
|
||||||
// Make sure the callback is valid!
|
// Make sure the callback is valid!
|
||||||
if (!method_exists($this, $callback)) {
|
if (!method_exists($this, $callback)) {
|
||||||
returnServerError('Unknown function (\'' . $callback . '\')!');
|
throwServerException('Unknown function (\'' . $callback . '\')!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$next = null; // Holds the URI of the next page
|
$next = null; // Holds the URI of the next page
|
||||||
|
|
|
@ -258,7 +258,7 @@ HTML,
|
||||||
|
|
||||||
// If no content type is selected, this bridge does nothing, so we return an error
|
// If no content type is selected, this bridge does nothing, so we return an error
|
||||||
if (count($types) == 0) {
|
if (count($types) == 0) {
|
||||||
returnClientError('You must select at least one of the content type : Post, Stories or Tags !');
|
throwClientException('You must select at least one of the content type : Post, Stories or Tags !');
|
||||||
}
|
}
|
||||||
$typesText = $types[0] ?? '';
|
$typesText = $types[0] ?? '';
|
||||||
|
|
||||||
|
|
|
@ -689,7 +689,7 @@ class ItakuBridge extends BridgeAbstract
|
||||||
if (is_array($item) || is_object($item)) {
|
if (is_array($item) || is_object($item)) {
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
} else {
|
} else {
|
||||||
returnServerError("Incorrectly parsed item. Check the code!\nType: " . gettype($item) . "\nprint_r(item:)\n" . var_dump($item));
|
throwServerException("Incorrectly parsed item. Check the code!\nType: " . gettype($item) . "\nprint_r(item:)\n" . var_dump($item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ class ItchioBridge extends BridgeAbstract
|
||||||
$html = getSimpleHTMLDOM($url);
|
$html = getSimpleHTMLDOM($url);
|
||||||
// if the page is password protected, abort
|
// if the page is password protected, abort
|
||||||
if ($html->find('.game_password_page', 0) !== null) {
|
if ($html->find('.game_password_page', 0) !== null) {
|
||||||
returnClientError('The requested page is password protected.');
|
throwClientException('The requested page is password protected.');
|
||||||
}
|
}
|
||||||
$title = $html->find('.game_title', 0)->innertext;
|
$title = $html->find('.game_title', 0)->innertext;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ class IvooxBridge extends BridgeAbstract
|
||||||
$this->request = str_replace(' ', '-', $this->getInput('s'));
|
$this->request = str_replace(' ', '-', $this->getInput('s'));
|
||||||
$url_feed = self::URI . urlencode($this->request) . '_sb_f_1.html?o=uploaddate';
|
$url_feed = self::URI . urlencode($this->request) . '_sb_f_1.html?o=uploaddate';
|
||||||
} else {
|
} else {
|
||||||
returnClientError('Not valid mode at IvooxBridge');
|
throwClientException('Not valid mode at IvooxBridge');
|
||||||
}
|
}
|
||||||
|
|
||||||
$dom = getSimpleHTMLDOM($url_feed);
|
$dom = getSimpleHTMLDOM($url_feed);
|
||||||
|
|
|
@ -167,7 +167,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function collectNews($html)
|
private function collectNews($html)
|
||||||
{
|
{
|
||||||
$articles = $html->find('div.newsTopArticle')
|
$articles = $html->find('div.newsTopArticle')
|
||||||
or returnServerError('No articles found! Layout might have changed!');
|
or throwServerException('No articles found! Layout might have changed!');
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
@ -184,7 +184,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
$html = getSimpleHTMLDOMCached($uri);
|
$html = getSimpleHTMLDOMCached($uri);
|
||||||
|
|
||||||
$fullArticle = $html->find('div.article', 0)
|
$fullArticle = $html->find('div.article', 0)
|
||||||
or returnServerError('No content found! Layout might have changed!');
|
or throwServerException('No content found! Layout might have changed!');
|
||||||
|
|
||||||
defaultLinkTo($fullArticle, static::URI);
|
defaultLinkTo($fullArticle, static::URI);
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function extractNewsUri($article)
|
private function extractNewsUri($article)
|
||||||
{
|
{
|
||||||
$element = $article->find('a', 0)
|
$element = $article->find('a', 0)
|
||||||
or returnServerError('Anchor not found!');
|
or throwServerException('Anchor not found!');
|
||||||
|
|
||||||
return $element->href;
|
return $element->href;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function extractNewsDate($article)
|
private function extractNewsDate($article)
|
||||||
{
|
{
|
||||||
$element = $article->find('div.subheadline', 0)
|
$element = $article->find('div.subheadline', 0)
|
||||||
or returnServerError('Date not found!');
|
or throwServerException('Date not found!');
|
||||||
|
|
||||||
$date = trim(explode('|', $element->plaintext)[0]);
|
$date = trim(explode('|', $element->plaintext)[0]);
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function extractNewsDescription($article)
|
private function extractNewsDescription($article)
|
||||||
{
|
{
|
||||||
$element = $article->find('span.newsText', 0)
|
$element = $article->find('span.newsText', 0)
|
||||||
or returnServerError('Description not found!');
|
or throwServerException('Description not found!');
|
||||||
|
|
||||||
$element->find('a', 0)->onclick = '';
|
$element->find('a', 0)->onclick = '';
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function extractNewsTitle($article)
|
private function extractNewsTitle($article)
|
||||||
{
|
{
|
||||||
$element = $article->find('h3', 0)
|
$element = $article->find('h3', 0)
|
||||||
or returnServerError('Title not found!');
|
or throwServerException('Title not found!');
|
||||||
|
|
||||||
return $element->plaintext;
|
return $element->plaintext;
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function extractFullArticleContent($article)
|
private function extractFullArticleContent($article)
|
||||||
{
|
{
|
||||||
$element = $article->find('div.article_body', 0)
|
$element = $article->find('div.article_body', 0)
|
||||||
or returnServerError('Article body not found!');
|
or throwServerException('Article body not found!');
|
||||||
|
|
||||||
// Remove teaser image
|
// Remove teaser image
|
||||||
$element->find('img.teaser-img', 0)->outertext = '';
|
$element->find('img.teaser-img', 0)->outertext = '';
|
||||||
|
@ -266,7 +266,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function extractFullArticleAuthor($article)
|
private function extractFullArticleAuthor($article)
|
||||||
{
|
{
|
||||||
$element = $article->find('span[itemprop=name]', 0)
|
$element = $article->find('span[itemprop=name]', 0)
|
||||||
or returnServerError('Author not found!');
|
or throwServerException('Author not found!');
|
||||||
|
|
||||||
return $element->plaintext;
|
return $element->plaintext;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function extractProfileDate($html)
|
private function extractProfileDate($html)
|
||||||
{
|
{
|
||||||
$element = $html->find('div.infobox div.vallabel', 0)
|
$element = $html->find('div.infobox div.vallabel', 0)
|
||||||
or returnServerError('Date not found!');
|
or throwServerException('Date not found!');
|
||||||
|
|
||||||
$date = trim(explode("\r\n", $element->plaintext)[1]);
|
$date = trim(explode("\r\n", $element->plaintext)[1]);
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
private function extractProfileTitle($html)
|
private function extractProfileTitle($html)
|
||||||
{
|
{
|
||||||
$element = $html->find('span.h1', 0)
|
$element = $html->find('span.h1', 0)
|
||||||
or returnServerError('Title not found!');
|
or throwServerException('Title not found!');
|
||||||
|
|
||||||
return $element->plaintext;
|
return $element->plaintext;
|
||||||
}
|
}
|
||||||
|
@ -314,12 +314,12 @@ class JustETFBridge extends BridgeAbstract
|
||||||
// - Quote
|
// - Quote
|
||||||
|
|
||||||
$strategy = $html->find('div.tab-container div.col-sm-6 p', 0)
|
$strategy = $html->find('div.tab-container div.col-sm-6 p', 0)
|
||||||
or returnServerError('Investment Strategy not found!');
|
or throwServerException('Investment Strategy not found!');
|
||||||
|
|
||||||
// Description requires a bit of cleanup due to lack of propper identification
|
// Description requires a bit of cleanup due to lack of propper identification
|
||||||
|
|
||||||
$description = $html->find('div.headline', 5)
|
$description = $html->find('div.headline', 5)
|
||||||
or returnServerError('Description container not found!');
|
or throwServerException('Description container not found!');
|
||||||
|
|
||||||
$description = $description->parent();
|
$description = $description->parent();
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
$quote = $html->find('div.infobox div.val', 0)
|
$quote = $html->find('div.infobox div.val', 0)
|
||||||
or returnServerError('Quote not found!');
|
or throwServerException('Quote not found!');
|
||||||
|
|
||||||
$quote_html = '<strong>Quote</strong><br><p>' . $quote . '</p>';
|
$quote_html = '<strong>Quote</strong><br><p>' . $quote . '</p>';
|
||||||
$strategy_html = '';
|
$strategy_html = '';
|
||||||
|
@ -350,7 +350,7 @@ class JustETFBridge extends BridgeAbstract
|
||||||
// Use ISIN + WKN as author
|
// Use ISIN + WKN as author
|
||||||
// Notice: "identfier" is not a typo [sic]!
|
// Notice: "identfier" is not a typo [sic]!
|
||||||
$element = $html->find('span.identfier', 0)
|
$element = $html->find('span.identfier', 0)
|
||||||
or returnServerError('Author not found!');
|
or throwServerException('Author not found!');
|
||||||
|
|
||||||
return $element->plaintext;
|
return $element->plaintext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,7 +420,7 @@ class LaCentraleBridge extends BridgeAbstract
|
||||||
!empty($this->getInput('distance'))
|
!empty($this->getInput('distance'))
|
||||||
&& is_null($this->getInput('location'))
|
&& is_null($this->getInput('location'))
|
||||||
) {
|
) {
|
||||||
returnClientError('You need a place ("CP ou département") to search arround.');
|
throwClientException('You need a place ("CP ou département") to search arround.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
|
|
|
@ -339,14 +339,14 @@ class LeBonCoinBridge extends BridgeAbstract
|
||||||
&& !is_null($range_max)
|
&& !is_null($range_max)
|
||||||
&& $range_min > $range_max
|
&& $range_min > $range_max
|
||||||
) {
|
) {
|
||||||
returnClientError('Min-' . $field . ' must be lower than max-' . $field . '.');
|
throwClientException('Min-' . $field . ' must be lower than max-' . $field . '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!is_null($range_min)
|
!is_null($range_min)
|
||||||
&& is_null($range_max)
|
&& is_null($range_max)
|
||||||
) {
|
) {
|
||||||
returnClientError('Max-' . $field . ' is needed when min-' . $field . ' is setted (range).');
|
throwClientException('Max-' . $field . ' is needed when min-' . $field . ' is setted (range).');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -16,7 +16,7 @@ class LinuxBlogBridge extends BridgeAbstract
|
||||||
$articles = $dom->find('ul.display-posts-listing li.listing-item');
|
$articles = $dom->find('ul.display-posts-listing li.listing-item');
|
||||||
|
|
||||||
if (!$articles) {
|
if (!$articles) {
|
||||||
returnServerError('Failed to retrieve articles');
|
throwServerException('Failed to retrieve articles');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ class MallTvBridge extends BridgeAbstract
|
||||||
|
|
||||||
$scriptLdJson = $html->find('script[type="application/ld+json"]', 0)->innertext;
|
$scriptLdJson = $html->find('script[type="application/ld+json"]', 0)->innertext;
|
||||||
if (!preg_match('/[\'"]uploadDate[\'"]\s*:\s*[\'"](\d{4}-\d{2}-\d{2})[\'"]/', $scriptLdJson, $match)) {
|
if (!preg_match('/[\'"]uploadDate[\'"]\s*:\s*[\'"](\d{4}-\d{2}-\d{2})[\'"]/', $scriptLdJson, $match)) {
|
||||||
returnServerError('Could not get date from MALL.TV detail page');
|
throwServerException('Could not get date from MALL.TV detail page');
|
||||||
}
|
}
|
||||||
|
|
||||||
return strtotime($match[1]);
|
return strtotime($match[1]);
|
||||||
|
@ -40,7 +40,7 @@ class MallTvBridge extends BridgeAbstract
|
||||||
$url = $this->getInput('url');
|
$url = $this->getInput('url');
|
||||||
|
|
||||||
if (!preg_match('/^https:\/\/www\.mall\.tv\/[a-z0-9-]+(\/[a-z0-9-]+)?\/?$/', $url)) {
|
if (!preg_match('/^https:\/\/www\.mall\.tv\/[a-z0-9-]+(\/[a-z0-9-]+)?\/?$/', $url)) {
|
||||||
returnServerError('Invalid url');
|
throwServerException('Invalid url');
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM($url);
|
$html = getSimpleHTMLDOM($url);
|
||||||
|
|
|
@ -108,7 +108,7 @@ class MangaDexBridge extends BridgeAbstract
|
||||||
switch ($this->queriedContext) {
|
switch ($this->queriedContext) {
|
||||||
case 'Title Chapters':
|
case 'Title Chapters':
|
||||||
preg_match(self::TITLE_REGEX, $this->getInput('url'), $matches)
|
preg_match(self::TITLE_REGEX, $this->getInput('url'), $matches)
|
||||||
or returnClientError('Invalid URL Parameter');
|
or throwClientException('Invalid URL Parameter');
|
||||||
$this->feedURI = self::URI . 'title/' . $matches['uuid'];
|
$this->feedURI = self::URI . 'title/' . $matches['uuid'];
|
||||||
$params['order[readableAt]'] = 'desc';
|
$params['order[readableAt]'] = 'desc';
|
||||||
if (!$this->getInput('external')) {
|
if (!$this->getInput('external')) {
|
||||||
|
@ -129,7 +129,7 @@ class MangaDexBridge extends BridgeAbstract
|
||||||
$uri = self::API_ROOT . 'chapter';
|
$uri = self::API_ROOT . 'chapter';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnServerError('Unimplemented Context (getAPI)');
|
throwServerException('Unimplemented Context (getAPI)');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove null keys
|
// Remove null keys
|
||||||
|
@ -180,7 +180,7 @@ class MangaDexBridge extends BridgeAbstract
|
||||||
if ($content['result'] == 'ok') {
|
if ($content['result'] == 'ok') {
|
||||||
$content = $content['data'];
|
$content = $content['data'];
|
||||||
} else {
|
} else {
|
||||||
returnServerError('Could not retrieve API results');
|
throwServerException('Could not retrieve API results');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($this->queriedContext) {
|
switch ($this->queriedContext) {
|
||||||
|
@ -191,7 +191,7 @@ class MangaDexBridge extends BridgeAbstract
|
||||||
$this->getChapters($content);
|
$this->getChapters($content);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnServerError('Unimplemented Context (collectData)');
|
throwServerException('Unimplemented Context (collectData)');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ class MangaDexBridge extends BridgeAbstract
|
||||||
$header = [ 'Content-Type: application/json' ];
|
$header = [ 'Content-Type: application/json' ];
|
||||||
$pages = json_decode(getContents($api_uri, $header), true);
|
$pages = json_decode(getContents($api_uri, $header), true);
|
||||||
if ($pages['result'] != 'ok') {
|
if ($pages['result'] != 'ok') {
|
||||||
returnServerError('Could not retrieve API results');
|
throwServerException('Could not retrieve API results');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getInput('images') == 'saver') {
|
if ($this->getInput('images') == 'saver') {
|
||||||
|
|
|
@ -21,7 +21,7 @@ class MinecraftBridge extends BridgeAbstract
|
||||||
$articles = json_decode($json);
|
$articles = json_decode($json);
|
||||||
|
|
||||||
if ($articles === null) {
|
if ($articles === null) {
|
||||||
returnServerError('Failed to decode JSON content.');
|
throwServerException('Failed to decode JSON content.');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($articles->article_grid as $article) {
|
foreach ($articles->article_grid as $article) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ModelKarteiBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
$model_id = preg_replace('/[^0-9]/', '', $this->getInput('model_id'));
|
$model_id = preg_replace('/[^0-9]/', '', $this->getInput('model_id'));
|
||||||
if (empty($model_id)) {
|
if (empty($model_id)) {
|
||||||
returnServerError('Invalid model ID');
|
throwServerException('Invalid model ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM(self::URI . 'sedcards/model/' . $model_id . '/');
|
$html = getSimpleHTMLDOM(self::URI . 'sedcards/model/' . $model_id . '/');
|
||||||
|
@ -34,7 +34,7 @@ class ModelKarteiBridge extends BridgeAbstract
|
||||||
|
|
||||||
$itemlist = $html->find('#photoList .photoPreview');
|
$itemlist = $html->find('#photoList .photoPreview');
|
||||||
if (!$itemlist) {
|
if (!$itemlist) {
|
||||||
returnServerError('No gallery');
|
throwServerException('No gallery');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($itemlist as $idx => $element) {
|
foreach ($itemlist as $idx => $element) {
|
||||||
|
|
|
@ -166,7 +166,7 @@ class MoinMoinBridge extends BridgeAbstract
|
||||||
private function splitSections($html)
|
private function splitSections($html)
|
||||||
{
|
{
|
||||||
$content = $html->find('div#page', 0)->innertext
|
$content = $html->find('div#page', 0)->innertext
|
||||||
or returnServerError('Unable to find <div id="page"/>!');
|
or throwServerException('Unable to find <div id="page"/>!');
|
||||||
|
|
||||||
$sections = [];
|
$sections = [];
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ class NasestrechaBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Check if page contains articles
|
// Check if page contains articles
|
||||||
$articles = $html->find('.post')
|
$articles = $html->find('.post')
|
||||||
or returnServerError('No articles found! Layout might have changed!');
|
or throwServerException('No articles found! Layout might have changed!');
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
@ -153,7 +153,7 @@ class NasestrechaBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Return URI of the article
|
// Return URI of the article
|
||||||
$element = $article->find('.thumbnail', 0)
|
$element = $article->find('.thumbnail', 0)
|
||||||
or returnServerError('Anchor not found!');
|
or throwServerException('Anchor not found!');
|
||||||
|
|
||||||
return $element->href;
|
return $element->href;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ class NasestrechaBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Check if date is set
|
// Check if date is set
|
||||||
$element = $article->find('div.post__info', 0)->find('span', 0)
|
$element = $article->find('div.post__info', 0)->find('span', 0)
|
||||||
or returnServerError('Date not found!');
|
or throwServerException('Date not found!');
|
||||||
|
|
||||||
$date = trim(explode('|', $element->plaintext)[0]);
|
$date = trim(explode('|', $element->plaintext)[0]);
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class NasestrechaBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract description
|
// Extract description
|
||||||
$element = $article->find('p.post__text', 0)
|
$element = $article->find('p.post__text', 0)
|
||||||
or returnServerError('Description not found!');
|
or throwServerException('Description not found!');
|
||||||
|
|
||||||
return $element->innertext;
|
return $element->innertext;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ class NasestrechaBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
// Extract title
|
// Extract title
|
||||||
$element = $article->find('a.post__title', 0)
|
$element = $article->find('a.post__title', 0)
|
||||||
or returnServerError('Title not found!');
|
or throwServerException('Title not found!');
|
||||||
|
|
||||||
return $element->plaintext;
|
return $element->plaintext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ class NationalGeographicBridge extends BridgeAbstract
|
||||||
case self::TOPIC_LATEST_STORIES:
|
case self::TOPIC_LATEST_STORIES:
|
||||||
return $this->collectLatestStories();
|
return $this->collectLatestStories();
|
||||||
default:
|
default:
|
||||||
returnServerError('Unknown topic: "' . $this->topicName . '"');
|
throwServerException('Unknown topic: "' . $this->topicName . '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ class OtrkeyFinderBridge extends BridgeAbstract
|
||||||
// Do we need to check the running time?
|
// Do we need to check the running time?
|
||||||
if ($minTime != 0 || $maxTime != 0) {
|
if ($minTime != 0 || $maxTime != 0) {
|
||||||
if ($maxTime > 0 && $maxTime < $minTime) {
|
if ($maxTime > 0 && $maxTime < $minTime) {
|
||||||
returnClientError('The minimum running time must be less than the maximum running time.');
|
throwClientException('The minimum running time must be less than the maximum running time.');
|
||||||
}
|
}
|
||||||
|
|
||||||
preg_match(self::FILENAME_REGEX, $file, $matches);
|
preg_match(self::FILENAME_REGEX, $file, $matches);
|
||||||
|
|
|
@ -25,7 +25,7 @@ class PatreonBridge extends BridgeAbstract
|
||||||
if (preg_match($regex, $html->save(), $matches) > 0) {
|
if (preg_match($regex, $html->save(), $matches) > 0) {
|
||||||
$campaign_id = $matches[1];
|
$campaign_id = $matches[1];
|
||||||
} else {
|
} else {
|
||||||
returnServerError('Could not find campaign ID');
|
throwServerException('Could not find campaign ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = [
|
$query = [
|
||||||
|
|
|
@ -109,7 +109,7 @@ class PepperBridgeAbstract extends BridgeAbstract
|
||||||
|
|
||||||
// Show an error message if we can't find the thread ID in the URL sent by the user
|
// Show an error message if we can't find the thread ID in the URL sent by the user
|
||||||
if ($threadSearch !== 1) {
|
if ($threadSearch !== 1) {
|
||||||
returnClientError($this->i8n('thread-error'));
|
throwClientException($this->i8n('thread-error'));
|
||||||
}
|
}
|
||||||
$threadID = $matches[1];
|
$threadID = $matches[1];
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ class PixivBridge extends BridgeAbstract
|
||||||
. '/profile/top';
|
. '/profile/top';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnClientError('Invalid Context');
|
throwClientException('Invalid Context');
|
||||||
}
|
}
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ class PixivBridge extends BridgeAbstract
|
||||||
if (
|
if (
|
||||||
!(strlen($proxy) > 0 && preg_match('/https?:\/\/.*/', $proxy))
|
!(strlen($proxy) > 0 && preg_match('/https?:\/\/.*/', $proxy))
|
||||||
) {
|
) {
|
||||||
returnServerError('Invalid proxy_url value set. The proxy must include the HTTP/S at the beginning of the url.');
|
throwServerException('Invalid proxy_url value set. The proxy must include the HTTP/S at the beginning of the url.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,12 +116,12 @@ class RedditBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
$forbiddenKey = 'reddit_forbidden';
|
$forbiddenKey = 'reddit_forbidden';
|
||||||
if ($this->cache->get($forbiddenKey)) {
|
if ($this->cache->get($forbiddenKey)) {
|
||||||
throw new RateLimitException();
|
throwRateLimitException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$rateLimitKey = 'reddit_rate_limit';
|
$rateLimitKey = 'reddit_rate_limit';
|
||||||
if ($this->cache->get($rateLimitKey)) {
|
if ($this->cache->get($rateLimitKey)) {
|
||||||
throw new RateLimitException();
|
throwRateLimitException();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -131,10 +131,10 @@ class RedditBridge extends BridgeAbstract
|
||||||
// 403 Forbidden
|
// 403 Forbidden
|
||||||
// This can possibly mean that reddit has permanently blocked this server's ip address
|
// This can possibly mean that reddit has permanently blocked this server's ip address
|
||||||
$this->cache->set($forbiddenKey, true, 60 * 61);
|
$this->cache->set($forbiddenKey, true, 60 * 61);
|
||||||
throw new RateLimitException();
|
throwRateLimitException();
|
||||||
} elseif ($e->getCode() === 429) {
|
} elseif ($e->getCode() === 429) {
|
||||||
$this->cache->set($rateLimitKey, true, 60 * 61);
|
$this->cache->set($rateLimitKey, true, 60 * 61);
|
||||||
throw new RateLimitException();
|
throwRateLimitException();
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,7 @@ class ReutersBridge extends BridgeAbstract
|
||||||
return $base_url . 'articles-by-section-alias-or-id-v1?query=' . $json_query;
|
return $base_url . 'articles-by-section-alias-or-id-v1?query=' . $json_query;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
returnServerError('unsupported endpoint');
|
throwServerException('unsupported endpoint');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addStories($title, $content, $timestamp, $author, $url, $category)
|
private function addStories($title, $content, $timestamp, $author, $url, $category)
|
||||||
|
|
|
@ -65,7 +65,7 @@ class RutubeBridge extends BridgeAbstract
|
||||||
private function getJSONData($html)
|
private function getJSONData($html)
|
||||||
{
|
{
|
||||||
$jsonDataRegex = '/window.reduxState = (.*);/';
|
$jsonDataRegex = '/window.reduxState = (.*);/';
|
||||||
preg_match($jsonDataRegex, $html, $matches) or returnServerError('Could not find reduxState');
|
preg_match($jsonDataRegex, $html, $matches) or throwServerException('Could not find reduxState');
|
||||||
$map = [
|
$map = [
|
||||||
'\x26' => '&',
|
'\x26' => '&',
|
||||||
'\x3c' => '<',
|
'\x3c' => '<',
|
||||||
|
|
|
@ -20,7 +20,7 @@ class SIMARBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
$html = getSimpleHTMLDOM($this->getURI());
|
$html = getSimpleHTMLDOM($this->getURI());
|
||||||
$e_home = $html->find('#home', 0)
|
$e_home = $html->find('#home', 0)
|
||||||
or returnServerError('Invalid site structure');
|
or throwServerException('Invalid site structure');
|
||||||
|
|
||||||
foreach ($e_home->find('span') as $element) {
|
foreach ($e_home->find('span') as $element) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
@ -34,7 +34,7 @@ class SIMARBridge extends BridgeAbstract
|
||||||
|
|
||||||
if ($this->getInput('interventions')) {
|
if ($this->getInput('interventions')) {
|
||||||
$e_main1 = $html->find('#menu1', 0)
|
$e_main1 = $html->find('#menu1', 0)
|
||||||
or returnServerError('Invalid site structure');
|
or throwServerException('Invalid site structure');
|
||||||
|
|
||||||
foreach ($e_main1->find('a') as $element) {
|
foreach ($e_main1->find('a') as $element) {
|
||||||
$item = [];
|
$item = [];
|
||||||
|
|
|
@ -59,7 +59,7 @@ class SchweinfurtBuergerinformationenBridge extends BridgeAbstract
|
||||||
if (preg_match('/artikel_id_(\d+)/', $article->id, $match)) {
|
if (preg_match('/artikel_id_(\d+)/', $article->id, $match)) {
|
||||||
$articleIDs[] = $match[1];
|
$articleIDs[] = $match[1];
|
||||||
} else {
|
} else {
|
||||||
returnServerError('Couldn\'t determine article ID from index page.');
|
throwServerException('Couldn\'t determine article ID from index page.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ EOD;
|
||||||
{
|
{
|
||||||
if (!is_null($this->getInput('profile'))) {
|
if (!is_null($this->getInput('profile'))) {
|
||||||
preg_match($this->profileUrlRegex, $this->getInput('profile'), $user)
|
preg_match($this->profileUrlRegex, $this->getInput('profile'), $user)
|
||||||
or returnServerError('Could not extract user ID and name from given profile URL.');
|
or throwServerException('Could not extract user ID and name from given profile URL.');
|
||||||
|
|
||||||
return self::URI . '/' . $user[1] . '/uploads';
|
return self::URI . '/' . $user[1] . '/uploads';
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ class SensCritiqueBridge extends BridgeAbstract
|
||||||
private function extractDataFromList($list)
|
private function extractDataFromList($list)
|
||||||
{
|
{
|
||||||
if ($list === null) {
|
if ($list === null) {
|
||||||
returnClientError('Cannot extract data from list');
|
throwClientException('Cannot extract data from list');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($list->find('div[data-testid="product-list-item"]') as $movie) {
|
foreach ($list->find('div[data-testid="product-list-item"]') as $movie) {
|
||||||
|
|
|
@ -48,20 +48,20 @@ class SeznamZpravyBridge extends BridgeAbstract
|
||||||
|
|
||||||
$html = getSimpleHTMLDOMCached($url . $this->getInput('author'), $ONE_DAY);
|
$html = getSimpleHTMLDOMCached($url . $this->getInput('author'), $ONE_DAY);
|
||||||
$mainBreadcrumbs = $html->find($selectors['breadcrumbs'], 0)
|
$mainBreadcrumbs = $html->find($selectors['breadcrumbs'], 0)
|
||||||
or returnServerError('Could not get breadcrumbs for: ' . $this->getURI());
|
or throwServerException('Could not get breadcrumbs for: ' . $this->getURI());
|
||||||
|
|
||||||
$author = $mainBreadcrumbs->last_child()->plaintext
|
$author = $mainBreadcrumbs->last_child()->plaintext
|
||||||
or returnServerError('Could not get author for: ' . $this->getURI());
|
or throwServerException('Could not get author for: ' . $this->getURI());
|
||||||
|
|
||||||
$this->feedName = $author . ' - Seznam Zprávy';
|
$this->feedName = $author . ' - Seznam Zprávy';
|
||||||
|
|
||||||
$articles = $html->find($selectors['articleList'])
|
$articles = $html->find($selectors['articleList'])
|
||||||
or returnServerError('Could not find articles for: ' . $this->getURI());
|
or throwServerException('Could not find articles for: ' . $this->getURI());
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
// Get article URL
|
// Get article URL
|
||||||
$titleLink = $article->find($selectors['articleTitle'], 0)
|
$titleLink = $article->find($selectors['articleTitle'], 0)
|
||||||
or returnServerError('Could not find title for: ' . $this->getURI());
|
or throwServerException('Could not find title for: ' . $this->getURI());
|
||||||
$articleURL = $titleLink->href;
|
$articleURL = $titleLink->href;
|
||||||
|
|
||||||
$articleContentHTML = getSimpleHTMLDOMCached($articleURL, $ONE_DAY);
|
$articleContentHTML = getSimpleHTMLDOMCached($articleURL, $ONE_DAY);
|
||||||
|
@ -71,9 +71,9 @@ class SeznamZpravyBridge extends BridgeAbstract
|
||||||
|
|
||||||
// Article text content
|
// Article text content
|
||||||
$contentElem = $articleContentHTML->find($selectors['articleContent'], 0)
|
$contentElem = $articleContentHTML->find($selectors['articleContent'], 0)
|
||||||
or returnServerError('Could not get article content for: ' . $articleURL);
|
or throwServerException('Could not get article content for: ' . $articleURL);
|
||||||
$contentParagraphs = $contentElem->find($selectors['articleParagraphs'])
|
$contentParagraphs = $contentElem->find($selectors['articleParagraphs'])
|
||||||
or returnServerError('Could not find paragraphs for: ' . $articleURL);
|
or throwServerException('Could not find paragraphs for: ' . $articleURL);
|
||||||
|
|
||||||
// If the article has an image, put that image at the start
|
// If the article has an image, put that image at the start
|
||||||
$contentInitialValue = isset($articleImageElem) ? $articleImageElem->outertext : '';
|
$contentInitialValue = isset($articleImageElem) ? $articleImageElem->outertext : '';
|
||||||
|
@ -83,7 +83,7 @@ class SeznamZpravyBridge extends BridgeAbstract
|
||||||
|
|
||||||
// Article categories
|
// Article categories
|
||||||
$breadcrumbsElem = $articleContentHTML->find($selectors['breadcrumbs'], 0)
|
$breadcrumbsElem = $articleContentHTML->find($selectors['breadcrumbs'], 0)
|
||||||
or returnServerError('Could not find breadcrumbs for: ' . $articleURL);
|
or throwServerException('Could not find breadcrumbs for: ' . $articleURL);
|
||||||
$breadcrumbs = $breadcrumbsElem->children();
|
$breadcrumbs = $breadcrumbsElem->children();
|
||||||
$numBreadcrumbs = count($breadcrumbs);
|
$numBreadcrumbs = count($breadcrumbs);
|
||||||
$categories = [];
|
$categories = [];
|
||||||
|
@ -96,7 +96,7 @@ class SeznamZpravyBridge extends BridgeAbstract
|
||||||
|
|
||||||
// Article date & time
|
// Article date & time
|
||||||
$articleTimeElem = $article->find($selectors['articleTime'], 0)
|
$articleTimeElem = $article->find($selectors['articleTime'], 0)
|
||||||
or returnServerError('Could not find article time for: ' . $articleURL);
|
or throwServerException('Could not find article time for: ' . $articleURL);
|
||||||
$articleTime = $articleTimeElem->plaintext;
|
$articleTime = $articleTimeElem->plaintext;
|
||||||
|
|
||||||
$articleDMElem = $article->find($selectors['articleDM'], 0);
|
$articleDMElem = $article->find($selectors['articleDM'], 0);
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ShanaprojectBridge extends BridgeAbstract
|
||||||
$html = $this->loadSeasonAnimeList();
|
$html = $this->loadSeasonAnimeList();
|
||||||
|
|
||||||
$animes = $html->find('div.header_display_box_info')
|
$animes = $html->find('div.header_display_box_info')
|
||||||
or returnServerError('Could not find anime headers!');
|
or throwServerException('Could not find anime headers!');
|
||||||
|
|
||||||
$min_episodes = $this->getInput('min_episodes') ?: 0;
|
$min_episodes = $this->getInput('min_episodes') ?: 0;
|
||||||
$min_total_episodes = $this->getInput('min_total_episodes') ?: 0;
|
$min_total_episodes = $this->getInput('min_total_episodes') ?: 0;
|
||||||
|
@ -89,7 +89,7 @@ class ShanaprojectBridge extends BridgeAbstract
|
||||||
$html = defaultLinkTo($html, self::URI . '/seasons');
|
$html = defaultLinkTo($html, self::URI . '/seasons');
|
||||||
|
|
||||||
$season = $html->find('div.follows_menu > a', 1)
|
$season = $html->find('div.follows_menu > a', 1)
|
||||||
or returnServerError('Could not find \'Season Anime List\'!');
|
or throwServerException('Could not find \'Season Anime List\'!');
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM($season->href);
|
$html = getSimpleHTMLDOM($season->href);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class ShanaprojectBridge extends BridgeAbstract
|
||||||
private function extractAnimeTitle($anime)
|
private function extractAnimeTitle($anime)
|
||||||
{
|
{
|
||||||
$title = $anime->find('a', 0)
|
$title = $anime->find('a', 0)
|
||||||
or returnServerError('Could not find anime title!');
|
or throwServerException('Could not find anime title!');
|
||||||
return trim($title->innertext);
|
return trim($title->innertext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class ShanaprojectBridge extends BridgeAbstract
|
||||||
private function extractAnimeUri($anime)
|
private function extractAnimeUri($anime)
|
||||||
{
|
{
|
||||||
$uri = $anime->find('a', 0)
|
$uri = $anime->find('a', 0)
|
||||||
or returnServerError('Could not find anime URI!');
|
or throwServerException('Could not find anime URI!');
|
||||||
return $uri->href;
|
return $uri->href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class ShanaprojectBridge extends BridgeAbstract
|
||||||
private function extractAnimeEpisodeInformation($anime)
|
private function extractAnimeEpisodeInformation($anime)
|
||||||
{
|
{
|
||||||
$episode = $anime->find('div.header_info_episode', 0)
|
$episode = $anime->find('div.header_info_episode', 0)
|
||||||
or returnServerError('Could not find anime episode information!');
|
or throwServerException('Could not find anime episode information!');
|
||||||
|
|
||||||
$retVal = preg_replace('/\r|\n/', ' ', $episode->plaintext);
|
$retVal = preg_replace('/\r|\n/', ' ', $episode->plaintext);
|
||||||
$retVal = preg_replace('/\s+/', ' ', $retVal);
|
$retVal = preg_replace('/\s+/', ' ', $retVal);
|
||||||
|
@ -162,7 +162,7 @@ class ShanaprojectBridge extends BridgeAbstract
|
||||||
return $matches[1];
|
return $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
returnServerError('Could not extract background image!');
|
throwServerException('Could not extract background image!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Builds an URI to search for a specific anime (subber is left empty)
|
// Builds an URI to search for a specific anime (subber is left empty)
|
||||||
|
|
|
@ -85,7 +85,7 @@ class SitemapBridge extends CssSelectorBridge
|
||||||
$links = $this->sitemapXmlToList($sitemap_xml, $url_pattern, empty($limit) ? 10 : $limit);
|
$links = $this->sitemapXmlToList($sitemap_xml, $url_pattern, empty($limit) ? 10 : $limit);
|
||||||
|
|
||||||
if (empty($links) && empty($this->sitemapXmlToList($sitemap_xml))) {
|
if (empty($links) && empty($this->sitemapXmlToList($sitemap_xml))) {
|
||||||
returnClientError('Could not retrieve URLs with Timestamps from Sitemap: ' . $sitemap_url);
|
throwClientException('Could not retrieve URLs with Timestamps from Sitemap: ' . $sitemap_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
|
@ -117,7 +117,7 @@ class SitemapBridge extends CssSelectorBridge
|
||||||
$url = urljoin($url, '/sitemap.xml');
|
$url = urljoin($url, '/sitemap.xml');
|
||||||
return $sitemap;
|
return $sitemap;
|
||||||
} else {
|
} else {
|
||||||
returnClientError('Failed to locate Sitemap from /robots.txt or /sitemap.xml. Try setting it manually.');
|
throwClientException('Failed to locate Sitemap from /robots.txt or /sitemap.xml. Try setting it manually.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$url = $matches[1];
|
$url = $matches[1];
|
||||||
|
|
|
@ -562,7 +562,7 @@ class SkimfeedBridge extends BridgeAbstract
|
||||||
private function extractFeed($html, $author)
|
private function extractFeed($html, $author)
|
||||||
{
|
{
|
||||||
$articles = $html->find('li')
|
$articles = $html->find('li')
|
||||||
or returnServerError('Could not find articles!');
|
or throwServerException('Could not find articles!');
|
||||||
|
|
||||||
if (
|
if (
|
||||||
count($articles) === 1
|
count($articles) === 1
|
||||||
|
@ -575,7 +575,7 @@ class SkimfeedBridge extends BridgeAbstract
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$anchor = $article->find('a', 0)
|
$anchor = $article->find('a', 0)
|
||||||
or returnServerError('Could not find anchor!');
|
or throwServerException('Could not find anchor!');
|
||||||
|
|
||||||
$item = [];
|
$item = [];
|
||||||
|
|
||||||
|
@ -600,13 +600,13 @@ class SkimfeedBridge extends BridgeAbstract
|
||||||
private function extractHotTopics($html)
|
private function extractHotTopics($html)
|
||||||
{
|
{
|
||||||
$topics = $html->find('#popbox ul li')
|
$topics = $html->find('#popbox ul li')
|
||||||
or returnServerError('Could not find topics!');
|
or throwServerException('Could not find topics!');
|
||||||
|
|
||||||
$limit = $this->getInput('limit') ?: -1;
|
$limit = $this->getInput('limit') ?: -1;
|
||||||
|
|
||||||
foreach ($topics as $topic) {
|
foreach ($topics as $topic) {
|
||||||
$anchor = $topic->find('a', 0)
|
$anchor = $topic->find('a', 0)
|
||||||
or returnServerError('Could not find anchor!');
|
or throwServerException('Could not find anchor!');
|
||||||
|
|
||||||
$item = [];
|
$item = [];
|
||||||
|
|
||||||
|
@ -624,11 +624,11 @@ class SkimfeedBridge extends BridgeAbstract
|
||||||
private function extractCustomFeed($html)
|
private function extractCustomFeed($html)
|
||||||
{
|
{
|
||||||
$boxes = $html->find('#boxx .boxes')
|
$boxes = $html->find('#boxx .boxes')
|
||||||
or returnServerError('Could not find boxes!');
|
or throwServerException('Could not find boxes!');
|
||||||
|
|
||||||
foreach ($boxes as $box) {
|
foreach ($boxes as $box) {
|
||||||
$anchor = $box->find('span.boxtitles a', 0)
|
$anchor = $box->find('span.boxtitles a', 0)
|
||||||
or returnServerError('Could not find box anchor!');
|
or throwServerException('Could not find box anchor!');
|
||||||
|
|
||||||
$author = '<a href="' . $anchor->href . '">' . trim($anchor->plaintext) . '</a>';
|
$author = '<a href="' . $anchor->href . '">' . trim($anchor->plaintext) . '</a>';
|
||||||
$uri = $anchor->href;
|
$uri = $anchor->href;
|
||||||
|
@ -667,11 +667,11 @@ class SkimfeedBridge extends BridgeAbstract
|
||||||
$html = getSimpleHTMLDOMCached(static::URI);
|
$html = getSimpleHTMLDOMCached(static::URI);
|
||||||
|
|
||||||
if (!$this->isCompatible($html)) {
|
if (!$this->isCompatible($html)) {
|
||||||
returnServerError('Skimfeed version is not compatible!');
|
throwServerException('Skimfeed version is not compatible!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$boxes = $html->find('#boxx .boxes')
|
$boxes = $html->find('#boxx .boxes')
|
||||||
or returnServerError('Could not find boxes!');
|
or throwServerException('Could not find boxes!');
|
||||||
|
|
||||||
// begin of 'channel' list
|
// begin of 'channel' list
|
||||||
$message = <<<EOD
|
$message = <<<EOD
|
||||||
|
@ -686,7 +686,7 @@ EOD;
|
||||||
|
|
||||||
foreach ($boxes as $box) {
|
foreach ($boxes as $box) {
|
||||||
$anchor = $box->find('span.boxtitles a', 0)
|
$anchor = $box->find('span.boxtitles a', 0)
|
||||||
or returnServerError('Could not find box anchor!');
|
or throwServerException('Could not find box anchor!');
|
||||||
|
|
||||||
$title = trim($anchor->plaintext);
|
$title = trim($anchor->plaintext);
|
||||||
$uri = $anchor->href;
|
$uri = $anchor->href;
|
||||||
|
@ -723,11 +723,11 @@ EOD;
|
||||||
$html = getSimpleHTMLDOMCached(static::URI);
|
$html = getSimpleHTMLDOMCached(static::URI);
|
||||||
|
|
||||||
if (!$this->isCompatible($html)) {
|
if (!$this->isCompatible($html)) {
|
||||||
returnServerError('Skimfeed version is not compatible!');
|
throwServerException('Skimfeed version is not compatible!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$channels = $html->find('#menubar a')
|
$channels = $html->find('#menubar a')
|
||||||
or returnServerError('Could not find channels!');
|
or throwServerException('Could not find channels!');
|
||||||
|
|
||||||
// begin of 'tech_channel' list
|
// begin of 'tech_channel' list
|
||||||
$message = <<<EOD
|
$message = <<<EOD
|
||||||
|
@ -759,11 +759,11 @@ EOD;
|
||||||
$channel_html = getSimpleHTMLDOMCached(static::URI . $uri);
|
$channel_html = getSimpleHTMLDOMCached(static::URI . $uri);
|
||||||
|
|
||||||
$boxes = $channel_html->find('#boxx .boxes')
|
$boxes = $channel_html->find('#boxx .boxes')
|
||||||
or returnServerError('Could not find boxes!');
|
or throwServerException('Could not find boxes!');
|
||||||
|
|
||||||
foreach ($boxes as $box) {
|
foreach ($boxes as $box) {
|
||||||
$anchor = $box->find('span.boxtitles a', 0)
|
$anchor = $box->find('span.boxtitles a', 0)
|
||||||
or returnServerError('Could not find box anchor!');
|
or throwServerException('Could not find box anchor!');
|
||||||
|
|
||||||
$boxtitle = trim($anchor->plaintext);
|
$boxtitle = trim($anchor->plaintext);
|
||||||
$boxuri = $anchor->href;
|
$boxuri = $anchor->href;
|
||||||
|
|
|
@ -48,7 +48,7 @@ class SoundCloudBridge extends BridgeAbstract
|
||||||
$this->feedIcon = $res->avatar_url;
|
$this->feedIcon = $res->avatar_url;
|
||||||
|
|
||||||
$apiItems = $this->getUserItems($res->id, $this->getInput('t'))
|
$apiItems = $this->getUserItems($res->id, $this->getInput('t'))
|
||||||
or returnServerError('No results for ' . $this->getInput('t'));
|
or throwServerException('No results for ' . $this->getInput('t'));
|
||||||
|
|
||||||
$hasTrackObject = ['all', 'reposts', 'likes'];
|
$hasTrackObject = ['all', 'reposts', 'likes'];
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ HTML;
|
||||||
|
|
||||||
// Extract widget JS filenames from player page
|
// Extract widget JS filenames from player page
|
||||||
if (preg_match_all($this->widgetRegex, $playerHTML, $matches) == false) {
|
if (preg_match_all($this->widgetRegex, $playerHTML, $matches) == false) {
|
||||||
returnServerError('Unable to find widget JS URL.');
|
throwServerException('Unable to find widget JS URL.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$clientID = '';
|
$clientID = '';
|
||||||
|
@ -150,7 +150,7 @@ HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($clientID)) {
|
if (empty($clientID)) {
|
||||||
returnServerError('Unable to find client ID.');
|
throwServerException('Unable to find client ID.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ class SpotifyBridge extends BridgeAbstract
|
||||||
if ($e->getCode() === 429) {
|
if ($e->getCode() === 429) {
|
||||||
$retryAfter = $e->response->getHeader('Retry-After') ?? (60 * 5);
|
$retryAfter = $e->response->getHeader('Retry-After') ?? (60 * 5);
|
||||||
$this->cache->set($cacheKey, true, $retryAfter);
|
$this->cache->set($cacheKey, true, $retryAfter);
|
||||||
throw new RateLimitException(sprintf('Rate limited by spotify, try again in %s seconds', $retryAfter));
|
throwRateLimitException(sprintf('Rate limited by spotify, try again in %s seconds', $retryAfter));
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ class StockFilingsBridge extends FeedExpander
|
||||||
if ($rssFeedUrl) {
|
if ($rssFeedUrl) {
|
||||||
parent::collectExpandableDatas($rssFeedUrl);
|
parent::collectExpandableDatas($rssFeedUrl);
|
||||||
} else {
|
} else {
|
||||||
returnClientError('Could not find RSS Feed URL. Are you sure you used a valid CIK?');
|
throwClientException('Could not find RSS Feed URL. Are you sure you used a valid CIK?');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ class StorytelBridge extends BridgeAbstract
|
||||||
$url = $this->getInput('url');
|
$url = $this->getInput('url');
|
||||||
|
|
||||||
if (!preg_match('/^https:\/\/www\.storytel\.com/', $url)) {
|
if (!preg_match('/^https:\/\/www\.storytel\.com/', $url)) {
|
||||||
returnServerError('Invalid URL: Only Storytel URLs are allowed.');
|
throwServerException('Invalid URL: Only Storytel URLs are allowed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM($url);
|
$html = getSimpleHTMLDOM($url);
|
||||||
|
|
|
@ -30,7 +30,7 @@ class StravaBridge extends BridgeAbstract
|
||||||
|
|
||||||
$dom = getSimpleHTMLDOM(self::URI . '/athletes/' . $athleteID);
|
$dom = getSimpleHTMLDOM(self::URI . '/athletes/' . $athleteID);
|
||||||
$scriptRegex = "/data-react-props='(.*?)'/";
|
$scriptRegex = "/data-react-props='(.*?)'/";
|
||||||
preg_match($scriptRegex, $dom, $matches) or returnServerError('Could not find json');
|
preg_match($scriptRegex, $dom, $matches) or throwServerException('Could not find json');
|
||||||
$jsonData = json_decode(html_entity_decode($matches[1]));
|
$jsonData = json_decode(html_entity_decode($matches[1]));
|
||||||
$this->feedName = $jsonData->athlete->name . "'s Recent Activities";
|
$this->feedName = $jsonData->athlete->name . "'s Recent Activities";
|
||||||
$this->iconURL = $jsonData->athlete->avatarUrl;
|
$this->iconURL = $jsonData->athlete->avatarUrl;
|
||||||
|
|
|
@ -24,7 +24,7 @@ class StreamCzBridge extends BridgeAbstract
|
||||||
|
|
||||||
$validUrl = '/^(https:\/\/www.stream.cz\/[a-z0-9-]+)(\/[a-z0-9-]+-\d+)?$/';
|
$validUrl = '/^(https:\/\/www.stream.cz\/[a-z0-9-]+)(\/[a-z0-9-]+-\d+)?$/';
|
||||||
if (!preg_match($validUrl, $url, $match)) {
|
if (!preg_match($validUrl, $url, $match)) {
|
||||||
returnServerError('Invalid url');
|
throwServerException('Invalid url');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fixedUrl = $match[1];
|
$fixedUrl = $match[1];
|
||||||
|
@ -35,25 +35,25 @@ class StreamCzBridge extends BridgeAbstract
|
||||||
|
|
||||||
$scriptElement = $html->find('body script', -1);
|
$scriptElement = $html->find('body script', -1);
|
||||||
if (null === $scriptElement) {
|
if (null === $scriptElement) {
|
||||||
returnServerError('Could not find metadata element on the page');
|
throwServerException('Could not find metadata element on the page');
|
||||||
}
|
}
|
||||||
$json = extractFromDelimiters($scriptElement->innertext, 'data : ', 'logs : ');
|
$json = extractFromDelimiters($scriptElement->innertext, 'data : ', 'logs : ');
|
||||||
if (false === $json) {
|
if (false === $json) {
|
||||||
returnServerError('Could not extract metadata from the page');
|
throwServerException('Could not extract metadata from the page');
|
||||||
}
|
}
|
||||||
$data = json_decode(trim($json, ",\t\n\r\0\x0B"), true);
|
$data = json_decode(trim($json, ",\t\n\r\0\x0B"), true);
|
||||||
if (false === $data) {
|
if (false === $data) {
|
||||||
returnServerError('Could not parse metadata on the page');
|
throwServerException('Could not parse metadata on the page');
|
||||||
}
|
}
|
||||||
|
|
||||||
$showData = $data['fetchable']['tag']['show']['data'];
|
$showData = $data['fetchable']['tag']['show']['data'];
|
||||||
if (!is_array($showData)) {
|
if (!is_array($showData)) {
|
||||||
returnServerError('Show not found in metadata');
|
throwServerException('Show not found in metadata');
|
||||||
}
|
}
|
||||||
$this->feedName = $showData['name'];
|
$this->feedName = $showData['name'];
|
||||||
$episodes = $showData['allEpisodesConnection']['edges'];
|
$episodes = $showData['allEpisodesConnection']['edges'];
|
||||||
if (!is_array($episodes)) {
|
if (!is_array($episodes)) {
|
||||||
returnServerError('Episodes not found in metadata');
|
throwServerException('Episodes not found in metadata');
|
||||||
}
|
}
|
||||||
foreach ($episodes as $episode) {
|
foreach ($episodes as $episode) {
|
||||||
if (!$episode['node']) {
|
if (!$episode['node']) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ class ThePirateBayBridge extends BridgeAbstract
|
||||||
$query = sprintf('/q.php?q=user:%s', rawurlencode($keyword));
|
$query = sprintf('/q.php?q=user:%s', rawurlencode($keyword));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnClientError('Impossible');
|
throwClientException('Impossible');
|
||||||
}
|
}
|
||||||
$api = 'https://apibay.org';
|
$api = 'https://apibay.org';
|
||||||
$json = getContents($api . $query);
|
$json = getContents($api . $query);
|
||||||
|
|
|
@ -616,7 +616,7 @@ class TrelloBridge extends BridgeAbstract
|
||||||
$data = $this->queryAPI('cards/' . $this->getInput('c'), $apiParams);
|
$data = $this->queryAPI('cards/' . $this->getInput('c'), $apiParams);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnClientError('Invalid context');
|
throwClientException('Invalid context');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->feedName = $data->name;
|
$this->feedName = $data->name;
|
||||||
|
|
|
@ -289,19 +289,19 @@ EOD
|
||||||
$data = $api->fetchListTweets($query, $this->queriedContext);
|
$data = $api->fetchListTweets($query, $this->queriedContext);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnServerError('Invalid query context !');
|
throwServerException('Invalid query context !');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
switch ($this->queriedContext) {
|
switch ($this->queriedContext) {
|
||||||
case 'By keyword or hashtag':
|
case 'By keyword or hashtag':
|
||||||
returnServerError('twitter: No results for this query.');
|
throwServerException('twitter: No results for this query.');
|
||||||
// fall-through
|
// fall-through
|
||||||
case 'By username':
|
case 'By username':
|
||||||
returnServerError('Requested username can\'t be found.');
|
throwServerException('Requested username can\'t be found.');
|
||||||
// fall-through
|
// fall-through
|
||||||
case 'By list':
|
case 'By list':
|
||||||
returnServerError('Requested username or list can\'t be found');
|
throwServerException('Requested username or list can\'t be found');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ EOD
|
||||||
. $this->getInput('u'), $authHeaders, $params);
|
. $this->getInput('u'), $authHeaders, $params);
|
||||||
|
|
||||||
if (isset($user->errors)) {
|
if (isset($user->errors)) {
|
||||||
returnServerError('Requested username can\'t be found.');
|
throwServerException('Requested username can\'t be found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default params
|
// Set default params
|
||||||
|
@ -258,7 +258,7 @@ EOD
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
returnServerError('Invalid query context !');
|
throwServerException('Invalid query context !');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -267,13 +267,13 @@ EOD
|
||||||
) {
|
) {
|
||||||
switch ($this->queriedContext) {
|
switch ($this->queriedContext) {
|
||||||
case 'By keyword or hashtag':
|
case 'By keyword or hashtag':
|
||||||
returnServerError('No results for this query.');
|
throwServerException('No results for this query.');
|
||||||
// fall-through
|
// fall-through
|
||||||
case 'By username':
|
case 'By username':
|
||||||
returnServerError('Requested username cannnot be found.');
|
throwServerException('Requested username cannnot be found.');
|
||||||
// fall-through
|
// fall-through
|
||||||
case 'By list ID':
|
case 'By list ID':
|
||||||
returnServerError('Requested list cannnot be found');
|
throwServerException('Requested list cannnot be found');
|
||||||
// fall-through
|
// fall-through
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class UrlebirdBridge extends BridgeAbstract
|
||||||
$url = 'https://urlebird.com/hash/' . substr($this->getInput('query'), 1) . '/';
|
$url = 'https://urlebird.com/hash/' . substr($this->getInput('query'), 1) . '/';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnServerError('Please, enter valid username or hashtag!');
|
throwServerException('Please, enter valid username or hashtag!');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ final class UsenixBridge extends BridgeAbstract
|
||||||
$this->collectLoginOnlineItems();
|
$this->collectLoginOnlineItems();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
returnClientError('Illegal Context');
|
throwClientException('Illegal Context');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function collectLoginOnlineItems(): void
|
private function collectLoginOnlineItems(): void
|
||||||
|
|
|
@ -81,7 +81,7 @@ class VimeoBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($json)) {
|
if (is_null($json)) {
|
||||||
returnClientError('No results for this query!');
|
throwClientException('No results for this query!');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($json->api->initial_json->data as $element) {
|
foreach ($json->api->initial_json->data as $element) {
|
||||||
|
@ -103,7 +103,7 @@ class VimeoBridge extends BridgeAbstract
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
returnServerError('Unknown type: ' . $element->type);
|
throwServerException('Unknown type: ' . $element->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ class Vk2Bridge extends BridgeAbstract
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
if ($this->cache->get($this->rateLimitCacheKey)) {
|
if ($this->cache->get($this->rateLimitCacheKey)) {
|
||||||
throw new RateLimitException();
|
throwRateLimitException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$u = $this->getInput('u');
|
$u = $this->getInput('u');
|
||||||
|
@ -229,7 +229,7 @@ class Vk2Bridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($ownerId)) {
|
if (is_null($ownerId)) {
|
||||||
returnServerError('Could not detect owner id');
|
throwServerException('Could not detect owner id');
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = $this->api('wall.get', [
|
$r = $this->api('wall.get', [
|
||||||
|
@ -304,7 +304,7 @@ class Vk2Bridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
$access_token = $this->getOption('access_token');
|
$access_token = $this->getOption('access_token');
|
||||||
if (!$access_token) {
|
if (!$access_token) {
|
||||||
returnServerError('You cannot run VK API methods without access_token');
|
throwServerException('You cannot run VK API methods without access_token');
|
||||||
}
|
}
|
||||||
$params['v'] = '5.131';
|
$params['v'] = '5.131';
|
||||||
$r = json_decode(
|
$r = json_decode(
|
||||||
|
@ -322,7 +322,7 @@ class Vk2Bridge extends BridgeAbstract
|
||||||
// if that limit is hit, VK returns error 29
|
// if that limit is hit, VK returns error 29
|
||||||
$this->cache->set($this->rateLimitCacheKey, true, 60 * 30);
|
$this->cache->set($this->rateLimitCacheKey, true, 60 * 30);
|
||||||
}
|
}
|
||||||
returnServerError('API returned error: ' . $r['error']['error_msg'] . ' (' . $r['error']['error_code'] . ')');
|
throwServerException('API returned error: ' . $r['error']['error_msg'] . ' (' . $r['error']['error_code'] . ')');
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,17 +526,17 @@ class VkBridge extends BridgeAbstract
|
||||||
$uri = urljoin(self::URI, $headers['location'][0]);
|
$uri = urljoin(self::URI, $headers['location'][0]);
|
||||||
|
|
||||||
if (str_contains($uri, '/429.html')) {
|
if (str_contains($uri, '/429.html')) {
|
||||||
throw new RateLimitException();
|
throwRateLimitException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match('#^https?://vk.com/#', $uri)) {
|
if (!preg_match('#^https?://vk.com/#', $uri)) {
|
||||||
returnServerError('Unexpected redirect location: ' . $uri);
|
throwServerException('Unexpected redirect location: ' . $uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
$redirects++;
|
$redirects++;
|
||||||
}
|
}
|
||||||
|
|
||||||
returnServerError('Too many redirects, while retreving content from VK');
|
throwServerException('Too many redirects, while retreving content from VK');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function appendVideo($video_title, $video_link, $previewImg, &$content_suffix)
|
protected function appendVideo($video_title, $video_link, $previewImg, &$content_suffix)
|
||||||
|
|
|
@ -61,7 +61,7 @@ class WebfailBridge extends BridgeAbstract
|
||||||
$this->extractArticle($html);
|
$this->extractArticle($html);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnClientError('Unknown type: ' . $type);
|
throwClientException('Unknown type: ' . $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class WikipediaBridge extends BridgeAbstract
|
||||||
$function = 'getContents' . ucfirst(strtolower($this->getInput('language')));
|
$function = 'getContents' . ucfirst(strtolower($this->getInput('language')));
|
||||||
|
|
||||||
if (!method_exists($this, $function)) {
|
if (!method_exists($this, $function)) {
|
||||||
returnServerError('A function to get the contents for your language is missing (\'' . $function . '\')!');
|
throwServerException('A function to get the contents for your language is missing (\'' . $function . '\')!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -205,13 +205,13 @@ class WikipediaBridge extends BridgeAbstract
|
||||||
$content_html = getSimpleHTMLDOMCached($uri);
|
$content_html = getSimpleHTMLDOMCached($uri);
|
||||||
|
|
||||||
if (!$content_html) {
|
if (!$content_html) {
|
||||||
returnServerError('Could not load site: ' . $uri . '!');
|
throwServerException('Could not load site: ' . $uri . '!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $content_html->find('#mw-content-text', 0);
|
$content = $content_html->find('#mw-content-text', 0);
|
||||||
|
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
returnServerError('Could not find content in page: ' . $uri . '!');
|
throwServerException('Could not find content in page: ' . $uri . '!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's remove a couple of things from the article
|
// Let's remove a couple of things from the article
|
||||||
|
|
|
@ -32,7 +32,7 @@ class WiredBridge extends FeedExpander
|
||||||
{
|
{
|
||||||
$feed = $this->getInput('feed');
|
$feed = $this->getInput('feed');
|
||||||
if (empty($feed) || !ctype_alpha(str_replace('-', '', $feed))) {
|
if (empty($feed) || !ctype_alpha(str_replace('-', '', $feed))) {
|
||||||
returnClientError('Invalid feed, please check the "feed" parameter.');
|
throwClientException('Invalid feed, please check the "feed" parameter.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$feed_url = $this->getURI() . 'feed/';
|
$feed_url = $this->getURI() . 'feed/';
|
||||||
|
|
|
@ -25,7 +25,7 @@ class WordPressBridge extends FeedExpander
|
||||||
$limit = $this->getInput('limit') ?? 10;
|
$limit = $this->getInput('limit') ?? 10;
|
||||||
if ($this->getInput('url') && substr($this->getInput('url'), 0, strlen('http')) !== 'http') {
|
if ($this->getInput('url') && substr($this->getInput('url'), 0, strlen('http')) !== 'http') {
|
||||||
// just in case someone find a way to access local files by playing with the url
|
// just in case someone find a way to access local files by playing with the url
|
||||||
returnClientError('The url parameter must either refer to http or https protocol.');
|
throwClientException('The url parameter must either refer to http or https protocol.');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$this->collectExpandableDatas($this->getURI() . '/feed/atom/', $limit);
|
$this->collectExpandableDatas($this->getURI() . '/feed/atom/', $limit);
|
||||||
|
|
|
@ -81,24 +81,24 @@ class XenForoBridge extends BridgeAbstract
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->threadurl === false) {
|
if ($this->threadurl === false) {
|
||||||
returnClientError('The URL you provided is invalid!');
|
throwClientException('The URL you provided is invalid!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$urlparts = parse_url($this->threadurl, PHP_URL_SCHEME);
|
$urlparts = parse_url($this->threadurl, PHP_URL_SCHEME);
|
||||||
|
|
||||||
// Scheme must be "http" or "https"
|
// Scheme must be "http" or "https"
|
||||||
if (preg_match('/http[s]{0,1}/', parse_url($this->threadurl, PHP_URL_SCHEME)) == false) {
|
if (preg_match('/http[s]{0,1}/', parse_url($this->threadurl, PHP_URL_SCHEME)) == false) {
|
||||||
returnClientError('The URL you provided doesn\'t specify a valid scheme (http or https)!');
|
throwClientException('The URL you provided doesn\'t specify a valid scheme (http or https)!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path cannot be root (../)
|
// Path cannot be root (../)
|
||||||
if (parse_url($this->threadurl, PHP_URL_PATH) === '/') {
|
if (parse_url($this->threadurl, PHP_URL_PATH) === '/') {
|
||||||
returnClientError('The URL you provided doesn\'t link to a valid thread (root path)!');
|
throwClientException('The URL you provided doesn\'t link to a valid thread (root path)!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// XenForo adds a thread ID to the URL, like "...-thread.454934283". It must be present
|
// XenForo adds a thread ID to the URL, like "...-thread.454934283". It must be present
|
||||||
if (preg_match('/.+\.\d+[\/]{0,1}/', parse_URL($this->threadurl, PHP_URL_PATH)) == false) {
|
if (preg_match('/.+\.\d+[\/]{0,1}/', parse_URL($this->threadurl, PHP_URL_PATH)) == false) {
|
||||||
returnClientError('The URL you provided doesn\'t link to a valid thread (ID missing)!');
|
throwClientException('The URL you provided doesn\'t link to a valid thread (ID missing)!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to start at the first page in the thread. XenForo uses "../page-n" syntax
|
// We want to start at the first page in the thread. XenForo uses "../page-n" syntax
|
||||||
|
@ -121,13 +121,13 @@ class XenForoBridge extends BridgeAbstract
|
||||||
} elseif ($mainContent = $html->find('div[class~="p-body"]', 0)) {
|
} elseif ($mainContent = $html->find('div[class~="p-body"]', 0)) {
|
||||||
$this->version = self::XENFORO_VERSION_2;
|
$this->version = self::XENFORO_VERSION_2;
|
||||||
} else {
|
} else {
|
||||||
returnServerError('This forum is currently not supported!');
|
throwServerException('This forum is currently not supported!');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($this->version) {
|
switch ($this->version) {
|
||||||
case self::XENFORO_VERSION_1:
|
case self::XENFORO_VERSION_1:
|
||||||
$titleBar = $mainContent->find('div.titleBar > h1', 0)
|
$titleBar = $mainContent->find('div.titleBar > h1', 0)
|
||||||
or returnServerError('Error finding title bar!');
|
or throwServerException('Error finding title bar!');
|
||||||
|
|
||||||
$this->title = $titleBar->plaintext;
|
$this->title = $titleBar->plaintext;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class XenForoBridge extends BridgeAbstract
|
||||||
|
|
||||||
case self::XENFORO_VERSION_2:
|
case self::XENFORO_VERSION_2:
|
||||||
$titleBar = $mainContent->find('div[class~="p-title"] h1', 0)
|
$titleBar = $mainContent->find('div[class~="p-title"] h1', 0)
|
||||||
or returnServerError('Error finding title bar!');
|
or throwServerException('Error finding title bar!');
|
||||||
|
|
||||||
$this->title = $titleBar->plaintext;
|
$this->title = $titleBar->plaintext;
|
||||||
$this->extractThreadPostsV2($html, $this->threadurl);
|
$this->extractThreadPostsV2($html, $this->threadurl);
|
||||||
|
@ -166,7 +166,7 @@ class XenForoBridge extends BridgeAbstract
|
||||||
|
|
||||||
// Posts are contained in an "ol"
|
// Posts are contained in an "ol"
|
||||||
$messageList = $html->find('#messageList > li')
|
$messageList = $html->find('#messageList > li')
|
||||||
or returnServerError('Error finding message list!');
|
or throwServerException('Error finding message list!');
|
||||||
|
|
||||||
foreach ($messageList as $post) {
|
foreach ($messageList as $post) {
|
||||||
if (!isset($post->attr['id'])) { // Skip ads
|
if (!isset($post->attr['id'])) { // Skip ads
|
||||||
|
@ -252,7 +252,7 @@ class XenForoBridge extends BridgeAbstract
|
||||||
$lang = $html->find('html', 0)->lang;
|
$lang = $html->find('html', 0)->lang;
|
||||||
|
|
||||||
$messageList = $html->find('div[class~="block-body"] article')
|
$messageList = $html->find('div[class~="block-body"] article')
|
||||||
or returnServerError('Error finding message list!');
|
or throwServerException('Error finding message list!');
|
||||||
|
|
||||||
foreach ($messageList as $post) {
|
foreach ($messageList as $post) {
|
||||||
if (!isset($post->attr['id'])) { // Skip ads
|
if (!isset($post->attr['id'])) { // Skip ads
|
||||||
|
|
|
@ -47,7 +47,7 @@ class YandexZenBridge extends BridgeAbstract
|
||||||
$channelName = $matches['channelName'];
|
$channelName = $matches['channelName'];
|
||||||
$channelAPIURL = self::_BASE_API_URL_WITH_CHANNEL_NAME . $channelName;
|
$channelAPIURL = self::_BASE_API_URL_WITH_CHANNEL_NAME . $channelName;
|
||||||
} else {
|
} else {
|
||||||
returnClientError(<<<EOT
|
throwClientException(<<<EOT
|
||||||
Invalid channel URL provided.
|
Invalid channel URL provided.
|
||||||
The channel\'s URL must be in one of these two forms:
|
The channel\'s URL must be in one of these two forms:
|
||||||
- https://dzen.ru/dream_faity_diy
|
- https://dzen.ru/dream_faity_diy
|
||||||
|
|
|
@ -79,7 +79,7 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
$this->feedName ??= '';
|
$this->feedName ??= '';
|
||||||
|
|
||||||
if ($this->hasPostsTab($json) === false) {
|
if ($this->hasPostsTab($json) === false) {
|
||||||
returnServerError('Channel does not have a posts tab');
|
throwServerException('Channel does not have a posts tab');
|
||||||
}
|
}
|
||||||
|
|
||||||
$posts = $this->getPosts($json);
|
$posts = $this->getPosts($json);
|
||||||
|
@ -156,13 +156,13 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
private function extractJson($html)
|
private function extractJson($html)
|
||||||
{
|
{
|
||||||
if (!preg_match($this->jsonRegex, $html, $parts)) {
|
if (!preg_match($this->jsonRegex, $html, $parts)) {
|
||||||
returnServerError('Failed to extract data from page');
|
throwServerException('Failed to extract data from page');
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = json_decode($parts[1]);
|
$data = json_decode($parts[1]);
|
||||||
|
|
||||||
if ($data === false) {
|
if ($data === false) {
|
||||||
returnServerError('Failed to decode extracted data');
|
throwServerException('Failed to decode extracted data');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
|
@ -75,14 +75,14 @@ class YoutubeBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
$cacheKey = 'youtube_rate_limit';
|
$cacheKey = 'youtube_rate_limit';
|
||||||
if ($this->cache->get($cacheKey)) {
|
if ($this->cache->get($cacheKey)) {
|
||||||
throw new RateLimitException();
|
throwRateLimitException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$this->collectDataInternal();
|
$this->collectDataInternal();
|
||||||
} catch (HttpException $e) {
|
} catch (HttpException $e) {
|
||||||
if ($e->getCode() === 429) {
|
if ($e->getCode() === 429) {
|
||||||
$this->cache->set($cacheKey, true, 60 * 16);
|
$this->cache->set($cacheKey, true, 60 * 16);
|
||||||
throw new RateLimitException();
|
throwRateLimitException();
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ class YoutubeBridge extends BridgeAbstract
|
||||||
// $jsonData = $jsonData->itemSectionRenderer->contents[0]->gridRenderer->items;
|
// $jsonData = $jsonData->itemSectionRenderer->contents[0]->gridRenderer->items;
|
||||||
$this->fetchItemsFromFromJsonData($jsonData);
|
$this->fetchItemsFromFromJsonData($jsonData);
|
||||||
} else {
|
} else {
|
||||||
returnServerError('Unable to get data from YouTube');
|
throwServerException('Unable to get data from YouTube');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fetch the xml feed
|
// Fetch the xml feed
|
||||||
|
@ -192,7 +192,7 @@ class YoutubeBridge extends BridgeAbstract
|
||||||
$this->feeduri = $url_listing;
|
$this->feeduri = $url_listing;
|
||||||
$this->feedName = 'Search: ' . $search;
|
$this->feedName = 'Search: ' . $search;
|
||||||
} else {
|
} else {
|
||||||
returnClientError("You must either specify either:\n - YouTube username (?u=...)\n - Channel id (?c=...)\n - Playlist id (?p=...)\n - Search (?s=...)");
|
throwClientException("You must either specify either:\n - YouTube username (?u=...)\n - Channel id (?c=...)\n - Playlist id (?p=...)\n - Search (?s=...)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ class YoutubeBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$videoSecondaryInfo) {
|
if (!$videoSecondaryInfo) {
|
||||||
returnServerError('Could not find videoSecondaryInfoRenderer. Error at: ' . $videoId);
|
throwServerException('Could not find videoSecondaryInfoRenderer. Error at: ' . $videoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$description = $videoSecondaryInfo->attributedDescription->content ?? '';
|
$description = $videoSecondaryInfo->attributedDescription->content ?? '';
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ZonebourseBridge extends BridgeAbstract
|
||||||
$articles = $dom->find('table#newsScreener tbody tr');
|
$articles = $dom->find('table#newsScreener tbody tr');
|
||||||
|
|
||||||
if (!$articles) {
|
if (!$articles) {
|
||||||
returnServerError('Failed to retrieve news content');
|
throwServerException('Failed to retrieve news content');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
|
@ -87,23 +87,22 @@ $html = getSimpleHTMLDOMCached('your URI', 86400); // Duration 24h
|
||||||
|
|
||||||
[Defined in lib/contents.php](https://github.com/RSS-Bridge/rss-bridge/blob/master/lib/contents.php)
|
[Defined in lib/contents.php](https://github.com/RSS-Bridge/rss-bridge/blob/master/lib/contents.php)
|
||||||
|
|
||||||
# returnClientError
|
# throwClientException($message = '')
|
||||||
The `returnClientError` function aborts execution of the current bridge
|
The `throwClientException` function aborts execution of the current bridge.
|
||||||
and returns the given error message with error code **400**:
|
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
returnClientError('Your error message')
|
throwClientException('Bad user input')
|
||||||
```
|
```
|
||||||
|
|
||||||
Use this function when the user provided invalid parameter or a required parameter is missing.
|
Use this function when the user provided invalid parameter or a required parameter is missing.
|
||||||
|
|
||||||
[Defined in lib/utils.php](https://github.com/RSS-Bridge/rss-bridge/blob/master/lib/utils.php)
|
[Defined in lib/utils.php](https://github.com/RSS-Bridge/rss-bridge/blob/master/lib/utils.php)
|
||||||
|
|
||||||
# returnServerError
|
# throwServerException($message = '')
|
||||||
The `returnServerError` function aborts execution of the current bridge and returns the given error message with error code **500**:
|
The `throwServerException` function aborts execution of the current bridge.
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
returnServerError('Your error message')
|
throwServerException('Received empty reply from thirdparty api')
|
||||||
```
|
```
|
||||||
|
|
||||||
Use this function when a problem occurs that has nothing to do with the parameters provided by the user.
|
Use this function when a problem occurs that has nothing to do with the parameters provided by the user.
|
||||||
|
@ -111,6 +110,10 @@ Use this function when a problem occurs that has nothing to do with the paramete
|
||||||
|
|
||||||
[Defined in lib/utils.php](https://github.com/RSS-Bridge/rss-bridge/blob/master/lib/utils.php)
|
[Defined in lib/utils.php](https://github.com/RSS-Bridge/rss-bridge/blob/master/lib/utils.php)
|
||||||
|
|
||||||
|
# throwRateLimitException($message = '')
|
||||||
|
|
||||||
|
Throws a `RateLimitException` which produces an HTTP 429 response.
|
||||||
|
|
||||||
# defaultLinkTo
|
# defaultLinkTo
|
||||||
Automatically replaces any relative URL in a given string or DOM object
|
Automatically replaces any relative URL in a given string or DOM object
|
||||||
(i.e. the one returned by [getSimpleHTMLDOM](#getsimplehtmldom)) with an absolute URL.
|
(i.e. the one returned by [getSimpleHTMLDOM](#getsimplehtmldom)) with an absolute URL.
|
||||||
|
|
|
@ -242,12 +242,33 @@ function create_random_string(int $bytes = 16): string
|
||||||
return bin2hex(openssl_random_pseudo_bytes($bytes));
|
return bin2hex(openssl_random_pseudo_bytes($bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
function returnClientError($message)
|
function throwClientException(string $message = '')
|
||||||
{
|
{
|
||||||
throw new \Exception($message, 400);
|
throw new \Exception($message, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
function returnServerError($message)
|
function throwServerException(string $message = '')
|
||||||
{
|
{
|
||||||
throw new \Exception($message, 500);
|
throw new \Exception($message, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function throwRateLimitException(string $message = '')
|
||||||
|
{
|
||||||
|
throw new RateLimitException($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use throwClientException() instead
|
||||||
|
*/
|
||||||
|
function returnClientError(string $message = '')
|
||||||
|
{
|
||||||
|
throw new \Exception($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use throwServerException() instead
|
||||||
|
*/
|
||||||
|
function returnServerError(string $message = '')
|
||||||
|
{
|
||||||
|
throw new \Exception($message);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue