1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-10 18:44:04 +02:00

Reformat codebase v4 (#2872)

Reformat code base to PSR12

Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
Dag
2022-07-01 15:10:30 +02:00
committed by GitHub
parent 66568e3a39
commit 4f75591060
398 changed files with 58607 additions and 56442 deletions

View File

@@ -1,56 +1,58 @@
<?php
class VieDeMerdeBridge extends BridgeAbstract {
const MAINTAINER = 'floviolleau';
const NAME = 'VieDeMerde Bridge';
const URI = 'https://www.viedemerde.fr';
const DESCRIPTION = 'Returns latest quotes from VieDeMerde.';
const CACHE_TIMEOUT = 7200;
class VieDeMerdeBridge extends BridgeAbstract
{
const MAINTAINER = 'floviolleau';
const NAME = 'VieDeMerde Bridge';
const URI = 'https://www.viedemerde.fr';
const DESCRIPTION = 'Returns latest quotes from VieDeMerde.';
const CACHE_TIMEOUT = 7200;
const PARAMETERS = array(array(
'item_limit' => array(
'name' => 'Limit number of returned items',
'type' => 'number',
'defaultValue' => 20
)
));
const PARAMETERS = [[
'item_limit' => [
'name' => 'Limit number of returned items',
'type' => 'number',
'defaultValue' => 20
]
]];
public function collectData() {
$limit = $this->getInput('item_limit');
public function collectData()
{
$limit = $this->getInput('item_limit');
if ($limit < 1) {
$limit = 20;
}
if ($limit < 1) {
$limit = 20;
}
$html = getSimpleHTMLDOM(self::URI, array());
$quotes = $html->find('article.bg-white');
if(sizeof($quotes) === 0) {
return;
}
$html = getSimpleHTMLDOM(self::URI, []);
$quotes = $html->find('article.bg-white');
if (sizeof($quotes) === 0) {
return;
}
foreach($quotes as $quote) {
$item = array();
$item['uri'] = self::URI . $quote->find('a', 0)->href;
$titleContent = $quote->find('h2', 0);
foreach ($quotes as $quote) {
$item = [];
$item['uri'] = self::URI . $quote->find('a', 0)->href;
$titleContent = $quote->find('h2', 0);
if($titleContent) {
$item['title'] = html_entity_decode($titleContent->plaintext, ENT_QUOTES);
} else {
continue;
}
if ($titleContent) {
$item['title'] = html_entity_decode($titleContent->plaintext, ENT_QUOTES);
} else {
continue;
}
$quoteText = $quote->find('a', 1)->plaintext;
$isAVDM = $quote->find('.vote-btn', 0)->plaintext;
$isNotAVDM = $quote->find('.vote-btn', 1)->plaintext;
$item['content'] = $quoteText . '<br>' . $isAVDM . '<br>' . $isNotAVDM;
$item['author'] = $quote->find('p', 0)->plaintext;
$item['uid'] = hash('sha256', $item['title']);
$quoteText = $quote->find('a', 1)->plaintext;
$isAVDM = $quote->find('.vote-btn', 0)->plaintext;
$isNotAVDM = $quote->find('.vote-btn', 1)->plaintext;
$item['content'] = $quoteText . '<br>' . $isAVDM . '<br>' . $isNotAVDM;
$item['author'] = $quote->find('p', 0)->plaintext;
$item['uid'] = hash('sha256', $item['title']);
$this->items[] = $item;
$this->items[] = $item;
if (count($this->items) >= $limit) {
break;
}
}
}
if (count($this->items) >= $limit) {
break;
}
}
}
}