diff options
author | 2022-07-01 15:10:30 +0200 | |
---|---|---|
committer | 2022-07-01 15:10:30 +0200 | |
commit | 4f75591060d95208a301bc6bf460d875631b29cc (patch) | |
tree | 4e37d86840e8d990a563ba75d3de6f84a53cc2de /bridges/NovelUpdatesBridge.php | |
parent | 66568e3a39c61546c09a47a5688914a0bdf3c60c (diff) | |
download | rss-bridge-4f75591060d95208a301bc6bf460d875631b29cc.tar.gz rss-bridge-4f75591060d95208a301bc6bf460d875631b29cc.tar.zst rss-bridge-4f75591060d95208a301bc6bf460d875631b29cc.zip |
Reformat codebase v4 (#2872)
Reformat code base to PSR12
Co-authored-by: rssbridge <noreply@github.com>
Diffstat (limited to 'bridges/NovelUpdatesBridge.php')
-rw-r--r-- | bridges/NovelUpdatesBridge.php | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/bridges/NovelUpdatesBridge.php b/bridges/NovelUpdatesBridge.php index 60d3fa5d..62e5f5b8 100644 --- a/bridges/NovelUpdatesBridge.php +++ b/bridges/NovelUpdatesBridge.php @@ -1,68 +1,72 @@ <?php -class NovelUpdatesBridge extends BridgeAbstract { - const MAINTAINER = 'albirew'; - const NAME = 'Novel Updates'; - const URI = 'https://www.novelupdates.com/'; - const CACHE_TIMEOUT = 21600; // 6h - const DESCRIPTION = 'Returns releases from Novel Updates'; - const PARAMETERS = array( array( - 'n' => array( - 'name' => 'Novel name as found in the url', - 'exampleValue' => 'spirit-realm', - 'required' => true - ) - )); +class NovelUpdatesBridge extends BridgeAbstract +{ + const MAINTAINER = 'albirew'; + const NAME = 'Novel Updates'; + const URI = 'https://www.novelupdates.com/'; + const CACHE_TIMEOUT = 21600; // 6h + const DESCRIPTION = 'Returns releases from Novel Updates'; + const PARAMETERS = [ [ + 'n' => [ + 'name' => 'Novel name as found in the url', + 'exampleValue' => 'spirit-realm', + 'required' => true + ] + ]]; - private $seriesTitle = ''; + private $seriesTitle = ''; - public function getURI(){ - if(!is_null($this->getInput('n'))) { - return static::URI . '/series/' . $this->getInput('n') . '/'; - } + public function getURI() + { + if (!is_null($this->getInput('n'))) { + return static::URI . '/series/' . $this->getInput('n') . '/'; + } - return parent::getURI(); - } + return parent::getURI(); + } - public function collectData(){ - $fullhtml = getSimpleHTMLDOM($this->getURI()); + public function collectData() + { + $fullhtml = getSimpleHTMLDOM($this->getURI()); - $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 - $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) { - $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->seriesTitle - . ' - ' - . $item['title'] - . '</a> by ' - . $item['team'] - . '<br><a href="' - . $item['uri'] - . '">' - . $fullhtml->find('div.seriesimg', 0)->innertext - . '</a>'; + $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 + $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) { + $item = []; + $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->seriesTitle + . ' - ' + . $item['title'] + . '</a> by ' + . $item['team'] + . '<br><a href="' + . $item['uri'] + . '">' + . $fullhtml->find('div.seriesimg', 0)->innertext + . '</a>'; - $this->items[] = $item; - } - } + $this->items[] = $item; + } + } - public function getName(){ - if(!empty($this->seriesTitle)) { - return $this->seriesTitle . ' - ' . static::NAME; - } + public function getName() + { + if (!empty($this->seriesTitle)) { + return $this->seriesTitle . ' - ' . static::NAME; + } - return parent::getName(); - } + return parent::getName(); + } } |