2016-05-21 18:27:30 +02:00
|
|
|
<?php
|
|
|
|
class NovelUpdatesBridge extends BridgeAbstract{
|
|
|
|
|
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "albirew";
|
|
|
|
$this->name = "Novel Updates";
|
|
|
|
$this->uri = "http://www.novelupdates.com/";
|
|
|
|
$this->description = "Returns releases from Novel Updates";
|
2016-08-22 01:25:56 +02:00
|
|
|
$this->parameters[] = array(
|
|
|
|
'n'=>array(
|
|
|
|
'name'=>'Novel URL',
|
|
|
|
'required'=>true
|
|
|
|
)
|
|
|
|
);
|
2016-05-21 18:27:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData(array $param){
|
|
|
|
if (!isset($param['n']))
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnClientError('You must specify the novel URL (/series/...)');
|
|
|
|
$thread = parse_url($param['n']) or $this->returnClientError('This URL seems malformed, please check it.');
|
2016-05-21 18:27:30 +02:00
|
|
|
if($thread['host'] !== 'www.novelupdates.com')
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnClientError('NovelUpdates URL only.');
|
2016-05-21 18:27:30 +02:00
|
|
|
if(strpos($thread['path'], 'series/') === FALSE)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnClientError('You must specify the novel URL.');
|
2016-05-21 18:27:30 +02:00
|
|
|
$url = 'http://www.novelupdates.com'.$thread['path'].'';
|
2016-07-08 19:06:35 +02:00
|
|
|
$fullhtml = $this->getSimpleHTMLDOM($url) or $this->returnServerError("Could not request NovelUpdates, novel not found");
|
2016-05-21 18:27:30 +02:00
|
|
|
$this->request = $fullhtml->find('h4.seriestitle', 0)->plaintext;
|
|
|
|
// dirty fix for nasty simpledom bug: https://github.com/sebsauvage/rss-bridge/issues/259
|
|
|
|
// forcefully removes tbody
|
|
|
|
$html = $fullhtml->find('table#myTable', 0)->innertext;
|
|
|
|
$html = stristr($html, '<tbody>'); //strip thead
|
|
|
|
$html = stristr($html, '<tr>'); //remove tbody
|
|
|
|
$html = str_get_html(stristr($html, '</tbody>', true)); //remove last tbody and get back as an array
|
|
|
|
foreach($html->find('tr') as $element){
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
|
|
|
$item['uri'] = $element->find('td', 2)->find('a', 0)->href;
|
|
|
|
$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'] = '<a href="'.$item['uri'].'">'.$this->request.' - '.$item['title'].'</a> by '.$item['team'].'<br><a href="'.$item['uri'].'">'.$fullhtml->find('div.seriesimg', 0)->innertext.'</a>';
|
2016-05-21 18:27:30 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2016-08-09 20:01:21 +02:00
|
|
|
|
2016-05-21 18:27:30 +02:00
|
|
|
public function getName(){
|
|
|
|
return (!empty($this->request) ? $this->request.' - ' : '') .'Novel Updates';
|
|
|
|
}
|
2016-08-09 20:01:21 +02:00
|
|
|
|
2016-05-21 18:27:30 +02:00
|
|
|
public function getCacheDuration(){
|
|
|
|
return 21600; // 6 hours
|
|
|
|
}
|
|
|
|
}
|