Skip to content

Commit

Permalink
[MaalaimalarBridge] fix image (#4222)
Browse files Browse the repository at this point in the history
* [NvidiaDriverBridge] Added Windows support

* Update NvidiaDriverBridge.php

* Update NvidiaDriverBridge.php

* [MaalaimalarBridge] fix image

* [MaalaimalarBridge] fix lint
  • Loading branch information
tillcash authored Aug 19, 2024
1 parent c0e37bc commit 320afc3
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 16 deletions.
8 changes: 6 additions & 2 deletions bridges/MaalaimalarBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ private function constructContent($article)
{
$content = '';
$imageElement = $article->find('div.ignore-autoplay img', 0);
if ($imageElement) {
$content .= '<p><img src="' . $imageElement->{'data-src'} . '"></p>';
if ($imageElement && isset($imageElement->{'data-src'})) {
$url = str_replace('500x300_', '', $imageElement->{'data-src'});

if (filter_var($url, FILTER_VALIDATE_URL)) {
$content = sprintf('<p><img src="%s"></p>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'));
}
}

$storyElement = $article->find('div.story-content', 0);
Expand Down
86 changes: 72 additions & 14 deletions bridges/NvidiaDriverBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,83 @@

class NvidiaDriverBridge extends FeedExpander
{
const NAME = 'NVIDIA Linux Driver Releases';
const NAME = 'NVIDIA Driver Releases';
const URI = 'https://www.nvidia.com/Download/processFind.aspx';
const DESCRIPTION = 'Fetch the latest NVIDIA Linux driver updates';
const DESCRIPTION = 'Fetch the latest NVIDIA driver updates';
const MAINTAINER = 'tillcash';

const PARAMETERS = [
[
'whql' => [
'name' => 'Version',
'Windows' => [
'wwhql' => [
'name' => 'Driver Type',
'type' => 'list',
'values' => [
'All' => '',
'Certified' => '1',
'Studio' => '4',
],
'defaultValue' => '1',
],
],
'Linux' => [
'lwhql' => [
'name' => 'Driver Type',
'type' => 'list',
'values' => [
'All' => '',
'Beta' => '0',
'Branch' => '5',
'Certified' => '1',
],
'defaultValue' => '1',
],
],
'FreeBSD' => [
'fwhql' => [
'name' => 'Driver Type',
'type' => 'list',
'values' => [
'All' => '',
'Beta' => '0',
'New Feature Branch' => '5',
'Recommended/Certified' => '1',
'All' => '',
'Beta' => '0',
'Branch' => '5',
'Certified' => '1',
],
'defaultValue' => '1',
],
],
];

private $operatingSystem = '';

public function collectData()
{
$whql = $this->getInput('whql');

$parameters = [
'lid' => 1, // en-us
'psid' => 129, // GeForce
'osid' => 12, // Linux 64-bit
'whql' => $whql,
];

switch ($this->queriedContext) {
case 'Windows':
$whql = $this->getInput('wwhql');
$parameters['osid'] = 57;
$parameters['dtcid'] = 1; // Windows Driver DCH
$parameters['whql'] = $whql;
$this->operatingSystem = 'Windows';
break;
case 'Linux':
$whql = $this->getInput('lwwhql');
$parameters['osid'] = 12;
$parameters['whql'] = $whql;
$this->operatingSystem = 'Linux';
break;
case 'FreeBSD':
$whql = $this->getInput('fwwhql');
$parameters['osid'] = 22;
$parameters['whql'] = $whql;
$this->operatingSystem = 'FreeBSD';
break;
}

$url = 'https://www.nvidia.com/Download/processFind.aspx?' . http_build_query($parameters);
$dom = getSimpleHTMLDOM($url);

Expand All @@ -40,10 +87,21 @@ public function collectData()

$this->items[] = [
'timestamp' => $element->find('td.gridItem', 3)->plaintext,
'title' => sprintf('NVIDIA Linux Driver %s', $element->find('td.gridItem', 2)->plaintext),
'title' => sprintf('NVIDIA Driver %s', $element->find('td.gridItem', 2)->plaintext),
'uri' => 'https://www.nvidia.com/Download/driverResults.aspx/' . $id,
'content' => $dom->find('tr#tr_' . $id . ' span', 0)->innertext,
];
}
}

public function getIcon()
{
return 'https://www.nvidia.com/favicon.ico';
}

public function getName()
{
$version = $this->getKey('whql') ?? '';
return sprintf('NVIDIA %s %s Driver Releases', $this->operatingSystem, $version);
}
}

0 comments on commit 320afc3

Please sign in to comment.