[New Bridge] Videocardz.com bridge (#3442)

* [New Bridge] Videocardz.com Bridge

* [New Bridge] Videocardz.com Bridge

* [Videocardz.com] cache timeout increase

* [VideoCardzBridge] cache timeout change

* [VideoCardzBridge] formatting

* [VideoCardBridge] formatting fixes

* [VideoCardzBridge] formatting fixes
This commit is contained in:
rmscoelho 2023-06-20 11:45:50 +01:00 committed by GitHub
parent 0c808dc3a1
commit 5a0bacbd8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 9 deletions

View File

@ -0,0 +1,79 @@
<?php
class VideoCardzBridge extends BridgeAbstract
{
const NAME = 'VideoCardz';
const URI = 'https://videocardz.com/';
const DESCRIPTION = 'Returns news from VideoCardz.com';
const MAINTAINER = 'rmscoelho';
const CACHE_TIMEOUT = 300;
const PARAMETERS = [
[
'feed' => [
'name' => 'News Feed',
'type' => 'list',
'title' => 'Feeds from VideoCardz.com',
'values' => [
'News' => 'sections/news',
'Featured' => 'sections/featured',
'Leak' => 'sections/leak',
'Press Releases' => 'sections/press-releases',
'Preview Roundup' => 'sections/review-roundup',
'Rumour' => 'sections/rumor',
]
]
]
];
public function getIcon()
{
return 'https://videocardz.com/favicon-32x32.png?x66580';
}
public function getURI()
{
switch ($this->queriedContext) {
case 'feed':
$url = self::URI . $this->getInput('feed');
break;
default:
$url = self::URI;
}
return $url;
}
public function collectData()
{
$url = sprintf('https://videocardz.com/%s', $this->getInput('feed'));
$dom = getSimpleHTMLDOM($url);
$dom = $dom->find('.subcategory-news', 0);
if (!$dom) {
throw new \Exception(sprintf('Unable to find css selector on `%s`', $url));
}
$dom = defaultLinkTo($dom, $this->getURI());
foreach ($dom->find('article') as $article) {
//Get thumbnail
$image = $article->style;
$image = preg_replace('/background-image:url\(/i', '', $image);
$image = substr_replace($image, '', -3);
//Get date and time of publishing
$datetime = date_parse($article->find('.main-index-article-datetitle-date > a', 0)->plaintext);
$year = $datetime['year'];
$month = $datetime['month'];
$day = $datetime['day'];
$hour = $datetime['hour'];
$minute = $datetime['minute'];
$timestamp = mktime($hour, $minute, 0, $month, $day, $year);
$content = '<img src="' . $image . '" alt="' . $article->find('h2', 0)->plaintext . ' thumbnail" />';
$this->items[] = [
'title' => $article->find('h2', 0)->plaintext,
'uri' => $article->find('p.main-index-article-datetitle-date > a', 0)->href,
'content' => $content,
'timestamp' => $timestamp,
];
}
}
}

View File

@ -7,15 +7,7 @@
[system] [system]
; Only these bridges are available for feed production ; Only these bridges are available for feed production
enabled_bridges[] = Youtube enabled_bridges[] = *
enabled_bridges[] = Twitter
enabled_bridges[] = Telegram
enabled_bridges[] = Reddit
enabled_bridges[] = Filter
enabled_bridges[] = Vk
enabled_bridges[] = FeedMerge
enabled_bridges[] = Twitch
enabled_bridges[] = ThePirateBay
; Defines the timezone used by RSS-Bridge ; Defines the timezone used by RSS-Bridge
; Find a list of supported timezones at ; Find a list of supported timezones at