From 320afc3f324ded84f56169dce70bc7721201ea0a Mon Sep 17 00:00:00 2001 From: tillcash Date: Mon, 19 Aug 2024 22:47:42 +0530 Subject: [PATCH] [MaalaimalarBridge] fix image (#4222) * [NvidiaDriverBridge] Added Windows support * Update NvidiaDriverBridge.php * Update NvidiaDriverBridge.php * [MaalaimalarBridge] fix image * [MaalaimalarBridge] fix lint --- bridges/MaalaimalarBridge.php | 8 +++- bridges/NvidiaDriverBridge.php | 86 ++++++++++++++++++++++++++++------ 2 files changed, 78 insertions(+), 16 deletions(-) diff --git a/bridges/MaalaimalarBridge.php b/bridges/MaalaimalarBridge.php index 87f85694..59c76b01 100644 --- a/bridges/MaalaimalarBridge.php +++ b/bridges/MaalaimalarBridge.php @@ -103,8 +103,12 @@ class MaalaimalarBridge extends BridgeAbstract { $content = ''; $imageElement = $article->find('div.ignore-autoplay img', 0); - if ($imageElement) { - $content .= '

'; + if ($imageElement && isset($imageElement->{'data-src'})) { + $url = str_replace('500x300_', '', $imageElement->{'data-src'}); + + if (filter_var($url, FILTER_VALIDATE_URL)) { + $content = sprintf('

', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')); + } } $storyElement = $article->find('div.story-content', 0); diff --git a/bridges/NvidiaDriverBridge.php b/bridges/NvidiaDriverBridge.php index 595411bc..6664fc77 100644 --- a/bridges/NvidiaDriverBridge.php +++ b/bridges/NvidiaDriverBridge.php @@ -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' => '', - 'Beta' => '0', - 'New Feature Branch' => '5', - 'Recommended/Certified' => '1', + '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', + '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); @@ -40,10 +87,21 @@ class NvidiaDriverBridge extends FeedExpander $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); + } }