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