From 158c4c67550781d58f22461a19549abe4fc7f1ad Mon Sep 17 00:00:00 2001 From: JackNUMBER Date: Wed, 29 May 2019 00:51:06 +0200 Subject: [PATCH 1/3] [SteamBridge] Follow source data fetching changes --- bridges/SteamBridge.php | 64 +++++++---------------------------------- 1 file changed, 10 insertions(+), 54 deletions(-) diff --git a/bridges/SteamBridge.php b/bridges/SteamBridge.php index 8ff456d798d..7a8906dd5db 100644 --- a/bridges/SteamBridge.php +++ b/bridges/SteamBridge.php @@ -8,44 +8,12 @@ class SteamBridge extends BridgeAbstract { const MAINTAINER = 'jacknumber'; const PARAMETERS = array( 'Wishlist' => array( - 'username' => array( - 'name' => 'Username', + 'userid' => array( + 'name' => 'Steamid64 (find it on steamid.io)', + 'title' => 'User ID (17 digits). Find your user ID with steamid.io or steamidfinder.com', 'required' => true, - ), - 'currency' => array( - 'name' => 'Currency', - 'type' => 'list', - 'values' => array( - // source: http://steam.steamlytics.xyz/currencies - 'USD' => 'us', - 'GBP' => 'gb', - 'EUR' => 'fr', - 'CHF' => 'ch', - 'RUB' => 'ru', - 'BRL' => 'br', - 'JPY' => 'jp', - 'SEK' => 'se', - 'IDR' => 'id', - 'MYR' => 'my', - 'PHP' => 'ph', - 'SGD' => 'sg', - 'THB' => 'th', - 'KRW' => 'kr', - 'TRY' => 'tr', - 'MXN' => 'mx', - 'CAD' => 'ca', - 'NZD' => 'nz', - 'CNY' => 'cn', - 'INR' => 'in', - 'CLP' => 'cl', - 'PEN' => 'pe', - 'COP' => 'co', - 'ZAR' => 'za', - 'HKD' => 'hk', - 'TWD' => 'tw', - 'SRD' => 'sr', - 'AED' => 'ae', - ), + 'exampleValue' => '76561198821231205', + 'pattern' => '[0-9]{17}', ), 'only_discount' => array( 'name' => 'Only discount', @@ -56,27 +24,15 @@ class SteamBridge extends BridgeAbstract { public function collectData(){ - $username = $this->getInput('username'); - $params = array( - 'cc' => $this->getInput('currency') - ); - - $url = self::URI . 'wishlist/id/' . $username . '?' . http_build_query($params); + $userid = $this->getInput('userid'); - $targetVariable = 'g_rgAppInfo'; + $sourceUrl = self::URI . 'wishlist/profiles/' . $userid . '/wishlistdata?p=0'; $sort = array(); - $html = ''; - $html = getSimpleHTMLDOM($url) - or returnServerError("Could not request Steam Wishlist. Tried:\n - $url"); + $json = getContents($sourceUrl) + or returnServerError('Could not get content from wishlistdata (' . $sourceUrl . ')'); - $jsContent = $html->find('.responsive_page_template_content script', 0)->innertext; - - if(preg_match('/var ' . $targetVariable . ' = (.*?);/s', $jsContent, $matches)) { - $appsData = json_decode($matches[1]); - } else { - returnServerError("Could not parse JS variable ($targetVariable) in page content."); - } + $appsData = json_decode($json); foreach($appsData as $id => $element) { From a9ca32659c17bc6e90ca3b9e08bb31d395327fc1 Mon Sep 17 00:00:00 2001 From: JackNUMBER Date: Wed, 29 May 2019 01:01:08 +0200 Subject: [PATCH 2/3] [SteamBridge] Improve media path building --- bridges/SteamBridge.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bridges/SteamBridge.php b/bridges/SteamBridge.php index 7a8906dd5db..db3c88990a6 100644 --- a/bridges/SteamBridge.php +++ b/bridges/SteamBridge.php @@ -73,11 +73,14 @@ public function collectData(){ } } + $coverUrl = str_replace('_292x136', '', strtok($element->capsule, '?')); + $picturesPath = pathinfo($coverUrl)['dirname'] . '/'; + $item = array(); $item['uri'] = "http://store.steampowered.com/app/$id/"; $item['title'] = $element->name; $item['type'] = $appType; - $item['cover'] = str_replace('_292x136', '', $element->capsule); + $item['cover'] = $coverUrl; $item['timestamp'] = $element->added; $item['isBuyable'] = $appIsBuyable; $item['hasDiscount'] = $appHasDiscount; @@ -97,10 +100,10 @@ public function collectData(){ } $item['enclosures'] = array(); - $item['enclosures'][] = str_replace('_292x136', '', $element->capsule); + $item['enclosures'][] = $coverUrl; - foreach($element->screenshots as $screenshot) { - $item['enclosures'][] = substr($element->capsule, 0, -31) . $screenshot; + foreach($element->screenshots as $screenshotFileName) { + $item['enclosures'][] = $picturesPath . $screenshotFileName; } $sort[$id] = $element->priority; From 3aedb687159338ddc6d0518a0d89d29cc5995857 Mon Sep 17 00:00:00 2001 From: JackNUMBER Date: Wed, 29 May 2019 02:03:22 +0200 Subject: [PATCH 3/3] [SteamBridge] Improve price fetching and display --- bridges/SteamBridge.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bridges/SteamBridge.php b/bridges/SteamBridge.php index db3c88990a6..d0acd6da561 100644 --- a/bridges/SteamBridge.php +++ b/bridges/SteamBridge.php @@ -43,6 +43,8 @@ public function collectData(){ if($element->subs) { $appIsBuyable = 1; + $priceBlock = str_get_html($element->subs[0]->discount_block); + $appPrice = str_replace('--', '00', $priceBlock->find('.discount_final_price', 0)->plaintext); if($element->subs[0]->discount_pct) { @@ -50,8 +52,6 @@ public function collectData(){ $discountBlock = str_get_html($element->subs[0]->discount_block); $appDiscountValue = $discountBlock->find('.discount_pct', 0)->plaintext; $appOldPrice = $discountBlock->find('.discount_original_price', 0)->plaintext; - $appNewPrice = $discountBlock->find('.discount_final_price', 0)->plaintext; - $appPrice = $appNewPrice; } else { @@ -59,7 +59,6 @@ public function collectData(){ continue; } - $appPrice = $element->subs[0]->price / 100; } } else { @@ -88,14 +87,21 @@ public function collectData(){ $item['priority'] = $element->priority; if($appIsBuyable) { + $item['price'] = floatval(str_replace(',', '.', $appPrice)); + $item['content'] = $appPrice; + + } + + if($appIsFree) { + $item['content'] = 'Free'; } if($appHasDiscount) { $item['discount']['value'] = $appDiscountValue; - $item['discount']['oldPrice'] = floatval(str_replace(',', '.', $appOldPrice)); - $item['discount']['newPrice'] = floatval(str_replace(',', '.', $appNewPrice)); + $item['discount']['oldPrice'] = $appOldPrice; + $item['content'] = '' . $appOldPrice . ' ' . $appPrice . ' (' . $appDiscountValue . ')'; }