mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-09 01:56:39 +02:00
Reformat codebase v4 (#2872)
Reformat code base to PSR12 Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
@@ -1,49 +1,52 @@
|
||||
<?php
|
||||
class TheFarSideBridge extends BridgeAbstract {
|
||||
const NAME = 'The Far Side Bridge';
|
||||
const URI = 'https://www.thefarside.com';
|
||||
const DESCRIPTION = 'Returns the daily dose';
|
||||
const MAINTAINER = 'VerifiedJoseph';
|
||||
const PARAMETERS = array();
|
||||
|
||||
const CACHE_TIMEOUT = 3600; // 1 hour
|
||||
class TheFarSideBridge extends BridgeAbstract
|
||||
{
|
||||
const NAME = 'The Far Side Bridge';
|
||||
const URI = 'https://www.thefarside.com';
|
||||
const DESCRIPTION = 'Returns the daily dose';
|
||||
const MAINTAINER = 'VerifiedJoseph';
|
||||
const PARAMETERS = [];
|
||||
|
||||
public function collectData() {
|
||||
$html = getSimpleHTMLDOM(self::URI);
|
||||
const CACHE_TIMEOUT = 3600; // 1 hour
|
||||
|
||||
$div = $html->find('div.tfs-page-container__cows', 0);
|
||||
public function collectData()
|
||||
{
|
||||
$html = getSimpleHTMLDOM(self::URI);
|
||||
|
||||
$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-page-container__cows', 0);
|
||||
|
||||
foreach($div->find('div.card-body') as $index => $card) {
|
||||
$image = $card->find('img', 0);
|
||||
$imageUrl = $image->attr['data-src'];
|
||||
$item = [];
|
||||
$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'] = '';
|
||||
|
||||
// Images are downloaded to bypass the hotlink protection.
|
||||
$image = getContents($imageUrl, array('Referer: ' . self::URI));
|
||||
foreach ($div->find('div.card-body') as $index => $card) {
|
||||
$image = $card->find('img', 0);
|
||||
$imageUrl = $image->attr['data-src'];
|
||||
|
||||
// Encode image as base64
|
||||
$imageBase64 = base64_encode($image);
|
||||
// Images are downloaded to bypass the hotlink protection.
|
||||
$image = getContents($imageUrl, ['Referer: ' . self::URI]);
|
||||
|
||||
$caption = '';
|
||||
// Encode image as base64
|
||||
$imageBase64 = base64_encode($image);
|
||||
|
||||
if ($card->find('figcaption', 0)) {
|
||||
$caption = $card->find('figcaption', 0)->innertext;
|
||||
}
|
||||
$caption = '';
|
||||
|
||||
$item['content'] .= <<<EOD
|
||||
if ($card->find('figcaption', 0)) {
|
||||
$caption = $card->find('figcaption', 0)->innertext;
|
||||
}
|
||||
|
||||
$item['content'] .= <<<EOD
|
||||
<figure>
|
||||
<img title="{$caption}" src="data:image/jpeg;base64,{$imageBase64}"/>
|
||||
<figcaption>{$caption}</figcaption>
|
||||
</figure>
|
||||
<br/>
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user