From da90a93d4fb1d8390b8cd365cb4642ab99d2834d Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 9 Mar 2020 20:55:50 +0000 Subject: [PATCH 1/6] [TheFarSideBridge] Add Bridge --- bridges/TheFarSideBridge.php | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 bridges/TheFarSideBridge.php diff --git a/bridges/TheFarSideBridge.php b/bridges/TheFarSideBridge.php new file mode 100644 index 00000000000..6eceb8eea09 --- /dev/null +++ b/bridges/TheFarSideBridge.php @@ -0,0 +1,44 @@ +find('h3', 0)->innertext)); + $item['title'] = $html->find('h3', 0)->innertext; + $item['timestamp'] = $html->find('h3', 0)->innertext; + + $item['content'] = ''; + + $div = $html->find('div.tfs-content.js-daily-dose', 0); + + foreach($div->find('div.card-body') as $index => $card) { + $image = $card->find('img', 0); + $imageUrl = $image->attr['data-src']; + + // To get around the hotlink protection, the images are downloaded, encoded as base64 and then added to the html. + $image = getContents($imageUrl, array('Referer: ' . self::URI)) + or returnServerError('Could not request: ' . $imageUrl); + + // Encode image as base64 + $imageBase64 = base64_encode($image); + + $caption = $card->find('figcaption', 0)->innertext; + + $item['content'] .= <<
{$caption}

+EOD; + } + + $this->items[] = $item; + } +} From 7b4ae13be99030435ac43445fe6c26ad20f795d4 Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 9 Mar 2020 21:06:39 +0000 Subject: [PATCH 2/6] [TheFarSideBridge] Update comment --- bridges/TheFarSideBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/TheFarSideBridge.php b/bridges/TheFarSideBridge.php index 6eceb8eea09..8539c17a77e 100644 --- a/bridges/TheFarSideBridge.php +++ b/bridges/TheFarSideBridge.php @@ -25,7 +25,7 @@ public function collectData() { $image = $card->find('img', 0); $imageUrl = $image->attr['data-src']; - // To get around the hotlink protection, the images are downloaded, encoded as base64 and then added to the html. + // To get around the hotlink protection, images are downloaded, encoded as base64 and then added to the html. $image = getContents($imageUrl, array('Referer: ' . self::URI)) or returnServerError('Could not request: ' . $imageUrl); From b5ae0a40fe5f5964aef073f11ad98c6ad4c9f024 Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 9 Mar 2020 21:40:36 +0000 Subject: [PATCH 3/6] [TheFarSideBridge] Add title attribute to image tag --- bridges/TheFarSideBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/TheFarSideBridge.php b/bridges/TheFarSideBridge.php index 8539c17a77e..447b1d8b5a9 100644 --- a/bridges/TheFarSideBridge.php +++ b/bridges/TheFarSideBridge.php @@ -35,7 +35,7 @@ public function collectData() { $caption = $card->find('figcaption', 0)->innertext; $item['content'] .= <<
{$caption}

+
{$caption}

EOD; } From 0d5b0ead01a56bb7080642a8227365418c4a2998 Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 9 Mar 2020 21:48:45 +0000 Subject: [PATCH 4/6] [TheFarSideBridge] Fix travis issues --- bridges/TheFarSideBridge.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bridges/TheFarSideBridge.php b/bridges/TheFarSideBridge.php index 447b1d8b5a9..68dd711dfb3 100644 --- a/bridges/TheFarSideBridge.php +++ b/bridges/TheFarSideBridge.php @@ -35,7 +35,11 @@ public function collectData() { $caption = $card->find('figcaption', 0)->innertext; $item['content'] .= <<
{$caption}

+
+ +
{$caption}
+
+
EOD; } From 301b7fef56c25f5b47803ca73936e3d0c73cab19 Mon Sep 17 00:00:00 2001 From: Joseph Date: Mon, 22 Mar 2021 14:43:39 +0000 Subject: [PATCH 5/6] [TheFarSideBridge] Update caption handling --- bridges/TheFarSideBridge.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bridges/TheFarSideBridge.php b/bridges/TheFarSideBridge.php index 68dd711dfb3..337a5b96f4c 100644 --- a/bridges/TheFarSideBridge.php +++ b/bridges/TheFarSideBridge.php @@ -32,7 +32,11 @@ public function collectData() { // Encode image as base64 $imageBase64 = base64_encode($image); - $caption = $card->find('figcaption', 0)->innertext; + $caption = ''; + + if ($card->find('figcaption', 0)) { + $caption = $card->find('figcaption', 0)->innertext; + } $item['content'] .= << From 03cf13845bd58892a86e50fbd566b615841f7d65 Mon Sep 17 00:00:00 2001 From: Joseph Date: Sat, 3 Apr 2021 14:59:23 +0100 Subject: [PATCH 6/6] [TheFarSideBridge] Fix title & date extraction --- bridges/TheFarSideBridge.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bridges/TheFarSideBridge.php b/bridges/TheFarSideBridge.php index 337a5b96f4c..6b598edee38 100644 --- a/bridges/TheFarSideBridge.php +++ b/bridges/TheFarSideBridge.php @@ -12,20 +12,19 @@ public function collectData() { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request: ' . self::URI); - $item = array(); - $item['uri'] = self::URI . date('/Y/m/d', strtotime($html->find('h3', 0)->innertext)); - $item['title'] = $html->find('h3', 0)->innertext; - $item['timestamp'] = $html->find('h3', 0)->innertext; + $div = $html->find('div.tfs-page-container__cows', 0); + $item = array(); + $item['uri'] = $html->find('meta[property="og:url"]', 0)->content; + $item['title'] = $div->find('h3', 0)->innertext; + $item['timestamp'] = $div->find('h3', 0)->innertext; $item['content'] = ''; - $div = $html->find('div.tfs-content.js-daily-dose', 0); - foreach($div->find('div.card-body') as $index => $card) { $image = $card->find('img', 0); $imageUrl = $image->attr['data-src']; - // To get around the hotlink protection, images are downloaded, encoded as base64 and then added to the html. + // Images are downloaded to bypass the hotlink protection. $image = getContents($imageUrl, array('Referer: ' . self::URI)) or returnServerError('Could not request: ' . $imageUrl);