diff --git a/bridges/NovelUpdatesBridge.php b/bridges/NovelUpdatesBridge.php index b865737..95dfc7f 100644 --- a/bridges/NovelUpdatesBridge.php +++ b/bridges/NovelUpdatesBridge.php @@ -7,23 +7,22 @@ class NovelUpdatesBridge extends BridgeAbstract{ const DESCRIPTION = "Returns releases from Novel Updates"; const PARAMETERS = array( array( 'n'=>array( - 'name'=>'Novel URL', - 'patterns'=>'http:\/\/www.novelupdates.com\/.*', - 'required'=>true + 'name'=>'Novel name as found in the url', + 'exampleValue'=>'spirit-realm', + 'required'=>true ) )); private $seriesTitle=''; + public function getURI(){ + return static::URI.'/series/'.$this->getInput('n').'/'; + } + public function collectData(){ - $thread = parse_url($this->getInput('n')) - or $this->returnClientError('This URL seems malformed, please check it.'); - if($thread['host'] !== 'www.novelupdates.com') - $this->returnClientError('NovelUpdates URL only.'); - if(strpos($thread['path'], 'series/') === FALSE) - $this->returnClientError('You must specify the novel URL.'); - $url = self::URI.$thread['path'].''; - $fullhtml = $this->getSimpleHTMLDOM($url) or $this->returnServerError("Could not request NovelUpdates, novel not found"); + $fullhtml = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError('Could not request NovelUpdates, novel "'.$this->getInput('n').'" not found'); + $this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext; // dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259 // forcefully removes tbody @@ -37,13 +36,17 @@ class NovelUpdatesBridge extends BridgeAbstract{ $item['title'] = $element->find('td', 2)->find('a', 0)->plaintext; $item['team'] = $element->find('td', 1)->innertext; $item['timestamp'] = strtotime($element->find('td', 0)->plaintext); - $item['content'] = ''.$this->seriesTitle.' - '.$item['title'].' by '.$item['team'].'
'.$fullhtml->find('div.seriesimg', 0)->innertext.''; + $item['content'] = + '' + .$this->seriesTitle.' - '.$item['title'] + .' by '.$item['team'].'
' + .''.$fullhtml->find('div.seriesimg', 0)->innertext.''; $this->items[] = $item; } } public function getName(){ - return (!empty($this->seriesTitle) ? $this->seriesTitle.' - ' : '') .'Novel Updates'; + return $this->seriesTitle. ' - ' . static::NAME; } public function getCacheDuration(){