2022-12-09 13:05:08 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class TapasBridge extends FeedExpander
|
|
|
|
{
|
|
|
|
const NAME = 'Tapas.io';
|
|
|
|
const URI = 'https://tapas.io/';
|
|
|
|
const DESCRIPTION = 'Return new chapters from standart Tapas RSS';
|
|
|
|
const MAINTAINER = 'Ololbu';
|
|
|
|
const CACHE_TIMEOUT = 3600;
|
|
|
|
const PARAMETERS = [
|
|
|
|
[
|
|
|
|
'title' => [
|
|
|
|
'name' => 'URL\'s title / ID',
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
|
|
|
'title' => 'Insert title from URL (tapas.io/series/THIS_TITLE/info) or title ID',
|
|
|
|
],
|
|
|
|
'extend_content' => [
|
|
|
|
'name' => 'Include on-site content',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'title' => 'Activate to include images or chapter text',
|
|
|
|
],
|
|
|
|
// 'force_title' => [
|
|
|
|
// 'name' => 'Force title use',
|
|
|
|
// 'type' => 'checkbox',
|
|
|
|
// 'title' => 'If you have trouble with feed getting, try this option.',
|
|
|
|
// ],
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $id;
|
|
|
|
|
2023-10-13 01:25:34 +03:00
|
|
|
public function collectData()
|
2022-12-09 13:05:08 +03:00
|
|
|
{
|
2023-10-13 01:25:34 +03:00
|
|
|
if (preg_match('/^[\d]+$/', $this->getInput('title'))) {
|
|
|
|
$this->id = $this->getInput('title');
|
2022-12-09 13:05:08 +03:00
|
|
|
}
|
2023-10-13 01:25:34 +03:00
|
|
|
if ($this->getInput('force_title') or !$this->id) {
|
|
|
|
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request ' . $this->getURI());
|
|
|
|
$this->id = $html->find('meta[property$=":url"]', 0)->content;
|
|
|
|
$this->id = str_ireplace(['tapastic://series/', '/info'], '', $this->id);
|
|
|
|
}
|
2023-10-13 03:31:09 +03:00
|
|
|
$this->collectExpandableDatas($this->getURI(), 10);
|
2022-12-09 13:05:08 +03:00
|
|
|
}
|
|
|
|
|
2023-10-13 02:59:05 +03:00
|
|
|
protected function parseItem(array $item)
|
2022-12-09 13:05:08 +03:00
|
|
|
{
|
2023-10-13 02:02:19 +03:00
|
|
|
// $namespaces = $feedItem->getNamespaces(true);
|
|
|
|
// if (isset($namespaces['content'])) {
|
|
|
|
// $description = $feedItem->children($namespaces['content']);
|
|
|
|
// if (isset($description->encoded)) {
|
|
|
|
// $item['content'] = (string)$description->encoded;
|
|
|
|
// }
|
|
|
|
// }
|
2022-12-09 13:05:08 +03:00
|
|
|
|
|
|
|
if ($this->getInput('extend_content')) {
|
2023-10-13 02:02:19 +03:00
|
|
|
$html = getSimpleHTMLDOM($item['uri']);
|
2023-10-13 03:31:09 +03:00
|
|
|
$item['content'] = $item['content'] ?? '';
|
|
|
|
|
2022-12-09 13:05:08 +03:00
|
|
|
if ($html->find('article.main__body', 0)) {
|
|
|
|
foreach ($html->find('article', 0)->find('img') as $line) {
|
|
|
|
$item['content'] .= '<img src="' . $line->{'data-src'} . '">';
|
|
|
|
}
|
|
|
|
} elseif ($html->find('article.main__body--book', 0)) {
|
|
|
|
$item['content'] .= $html->find('article.viewer__body', 0)->innertext;
|
|
|
|
} else {
|
|
|
|
$item['content'] .= '<h1 style="font-size:24px;text-align:center;">Locked episode</h1>';
|
|
|
|
$item['content'] .= '<h5 style="text-align:center;">' . $html->find('div.js-viewer-filter h5', 0)->plaintext . '</h5>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
2023-10-13 01:25:34 +03:00
|
|
|
public function getURI()
|
2022-12-09 13:05:08 +03:00
|
|
|
{
|
2023-10-13 01:25:34 +03:00
|
|
|
if ($this->id) {
|
|
|
|
return self::URI . 'rss/series/' . $this->id;
|
2022-12-09 13:05:08 +03:00
|
|
|
}
|
2023-10-13 01:25:34 +03:00
|
|
|
return self::URI;
|
2022-12-09 13:05:08 +03:00
|
|
|
}
|
|
|
|
}
|