mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-10 00:48:48 +00:00
[ScribbleHubBridge] Add CloudFlare error handling (#3361)
* [ScribbleHubBridge] Set html defaultLinkTo * [ScrubbleHubBridge] Add CloudFlare error handling
This commit is contained in:
parent
c6c4b3a24f
commit
dc4134ed1d
@ -54,24 +54,36 @@ class ScribbleHubBridge extends FeedExpander
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item_html = getSimpleHTMLDOMCached($item['uri'])) {
|
$item['comments'] = $item['uri'] . '#comments';
|
||||||
//Retrieve full description from page contents
|
|
||||||
$item['content'] = $item_html->find('#chp_raw', 0);
|
|
||||||
|
|
||||||
//Retrieve image for thumbnail
|
try {
|
||||||
$item_image = $item_html->find('.s_novel_img > img', 0)->src;
|
$item_html = getSimpleHTMLDOMCached($item['uri']);
|
||||||
$item['enclosures'] = [$item_image];
|
} catch (HttpException $e) {
|
||||||
|
// 403 Forbidden, This means we got anti-bot response
|
||||||
//Restore lost categories
|
if ($e->getCode() === 403) {
|
||||||
$item_story = html_entity_decode($item_html->find('.chp_byauthor > a', 0)->innertext);
|
return $item;
|
||||||
$item_sid = $item_html->find('#mysid', 0)->value;
|
}
|
||||||
$item['categories'] = [$item_story, $item_sid];
|
throw $e;
|
||||||
|
|
||||||
//Generate UID
|
|
||||||
$item_pid = $item_html->find('#mypostid', 0)->value;
|
|
||||||
$item['uid'] = $item_sid . "/$item_pid";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$item_html = defaultLinkTo($item_html, self::URI);
|
||||||
|
|
||||||
|
//Retrieve full description from page contents
|
||||||
|
$item['content'] = $item_html->find('#chp_raw', 0);
|
||||||
|
|
||||||
|
//Retrieve image for thumbnail
|
||||||
|
$item_image = $item_html->find('.s_novel_img > img', 0)->src;
|
||||||
|
$item['enclosures'] = [$item_image];
|
||||||
|
|
||||||
|
//Restore lost categories
|
||||||
|
$item_story = html_entity_decode($item_html->find('.chp_byauthor > a', 0)->innertext);
|
||||||
|
$item_sid = $item_html->find('#mysid', 0)->value;
|
||||||
|
$item['categories'] = [$item_story, $item_sid];
|
||||||
|
|
||||||
|
//Generate UID
|
||||||
|
$item_pid = $item_html->find('#mypostid', 0)->value;
|
||||||
|
$item['uid'] = $item_sid . "/$item_pid";
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,11 +92,27 @@ class ScribbleHubBridge extends FeedExpander
|
|||||||
$name = parent::getName() . " $this->queriedContext";
|
$name = parent::getName() . " $this->queriedContext";
|
||||||
switch ($this->queriedContext) {
|
switch ($this->queriedContext) {
|
||||||
case 'Author':
|
case 'Author':
|
||||||
$page = getSimpleHTMLDOMCached(self::URI . 'profile/' . $this->getInput('uid'));
|
try {
|
||||||
|
$page = getSimpleHTMLDOMCached(self::URI . 'profile/' . $this->getInput('uid'));
|
||||||
|
} catch (HttpException $e) {
|
||||||
|
// 403 Forbidden, This means we got anti-bot response
|
||||||
|
if ($e->getCode() === 403) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
$title = html_entity_decode($page->find('.p_m_username.fp_authorname', 0)->plaintext);
|
$title = html_entity_decode($page->find('.p_m_username.fp_authorname', 0)->plaintext);
|
||||||
break;
|
break;
|
||||||
case 'Series':
|
case 'Series':
|
||||||
$page = getSimpleHTMLDOMCached(self::URI . 'series/' . $this->getInput('sid') . '/a');
|
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) {
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
$title = html_entity_decode($page->find('.fic_title', 0)->plaintext);
|
$title = html_entity_decode($page->find('.fic_title', 0)->plaintext);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user