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';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-12-13 13:50:54 +03:00
|
|
|
public function collectData()
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
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
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-12-13 13:50:54 +03:00
|
|
|
protected function parseItem($feedItem)
|
|
|
|
{
|
2022-06-24 19:29:35 +03:00
|
|
|
$item = parent::parseRss2Item($feedItem);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-12-13 13:50:54 +03:00
|
|
|
//fetch page
|
2022-01-02 12:36:09 +03:00
|
|
|
$articlePage = getSimpleHTMLDOMCached($feedItem->link);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
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);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
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');
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-12-13 13:50:54 +03:00
|
|
|
if ($iframeUrl) {
|
|
|
|
$found->outertext = '<a href="' . $iframeUrl . '">' . $iframeUrl . '</a>';
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
|
2021-05-17 21:18:51 +03:00
|
|
|
$item['categories'] = [];
|
|
|
|
foreach ($articlePage->find('a.tagItem') as $tag) {
|
|
|
|
array_push($item['categories'], $tag->innertext);
|
2020-12-13 13:50:54 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-12-13 13:50:54 +03:00
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
}
|