2016-05-21 19:27:30 +03:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
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
|
|
|
|
]
|
|
|
|
]];
|
2016-05-21 19:27:30 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
private $seriesTitle = '';
|
2016-08-29 15:10:00 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
if (!is_null($this->getInput('n'))) {
|
|
|
|
return static::URI . '/series/' . $this->getInput('n') . '/';
|
|
|
|
}
|
2017-02-15 00:36:33 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
return parent::getURI();
|
|
|
|
}
|
2016-09-04 15:26:11 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$fullhtml = getSimpleHTMLDOM($this->getURI());
|
2016-09-04 15:26:11 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$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) {
|
Fix coding style missed by phpbcf (#2901)
$ composer require --dev friendsofphp/php-cs-fixer
$ echo >.php-cs-fixer.dist.php "<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__);
$rules = [
'@PSR12' => true,
// '@PSR12:risky' => true,
'@PHP74Migration' => true,
// '@PHP74Migration:risky' => true,
// buggy, duplicates existing comment sometimes
'no_break_comment' => false,
'array_syntax' => true,
'lowercase_static_reference' => true,
'visibility_required' => false,
// Too much noise
'binary_operator_spaces' => false,
'heredoc_indentation' => false,
'trailing_comma_in_multiline' => false,
];
$config = new PhpCsFixer\Config();
return $config
->setRules($rules)
// ->setRiskyAllowed(true)
->setFinder($finder);
"
$ vendor/bin/php-cs-fixer --version
PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 8.1.7
$ vendor/bin/php-cs-fixer fix
$ rm .php-cs-fixer.cache
$ vendor/bin/php-cs-fixer fix
2022-07-08 14:00:52 +03:00
|
|
|
$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="'
|
2022-07-01 16:10:30 +03:00
|
|
|
. $item['uri']
|
|
|
|
. '">'
|
|
|
|
. $this->seriesTitle
|
|
|
|
. ' - '
|
|
|
|
. $item['title']
|
|
|
|
. '</a> by '
|
|
|
|
. $item['team']
|
|
|
|
. '<br><a href="'
|
|
|
|
. $item['uri']
|
|
|
|
. '">'
|
|
|
|
. $fullhtml->find('div.seriesimg', 0)->innertext
|
|
|
|
. '</a>';
|
2016-08-09 21:01:21 +03:00
|
|
|
|
Fix coding style missed by phpbcf (#2901)
$ composer require --dev friendsofphp/php-cs-fixer
$ echo >.php-cs-fixer.dist.php "<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__);
$rules = [
'@PSR12' => true,
// '@PSR12:risky' => true,
'@PHP74Migration' => true,
// '@PHP74Migration:risky' => true,
// buggy, duplicates existing comment sometimes
'no_break_comment' => false,
'array_syntax' => true,
'lowercase_static_reference' => true,
'visibility_required' => false,
// Too much noise
'binary_operator_spaces' => false,
'heredoc_indentation' => false,
'trailing_comma_in_multiline' => false,
];
$config = new PhpCsFixer\Config();
return $config
->setRules($rules)
// ->setRiskyAllowed(true)
->setFinder($finder);
"
$ vendor/bin/php-cs-fixer --version
PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 8.1.7
$ vendor/bin/php-cs-fixer fix
$ rm .php-cs-fixer.cache
$ vendor/bin/php-cs-fixer fix
2022-07-08 14:00:52 +03:00
|
|
|
$this->items[] = $item;
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
if (!empty($this->seriesTitle)) {
|
|
|
|
return $this->seriesTitle . ' - ' . static::NAME;
|
|
|
|
}
|
2017-02-15 00:20:55 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
return parent::getName();
|
|
|
|
}
|
2016-05-21 19:27:30 +03:00
|
|
|
}
|