1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-19 06:42:14 +02:00

bridges: Replace returnError function with more specific

Replacements depend on original error code:
400: returnClientError
404: returnServerError
500: returnServerError
501: returnServerError
This commit is contained in:
logmanoriginal
2016-08-17 14:45:08 +02:00
parent 73a1bcf3d6
commit 74f0572d91
124 changed files with 401 additions and 400 deletions

View File

@@ -5,7 +5,7 @@ class ShanaprojectBridge extends BridgeAbstract {
$this->name = 'Shanaproject Bridge';
$this->uri = 'http://www.shanaproject.com';
$this->description = 'Returns a list of anime from the current Season Anime List';
$this->update = '2016-08-06';
$this->update = '2016-08-17';
}
// Returns an html object for the Season Anime List (latest season)
@@ -13,15 +13,15 @@ class ShanaprojectBridge extends BridgeAbstract {
// First we need to find the URI to the latest season from the 'seasons' page searching for 'Season Anime List'
$html = $this->file_get_html($this->getURI() . '/seasons');
if(!$html)
$this->returnError('Could not load \'seasons\' page!', 404);
$this->returnServerError('Could not load \'seasons\' page!');
$season = $html->find('div.follows_menu/a', 1);
if(!$season)
$this->returnError('Could not find \'Season Anime List\'!', 404);
$this->returnServerError('Could not find \'Season Anime List\'!');
$html = $this->file_get_html($this->getURI() . $season->href);
if(!$html)
$this->returnError('Could not load \'Season Anime List\' from \'' . $season->innertext . '\'!');
$this->returnServerError('Could not load \'Season Anime List\' from \'' . $season->innertext . '\'!');
return $html;
}
@@ -30,7 +30,7 @@ class ShanaprojectBridge extends BridgeAbstract {
private function ExtractAnimeTitle($anime){
$title = $anime->find('a', 0);
if(!$title)
$this->returnError('Could not find anime title!', 404);
$this->returnServerError('Could not find anime title!');
return trim($title->innertext);
}
@@ -38,7 +38,7 @@ class ShanaprojectBridge extends BridgeAbstract {
private function ExtractAnimeURI($anime){
$uri = $anime->find('a', 0);
if(!$uri)
$this->returnError('Could not find anime URI!', 404);
$this->returnServerError('Could not find anime URI!');
return $this->getURI() . $uri->href;
}
@@ -46,7 +46,7 @@ class ShanaprojectBridge extends BridgeAbstract {
private function ExtractAnimeTimestamp($anime){
$timestamp = $anime->find('span.header_info_block', 1);
if(!$timestamp)
$this->returnError('Could not find anime timestamp!', 404);
$this->returnServerError('Could not find anime timestamp!');
return strtotime($timestamp->innertext);
}
@@ -62,7 +62,7 @@ class ShanaprojectBridge extends BridgeAbstract {
private function ExtractAnimeEpisodeInformation($anime){
$episode = $anime->find('div.header_info_episode', 0);
if(!$episode)
$this->returnError('Could not find anime episode information!', 404);
$this->returnServerError('Could not find anime episode information!');
return preg_replace('/\r|\n/', ' ', $episode->plaintext);
}
@@ -74,7 +74,7 @@ class ShanaprojectBridge extends BridgeAbstract {
if(preg_match("/url\(\/\/([^\)]+)\)/i", $anime->parent->style, $matches))
return $matches[1];
$this->returnError('Could not extract background image!', 404);
$this->returnServerError('Could not extract background image!');
}
// Builds an URI to search for a specific anime (subber is left empty)
@@ -97,7 +97,7 @@ class ShanaprojectBridge extends BridgeAbstract {
$animes = $html->find('div.header_display_box_info');
if(!$animes)
$this->returnError('Could not find anime headers!', 404);
$this->returnServerError('Could not find anime headers!');
foreach($animes as $anime){
$item = new \Item();