mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 09:35:28 +03:00
[TapasBridge] New bridge (#3184)
* [TapasBridge] New bridge * [TapasBridge] Delete comment * [TapasBridge] Delete context * [TapasBridge] Delete context again * [TapasBridge] Convert double quotes do single quotes * [TapasBridge] Fix some lint errors * [TapasBridge] Fix indentation style * [TapasBridge] Fix some lint errors
This commit is contained in:
parent
ec1b9a110d
commit
7d5698a75f
1 changed files with 87 additions and 0 deletions
87
bridges/TapasBridge.php
Normal file
87
bridges/TapasBridge.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?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;
|
||||
|
||||
public function getURI()
|
||||
{
|
||||
if ($this->id) {
|
||||
return self::URI . 'rss/series/' . $this->id;
|
||||
} else {
|
||||
return self::URI . 'series/' . $this->getInput('title') . '/info/';
|
||||
}
|
||||
return self::URI;
|
||||
}
|
||||
|
||||
protected function parseItem($feedItem)
|
||||
{
|
||||
$item = parent::parseItem($feedItem);
|
||||
|
||||
$namespaces = $feedItem->getNamespaces(true);
|
||||
if (isset($namespaces['content'])) {
|
||||
$description = $feedItem->children($namespaces['content']);
|
||||
if (isset($description->encoded)) {
|
||||
$item['content'] = (string)$description->encoded;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->getInput('extend_content')) {
|
||||
$html = getSimpleHTMLDOM($item['uri']) or returnServerError('Could not request ' . $this->getURI());
|
||||
if (!$item['content']) {
|
||||
$item['content'] = '';
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
if (preg_match('/^[\d]+$/', $this->getInput('title'))) {
|
||||
$this->id = $this->getInput('title');
|
||||
}
|
||||
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);
|
||||
}
|
||||
$this->collectExpandableDatas($this->getURI());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue