[RaceDepartmentBridge] Follow site changes (#2087)

This commit is contained in:
t0stiman 2021-05-17 20:18:51 +02:00 committed by GitHub
parent 655e02e3fe
commit 2b793f04de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 25 deletions

View File

@ -6,17 +6,21 @@ class RaceDepartmentBridge extends FeedExpander {
const MAINTAINER = 't0stiman';
public function collectData() {
$this->collectExpandableDatas('https://www.racedepartment.com/news/archive.rss', 10);
$this->collectExpandableDatas('https://www.racedepartment.com/ams/index.rss', 10);
}
protected function parseItem($feedItem) {
$item = parent::parseItem($feedItem);
$item = parent::parseRSS_2_0_Item($feedItem);
//fetch page
$articlePage = getSimpleHTMLDOMCached($feedItem->link)
or returnServerError('Could not retrieve ' . $feedItem->link);
//extract article
$item['content'] = $articlePage->find('div.thfeature_firstPost', 0);
$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);
//convert iframes to links. meant for embedded videos.
foreach($item['content']->find('iframe') as $found) {
@ -28,29 +32,11 @@ class RaceDepartmentBridge extends FeedExpander {
}
}
//get rid of some elements we don't need
$to_remove_selectors = array(
'div.p-title', //title
'ul.listInline', //Thread starter, Start date
'div.rd_news_article_share_buttons',
'div.thfeature_firstPost-author',
'div.reactionsBar',
'footer',
'div.message-lastEdit',
'section.message-attachments'
);
foreach($to_remove_selectors as $selector) {
foreach($item['content']->find($selector) as $found) {
$found->outertext = '';
}
$item['categories'] = array();
foreach($articlePage->find('a.tagItem') as $tag) {
array_push($item['categories'], $tag->innertext);
}
//category
$forumPath = $articlePage->find('div.breadcrumb', 0);
$pathElements = $forumPath->find('span');
$item['categories'] = array(end($pathElements)->innertext);
return $item;
}
}