aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bridges/ScribbleHubBridge.php60
1 files changed, 44 insertions, 16 deletions
diff --git a/bridges/ScribbleHubBridge.php b/bridges/ScribbleHubBridge.php
index c904cd03..4fe43df3 100644
--- a/bridges/ScribbleHubBridge.php
+++ b/bridges/ScribbleHubBridge.php
@@ -54,23 +54,35 @@ class ScribbleHubBridge extends FeedExpander
return [];
}
- if ($item_html = getSimpleHTMLDOMCached($item['uri'])) {
- //Retrieve full description from page contents
- $item['content'] = $item_html->find('#chp_raw', 0);
+ $item['comments'] = $item['uri'] . '#comments';
- //Retrieve image for thumbnail
- $item_image = $item_html->find('.s_novel_img > img', 0)->src;
- $item['enclosures'] = [$item_image];
+ try {
+ $item_html = getSimpleHTMLDOMCached($item['uri']);
+ } catch (HttpException $e) {
+ // 403 Forbidden, This means we got anti-bot response
+ if ($e->getCode() === 403) {
+ return $item;
+ }
+ throw $e;
+ }
- //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];
+ $item_html = defaultLinkTo($item_html, self::URI);
- //Generate UID
- $item_pid = $item_html->find('#mypostid', 0)->value;
- $item['uid'] = $item_sid . "/$item_pid";
- }
+ //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;
}
@@ -80,11 +92,27 @@ class ScribbleHubBridge extends FeedExpander
$name = parent::getName() . " $this->queriedContext";
switch ($this->queriedContext) {
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);
break;
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);
break;
}