2020-12-13 13:50:54 +03:00
|
|
|
<?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() {
|
2021-05-17 21:18:51 +03:00
|
|
|
$this->collectExpandableDatas('https://www.racedepartment.com/ams/index.rss', 10);
|
2020-12-13 13:50:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function parseItem($feedItem) {
|
2021-05-17 21:18:51 +03:00
|
|
|
$item = parent::parseRSS_2_0_Item($feedItem);
|
2020-12-13 13:50:54 +03:00
|
|
|
|
|
|
|
//fetch page
|
2022-01-02 12:36:09 +03:00
|
|
|
$articlePage = getSimpleHTMLDOMCached($feedItem->link);
|
2021-05-17 21:18:51 +03:00
|
|
|
|
|
|
|
$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);
|
2020-12-13 13:50:54 +03:00
|
|
|
|
|
|
|
//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>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-17 21:18:51 +03:00
|
|
|
$item['categories'] = array();
|
|
|
|
foreach($articlePage->find('a.tagItem') as $tag) {
|
|
|
|
array_push($item['categories'], $tag->innertext);
|
2020-12-13 13:50:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
}
|