mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-09-01 20:23: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,41 +1,44 @@
|
||||
<?php
|
||||
class RaceDepartmentBridge extends FeedExpander {
|
||||
const NAME = 'RaceDepartment News';
|
||||
const URI = 'https://racedepartment.com/';
|
||||
const DESCRIPTION = 'Get the latest (sim)racing news from RaceDepartment.';
|
||||
const MAINTAINER = 't0stiman';
|
||||
|
||||
public function collectData() {
|
||||
$this->collectExpandableDatas('https://www.racedepartment.com/ams/index.rss', 10);
|
||||
}
|
||||
class RaceDepartmentBridge extends FeedExpander
|
||||
{
|
||||
const NAME = 'RaceDepartment News';
|
||||
const URI = 'https://racedepartment.com/';
|
||||
const DESCRIPTION = 'Get the latest (sim)racing news from RaceDepartment.';
|
||||
const MAINTAINER = 't0stiman';
|
||||
|
||||
protected function parseItem($feedItem) {
|
||||
$item = parent::parseRss2Item($feedItem);
|
||||
public function collectData()
|
||||
{
|
||||
$this->collectExpandableDatas('https://www.racedepartment.com/ams/index.rss', 10);
|
||||
}
|
||||
|
||||
//fetch page
|
||||
$articlePage = getSimpleHTMLDOMCached($feedItem->link);
|
||||
protected function parseItem($feedItem)
|
||||
{
|
||||
$item = parent::parseRss2Item($feedItem);
|
||||
|
||||
$coverImage = $articlePage->find('img.js-articleCoverImage', 0);
|
||||
#relative url -> absolute url
|
||||
$coverImage = str_replace('src="/', 'src="' . $this->getURI() . '/', $coverImage);
|
||||
$article = $articlePage->find('article.articleBody-main > div.bbWrapper', 0);
|
||||
$item['content'] = str_get_html($coverImage . $article);
|
||||
//fetch page
|
||||
$articlePage = getSimpleHTMLDOMCached($feedItem->link);
|
||||
|
||||
//convert iframes to links. meant for embedded videos.
|
||||
foreach($item['content']->find('iframe') as $found) {
|
||||
$coverImage = $articlePage->find('img.js-articleCoverImage', 0);
|
||||
#relative url -> absolute url
|
||||
$coverImage = str_replace('src="/', 'src="' . $this->getURI() . '/', $coverImage);
|
||||
$article = $articlePage->find('article.articleBody-main > div.bbWrapper', 0);
|
||||
$item['content'] = str_get_html($coverImage . $article);
|
||||
|
||||
$iframeUrl = $found->getAttribute('src');
|
||||
//convert iframes to links. meant for embedded videos.
|
||||
foreach ($item['content']->find('iframe') as $found) {
|
||||
$iframeUrl = $found->getAttribute('src');
|
||||
|
||||
if ($iframeUrl) {
|
||||
$found->outertext = '<a href="' . $iframeUrl . '">' . $iframeUrl . '</a>';
|
||||
}
|
||||
}
|
||||
if ($iframeUrl) {
|
||||
$found->outertext = '<a href="' . $iframeUrl . '">' . $iframeUrl . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$item['categories'] = array();
|
||||
foreach($articlePage->find('a.tagItem') as $tag) {
|
||||
array_push($item['categories'], $tag->innertext);
|
||||
}
|
||||
$item['categories'] = [];
|
||||
foreach ($articlePage->find('a.tagItem') as $tag) {
|
||||
array_push($item['categories'], $tag->innertext);
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user