2016-05-21 18:27:30 +02:00
|
|
|
<?php
|
|
|
|
class NovelUpdatesBridge extends BridgeAbstract{
|
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = "albirew";
|
|
|
|
const NAME = "Novel Updates";
|
|
|
|
const URI = "http://www.novelupdates.com/";
|
2016-09-25 17:04:28 +02:00
|
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
2016-08-30 11:23:55 +02:00
|
|
|
const DESCRIPTION = "Returns releases from Novel Updates";
|
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'n'=>array(
|
2016-09-04 14:26:11 +02:00
|
|
|
'name'=>'Novel name as found in the url',
|
|
|
|
'exampleValue'=>'spirit-realm',
|
|
|
|
'required'=>true
|
2016-08-27 21:03:26 +02:00
|
|
|
)
|
|
|
|
));
|
2016-05-21 18:27:30 +02:00
|
|
|
|
2016-08-29 14:10:00 +02:00
|
|
|
private $seriesTitle='';
|
|
|
|
|
2016-09-04 14:26:11 +02:00
|
|
|
public function getURI(){
|
|
|
|
return static::URI.'/series/'.$this->getInput('n').'/';
|
|
|
|
}
|
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData(){
|
2016-09-25 23:22:33 +02:00
|
|
|
$fullhtml = getSimpleHTMLDOM($this->getURI())
|
|
|
|
or returnServerError('Could not request NovelUpdates, novel "'.$this->getInput('n').'" not found');
|
2016-09-04 14:26:11 +02:00
|
|
|
|
2016-08-29 14:10:00 +02:00
|
|
|
$this->seriesTitle = $fullhtml->find('h4.seriestitle', 0)->plaintext;
|
2016-05-21 18:27:30 +02:00
|
|
|
// 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);
|
2016-09-04 14:26:11 +02:00
|
|
|
$item['content'] =
|
|
|
|
'<a href="'.$item['uri'].'">'
|
|
|
|
.$this->seriesTitle.' - '.$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(){
|
2016-09-04 14:26:11 +02:00
|
|
|
return $this->seriesTitle. ' - ' . static::NAME;
|
2016-05-21 18:27:30 +02:00
|
|
|
}
|
|
|
|
}
|