diff options
author | 2024-10-17 14:14:51 +0200 | |
---|---|---|
committer | 2024-10-17 14:14:51 +0200 | |
commit | bd88bc27d3113717caf28023bbeb39a02f58901f (patch) | |
tree | dbecfc4b10c90d893859edd375e7cc9dd589570e | |
parent | 56994b3b5c732089548c7fba49286916550e569a (diff) | |
download | rss-bridge-bd88bc27d3113717caf28023bbeb39a02f58901f.tar.gz rss-bridge-bd88bc27d3113717caf28023bbeb39a02f58901f.tar.zst rss-bridge-bd88bc27d3113717caf28023bbeb39a02f58901f.zip |
[TheDrive] New bridge (#4304)
-rw-r--r-- | bridges/TheDriveBridge.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/bridges/TheDriveBridge.php b/bridges/TheDriveBridge.php new file mode 100644 index 00000000..f164dccd --- /dev/null +++ b/bridges/TheDriveBridge.php @@ -0,0 +1,45 @@ +<?php + +class TheDriveBridge extends FeedExpander +{ + const NAME = 'The Drive'; + const URI = 'https://www.thedrive.com/'; + const DESCRIPTION = 'Car news from thedrive.com'; + const MAINTAINER = 't0stiman'; + const DONATION_URI = 'https://ko-fi.com/tostiman'; + + public function collectData() + { + $this->collectExpandableDatas('https://www.thedrive.com/feed', 20); + } + + protected function parseItem($feedItem) + { + $item = parent::parseItem($feedItem); + + //remove warzone articles + if (str_contains($item['uri'], 'the-war-zone')) { + return null; + } + + //the first image in the article is an attachment for some reason + foreach ($item['enclosures'] as $attachment) { + $item['content'] = '<img src="' . $attachment . '">' . $item['content']; + } + $item['enclosures'] = []; + + //make youtube videos clickable + $html = str_get_html($item['content']); + + foreach ($html->find('div.lazied-youtube-frame') as $youtubeVideoDiv) { + $videoID = $youtubeVideoDiv->getAttribute('data-video-id'); + + //place <a> around the <div> + $youtubeVideoDiv->outertext = '<a href="https://www.youtube.com/watch?v=' . $videoID . '">' . $youtubeVideoDiv->outertext . '</a>'; + } + + $item['content'] = $html; + + return $item; + } +} |