2023-04-19 21:35:04 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class ScribbleHubBridge extends FeedExpander
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'phantop';
|
|
|
|
const NAME = 'Scribble Hub';
|
|
|
|
const URI = 'https://scribblehub.com/';
|
|
|
|
const DESCRIPTION = 'Returns chapters from Scribble Hub.';
|
|
|
|
const PARAMETERS = [
|
|
|
|
'All' => [],
|
|
|
|
'Author' => [
|
|
|
|
'uid' => [
|
|
|
|
'name' => 'uid',
|
|
|
|
'required' => true,
|
2024-01-11 22:09:45 +03:00
|
|
|
// Example: miriamrobern's stories
|
|
|
|
'exampleValue' => '149271',
|
2023-04-19 21:35:04 +03:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'Series' => [
|
|
|
|
'sid' => [
|
|
|
|
'name' => 'sid',
|
|
|
|
'required' => true,
|
2024-01-11 22:09:45 +03:00
|
|
|
// Example: latest chapters from Uskweirs
|
|
|
|
'exampleValue' => '965299',
|
2023-04-19 21:35:04 +03:00
|
|
|
],
|
2024-04-08 00:02:36 +03:00
|
|
|
],
|
|
|
|
'List' => [
|
|
|
|
'url' => [
|
|
|
|
'name' => 'url',
|
|
|
|
'required' => true,
|
|
|
|
// Example: latest stories with the 'Transgender' tag
|
|
|
|
'exampleValue' => 'https://www.scribblehub.com/series-finder/?sf=1&gi=6&tgi=1088&sort=dateadded',
|
|
|
|
],
|
2023-04-19 21:35:04 +03:00
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
public function getIcon()
|
|
|
|
{
|
|
|
|
return self::URI . 'favicon.ico';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$url = 'https://rssscribblehub.com/rssfeed.php?type=';
|
2024-04-08 00:02:36 +03:00
|
|
|
if ($this->queriedContext === 'List') {
|
|
|
|
$this->collectList($this->getURI());
|
|
|
|
return;
|
|
|
|
}
|
2023-04-19 21:35:04 +03:00
|
|
|
if ($this->queriedContext === 'Author') {
|
|
|
|
$url = $url . 'author&uid=' . $this->getInput('uid');
|
|
|
|
} else { //All and Series use the same source feed
|
|
|
|
$url = $url . 'main';
|
|
|
|
}
|
|
|
|
$this->collectExpandableDatas($url);
|
|
|
|
}
|
|
|
|
|
2024-04-08 00:02:36 +03:00
|
|
|
protected $author = '';
|
|
|
|
|
|
|
|
private function collectList($url)
|
|
|
|
{
|
|
|
|
$html = getSimpleHTMLDOMCached($url);
|
|
|
|
foreach ($html->find('.search_main_box') as $element) {
|
|
|
|
$item = [];
|
|
|
|
|
|
|
|
$title = $element->find('.search_title a', 0);
|
|
|
|
$item['title'] = $title->plaintext;
|
|
|
|
$item['uri'] = $title->href;
|
|
|
|
|
|
|
|
$strdate = $element->find('[title="Last Updated"]', 0)->plaintext;
|
|
|
|
$item['timestamp'] = strtotime($strdate);
|
|
|
|
$item['uid'] = $item['uri'];
|
|
|
|
|
|
|
|
$details = getSimpleHTMLDOMCached($item['uri']);
|
|
|
|
$item['enclosures'][] = $details->find('.fic_image img', 0)->src;
|
|
|
|
$item['content'] = $details->find('.wi_fic_desc', 0);
|
|
|
|
|
|
|
|
foreach ($details->find('.fic_genre') as $tag) {
|
|
|
|
$item['categories'][] = $tag->plaintext;
|
|
|
|
}
|
|
|
|
foreach ($details->find('.stag') as $tag) {
|
|
|
|
$item['categories'][] = $tag->plaintext;
|
|
|
|
}
|
|
|
|
|
|
|
|
$read_url = $details->find('.read_buttons a', 0)->href;
|
|
|
|
$read_html = getSimpleHTMLDOMCached($read_url);
|
|
|
|
$item['content'] .= '<hr><h3>';
|
|
|
|
$item['content'] .= $read_html->find('.chapter-title', 0);
|
|
|
|
$item['content'] .= '</h3>';
|
|
|
|
$item['content'] .= $read_html->find('#chp_raw', 0);
|
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-13 02:59:05 +03:00
|
|
|
protected function parseItem(array $item)
|
2023-04-19 21:35:04 +03:00
|
|
|
{
|
|
|
|
//For series, filter out other series from 'All' feed
|
|
|
|
if (
|
|
|
|
$this->queriedContext === 'Series'
|
|
|
|
&& preg_match('/read\/' . $this->getInput('sid') . '-/', $item['uri']) !== 1
|
|
|
|
) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2024-01-11 22:09:45 +03:00
|
|
|
if ($this->queriedContext === 'Author') {
|
|
|
|
$this->author = $item['author'];
|
|
|
|
}
|
|
|
|
|
2023-05-11 02:33:21 +03:00
|
|
|
$item['comments'] = $item['uri'] . '#comments';
|
2024-05-12 22:45:14 +03:00
|
|
|
$item['uid'] = $item['uri'];
|
2023-04-19 21:35:04 +03:00
|
|
|
|
2023-05-11 02:33:21 +03:00
|
|
|
try {
|
2023-10-13 01:25:34 +03:00
|
|
|
$dom = getSimpleHTMLDOMCached($item['uri']);
|
2023-05-11 02:33:21 +03:00
|
|
|
} catch (HttpException $e) {
|
|
|
|
// 403 Forbidden, This means we got anti-bot response
|
2024-05-12 22:45:14 +03:00
|
|
|
if ($e->getCode() === 403 || $e->getCode() === 429) {
|
2023-05-11 02:33:21 +03:00
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
throw $e;
|
|
|
|
}
|
2023-04-19 21:35:04 +03:00
|
|
|
|
2023-10-13 01:25:34 +03:00
|
|
|
$dom = defaultLinkTo($dom, self::URI);
|
2023-04-19 21:35:04 +03:00
|
|
|
|
2023-05-11 02:33:21 +03:00
|
|
|
//Retrieve full description from page contents
|
2023-10-13 01:25:34 +03:00
|
|
|
$item['content'] = $dom->find('#chp_raw', 0);
|
2023-05-11 02:33:21 +03:00
|
|
|
|
|
|
|
//Retrieve image for thumbnail
|
2023-10-13 01:25:34 +03:00
|
|
|
$item_image = $dom->find('.s_novel_img > img', 0)->src;
|
2023-05-11 02:33:21 +03:00
|
|
|
$item['enclosures'] = [$item_image];
|
|
|
|
|
|
|
|
//Restore lost categories
|
2023-10-13 01:25:34 +03:00
|
|
|
$item_story = html_entity_decode($dom->find('.chp_byauthor > a', 0)->innertext);
|
|
|
|
$item_sid = $dom->find('#mysid', 0)->value;
|
2023-05-11 02:33:21 +03:00
|
|
|
$item['categories'] = [$item_story, $item_sid];
|
|
|
|
|
|
|
|
//Generate UID
|
2023-10-13 01:25:34 +03:00
|
|
|
$item_pid = $dom->find('#mypostid', 0)->value;
|
2023-04-19 21:35:04 +03:00
|
|
|
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
$name = parent::getName() . " $this->queriedContext";
|
|
|
|
switch ($this->queriedContext) {
|
|
|
|
case 'Author':
|
2024-01-11 22:09:45 +03:00
|
|
|
$title = $this->author;
|
2023-04-19 21:35:04 +03:00
|
|
|
break;
|
|
|
|
case 'Series':
|
2023-05-11 02:33:21 +03:00
|
|
|
try {
|
|
|
|
$page = getSimpleHTMLDOMCached(self::URI . 'series/' . $this->getInput('sid') . '/a');
|
|
|
|
} catch (HttpException $e) {
|
|
|
|
// 403 Forbidden, This means we got anti-bot response
|
|
|
|
if ($e->getCode() === 403) {
|
2024-04-08 00:02:36 +03:00
|
|
|
return $name;
|
2023-05-11 02:33:21 +03:00
|
|
|
}
|
|
|
|
throw $e;
|
|
|
|
}
|
2023-04-19 21:35:04 +03:00
|
|
|
$title = html_entity_decode($page->find('.fic_title', 0)->plaintext);
|
|
|
|
break;
|
2024-04-08 00:02:36 +03:00
|
|
|
case 'List':
|
|
|
|
$page = getSimpleHTMLDOMCached($this->getURI());
|
|
|
|
$title = $page->find('head > title', 0)->plaintext;
|
|
|
|
$title = explode(' |', $title)[0];
|
|
|
|
break;
|
2023-04-19 21:35:04 +03:00
|
|
|
}
|
|
|
|
if (isset($title)) {
|
|
|
|
$name .= " - $title";
|
|
|
|
}
|
|
|
|
return $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
$uri = parent::getURI();
|
|
|
|
switch ($this->queriedContext) {
|
|
|
|
case 'Author':
|
|
|
|
$uri = self::URI . 'profile/' . $this->getInput('uid');
|
|
|
|
break;
|
|
|
|
case 'Series':
|
|
|
|
$uri = self::URI . 'series/' . $this->getInput('sid') . '/a';
|
|
|
|
break;
|
2024-04-08 00:02:36 +03:00
|
|
|
case 'List':
|
|
|
|
$uri = $this->getInput('url');
|
|
|
|
break;
|
2023-04-19 21:35:04 +03:00
|
|
|
}
|
|
|
|
return $uri;
|
|
|
|
}
|
|
|
|
}
|