From 5aaab9eb8ccac18f5d8358e6d35bf0348bc06bc6 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Fri, 16 Feb 2018 22:11:03 +0100 Subject: [PATCH 01/11] [YoutubeBridge] Skip unavailable videos --- bridges/YoutubeBridge.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 3d81daeb..b10db9e8 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -50,6 +50,12 @@ class YoutubeBridge extends BridgeAbstract { private function ytBridgeQueryVideoInfo($vid, &$author, &$desc, &$time){ $html = $this->ytGetSimpleHTMLDOM(self::URI . "watch?v=$vid"); + + // Skip unavailable videos + if(!strpos($html->innertext, 'IS_UNAVAILABLE_PAGE')){ + return; + } + $author = $html->innertext; $author = substr($author, strpos($author, '"author=') + 8); $author = substr($author, 0, strpos($author, '\u0026')); From 4f6277b6b508c9389c8bb6730f503ae27f7f2134 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Fri, 16 Feb 2018 22:12:24 +0100 Subject: [PATCH 02/11] [YoutubeBridge] Fix parsing author name breaks the bridge The author name is parsed by searching a string within the entire HTML document: $author = $html->innertext; $author = substr($author, strpos($author, '"author=') + 8); $author = substr($author, 0, strpos($author, '\u0026')); This solution will return big portions of the HTML document if the strpos function returns zero (not found). This commit replaces the previous implementation by searching for a specific script tag and making use of the JSON data inside it. References #580 --- bridges/YoutubeBridge.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index b10db9e8..b4c3f6c0 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -56,9 +56,19 @@ class YoutubeBridge extends BridgeAbstract { return; } - $author = $html->innertext; - $author = substr($author, strpos($author, '"author=') + 8); - $author = substr($author, 0, strpos($author, '\u0026')); + foreach($html->find('script') as $script){ + $data = trim($script->innertext); + + if(strpos($data, '{') !== 0) + continue; // Wrong script + + $json = json_decode($data); + + if(!isset($json->itemListElement)) + continue; // Wrong script + + $author = $json->itemListElement[0]->item->name; + } if(!is_null($html->find('div#watch-description-text', 0))) $desc = $html->find('div#watch-description-text', 0)->innertext; From 962617086ebe2868a40f16592ac3dd3ba4748bf1 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Fri, 16 Feb 2018 22:26:18 +0100 Subject: [PATCH 03/11] [YoutubeBridge] Remove superfluous div selectors --- bridges/YoutubeBridge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index b4c3f6c0..32d42164 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -70,8 +70,8 @@ class YoutubeBridge extends BridgeAbstract { $author = $json->itemListElement[0]->item->name; } - if(!is_null($html->find('div#watch-description-text', 0))) - $desc = $html->find('div#watch-description-text', 0)->innertext; + if(!is_null($html->find('#watch-description-text', 0))) + $desc = $html->find('#watch-description-text', 0)->innertext; if(!is_null($html->find('meta[itemprop=datePublished]', 0))) $time = strtotime($html->find('meta[itemprop=datePublished]', 0)->getAttribute('content')); From 4805b52d4263d54daf6e80e697fec8495d0cf276 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Fri, 16 Feb 2018 22:35:00 +0100 Subject: [PATCH 04/11] [YoutubeBridge] Fix typo --- bridges/YoutubeBridge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 32d42164..321fb264 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -52,11 +52,11 @@ class YoutubeBridge extends BridgeAbstract { $html = $this->ytGetSimpleHTMLDOM(self::URI . "watch?v=$vid"); // Skip unavailable videos - if(!strpos($html->innertext, 'IS_UNAVAILABLE_PAGE')){ + if(!strpos($html->innertext, 'IS_UNAVAILABLE_PAGE')) { return; } - foreach($html->find('script') as $script){ + foreach($html->find('script') as $script) { $data = trim($script->innertext); if(strpos($data, '{') !== 0) From 0622fe142b6ad3e5bbb95b0ab4d88dd0333579b3 Mon Sep 17 00:00:00 2001 From: sysadminstory Date: Thu, 1 Mar 2018 18:10:34 +0100 Subject: [PATCH 05/11] Dealabs : Added Groupes Feeds and Feed name is set according to parameters (#630) * [DealabsBride] Added Groupes Feeds --- bridges/DealabsBridge.php | 299 ++++++++++++++++++++++++++++---------- 1 file changed, 225 insertions(+), 74 deletions(-) diff --git a/bridges/DealabsBridge.php b/bridges/DealabsBridge.php index cd020171..d2cab2f0 100644 --- a/bridges/DealabsBridge.php +++ b/bridges/DealabsBridge.php @@ -4,50 +4,120 @@ class DealabsBridge extends BridgeAbstract { const URI = 'https://www.dealabs.com/'; const DESCRIPTION = 'Return the Dealabs search result using keywords'; const MAINTAINER = 'sysadminstory'; - const PARAMETERS = array( array ( - 'q' => array( - 'name' => 'Mot(s) clé(s)', - 'type' => 'text', - 'required' => true + const PARAMETERS = array( + 'Recherche par Mot(s) clé(s)' => array ( + 'q' => array( + 'name' => 'Mot(s) clé(s)', + 'type' => 'text', + 'required' => true + ), + 'hide_expired' => array( + 'name' => 'Masquer les éléments expirés', + 'type' => 'checkbox', + 'required' => 'true' + ), + 'hide_local' => array( + 'name' => 'Masquer les deals locaux', + 'type' => 'checkbox', + 'title' => 'Masquer les deals en magasins physiques', + 'required' => 'true' + ), + 'priceFrom' => array( + 'name' => 'Prix minimum', + 'type' => 'text', + 'title' => 'Prix mnimum en euros', + 'required' => 'false', + 'defaultValue' => '' + ), + 'priceTo' => array( + 'name' => 'Prix maximum', + 'type' => 'text', + 'title' => 'Prix maximum en euros', + 'required' => 'false', + 'defaultValue' => '' + ), ), - 'hide_expired' => array( - 'name' => 'Masquer les éléments expirés', - 'type' => 'checkbox', - 'required' => 'true' - ), - 'hide_local' => array( - 'name' => 'Masquer les deals locaux', - 'type' => 'checkbox', - 'title' => 'Masquer les deals en magasins physiques', - 'required' => 'true' - ), - 'priceFrom' => array( - 'name' => 'Prix minimum', - 'type' => 'text', - 'title' => 'Prix mnimum en euros', - 'required' => 'false', - 'defaultValue' => '' - ), - 'priceTo' => array( - 'name' => 'Prix maximum', - 'type' => 'text', - 'title' => 'Prix maximum en euros', - 'required' => 'false', - 'defaultValue' => '' - ), - )); + + 'Deals par groupe' => array( + 'groupe' => array( + 'name' => 'Groupe', + 'type' => 'list', + 'required' => 'true', + 'title' => 'Groupe dont il faut afficher les deals', + 'values' => array( + 'Accessoires & gadgets' => 'accessoires-gadgets', + 'Alimentation & boissons' => 'alimentation-boissons', + 'Animaux' => 'animaux', + 'Applis & logiciels' => 'applis-logiciels', + 'Consoles & jeux vidéo' => 'consoles-jeux-video', + 'Culture & divertissement' => 'culture-divertissement', + 'Gratuit' => 'gratuit', + 'Image, son & vidéo' => 'image-son-video', + 'Informatique' => 'informatique', + 'Jeux & jouets' => 'jeux-jouets', + 'Maison & jardin' => 'maison-jardin', + 'Mode & accessoires' => 'mode-accessoires', + 'Santé & cosmétiques' => 'hygiene-sante-cosmetiques', + 'Services divers' => 'services-divers', + 'Sports & plein air' => 'sports-plein-air', + 'Téléphonie' => 'telephonie', + 'Voyages & sorties' => 'voyages-sorties-restaurants' + ) + ), + 'ordre' => array( + 'name' => 'Trier par', + 'type' => 'list', + 'required' => 'true', + 'title' => 'Ordre de tri des deals', + 'values' => array( + 'Du deal le plus Hot au moins Hot' => '', + 'Du deal le plus récent au plus ancien' => '-nouveaux', + 'Du deal le plus commentés au moins commentés' => '-commentes' + ) + ) + ) + ); const CACHE_TIMEOUT = 3600; public function collectData(){ + switch($this->queriedContext) { + case 'Recherche par Mot(s) clé(s)': + return $this->collectDataMotsCles(); + break; + case 'Deals par groupe': + return $this->collectDataGroupe(); + break; + } + } + + /** + * Get the Deal data from the choosen groupe in the choose order + */ + public function collectDataGroupe() + { + + $groupe = $this->getInput('groupe'); + $ordre = $this->getInput('ordre'); + + $url = self::URI + . '/groupe/' . $groupe . $ordre; + $this->collectDeals($url); + } + + /** + * Get the Deal data from the choosen keywords and parameters + */ + public function collectDataMotsCles() + { $q = $this->getInput('q'); $hide_expired = $this->getInput('hide_expired'); $hide_local = $this->getInput('hide_local'); $priceFrom = $this->getInput('priceFrom'); $priceTo = $this->getInput('priceFrom'); - /* Event if the original website uses POST with the search page, GET works too */ - $html = getSimpleHTMLDOM(self::URI + /* Even if the original website uses POST with the search page, GET works too */ + $url = self::URI . '/search/advanced?q=' . urlencode($q) . '&hide_expired='. $hide_expired @@ -59,52 +129,118 @@ class DealabsBridge extends BridgeAbstract { * sort_by : Sort the search by new deals * time_frame : Search will not be on a limited timeframe */ - . '&search_fields[]=1&search_fields[]=2&search_fields[]=3&sort_by=new&time_frame=0') + . '&search_fields[]=1&search_fields[]=2&search_fields[]=3&sort_by=new&time_frame=0'; + $this->collectDeals($url); + } + + /** + * Get the Deal data using the given URL + */ + public function collectDeals($url){ + $html = getSimpleHTMLDOM($url) or returnServerError('Could not request Dealabs.'); $list = $html->find('article'); - if($list === null) { - returnClientError('Your combination of parameters returned no results'); - } - foreach($list as $deal) { - $item = array(); - $item['uri'] = $deal->find('div[class=threadGrid-title]', 0)->find('a', 0)->href; - $item['title'] = $deal->find( - 'a[class=cept-tt thread-link linkPlain space--r-1 size--all-s size--fromW3-m]', 0 - )->plaintext; - $item['author'] = $deal->find('span.thread-username', 0)->plaintext; - $item['content'] = '

' - . $deal->find('a[class=cept-tt thread-link linkPlain space--r-1 size--all-s size--fromW3-m]', 0)->innertext - . '

' - . $this->getPrix($deal) - . $this->getReduction($deal) - . $this->getExpedition($deal) - . $this->getLivraison($deal) - . $this->getOrigine($deal) - . $deal->find( - 'div[class=cept-description-container overflow--wrap-break size--all-s size--fromW3-m]', 0 - )->innertext - . '
' - . $deal->find('div[class=flex flex--align-c flex--justify-space-between space--b-2]', 0)->children(0)->outertext - . '
'; - $dealDateDiv = $deal->find('div[class=size--all-s flex flex--wrap flex--justify-e flex--grow-1]', 0) - ->find('span[class=hide--toW3]'); - $itemDate = end($dealDateDiv)->plaintext; - if(substr( $itemDate, 0, 6 ) === 'il y a') { - $item['timestamp'] = $this->relativeDateToTimestamp($itemDate); - } else { - $item['timestamp'] = $this->parseDate($itemDate); + // Deal Image Link CSS Selector + $selectorImageLink = implode( + ' ', /* Notice this is a space! */ + array( + 'cept-thread-image-link', + 'imgFrame', + 'imgFrame--noBorder', + 'box--all-i', + 'thread-listImgCell', + ) + ); + + // Deal Link CSS Selector + $selectorLink = implode( + ' ', /* Notice this is a space! */ + array( + 'cept-tt', + 'thread-link', + 'linkPlain', + 'space--r-1', + 'size--all-s', + 'size--fromW3-m', + ) + ); + + // Deal Hotness CSS Selector + $selectorHot = implode( + ' ', /* Notice this is a space! */ + array( + 'flex', + 'flex--align-c', + 'flex--justify-space-between', + 'space--b-2', + ) + ); + + // Deal Description CSS Selector + $selectorDescription = implode( + ' ', /* Notice this is a space! */ + array( + 'cept-description-container', + 'overflow--wrap-break', + 'size--all-s', + 'size--fromW3-m', + ) + ); + + // Deal Date CSS Selector + $selectorDate = implode( + ' ', /* Notice this is a space! */ + array( + 'size--all-s', + 'flex', + 'flex--wrap', + 'flex--justify-e', + 'flex--grow-1', + ) + ); + + // If there is no results, we don't parse the content because it display some random deals + $noresult = $html->find('h3[class=size--all-l size--fromW2-xl size--fromW3-xxl]', 0); + if($noresult != null && $noresult->plaintext == 'Il n'y a rien à afficher pour le moment :(') { + $this->items = array(); + } else { + foreach($list as $deal) { + $item = array(); + $item['uri'] = $deal->find('div[class=threadGrid-title]', 0)->find('a', 0)->href; + $item['title'] = $deal->find('a[class='. $selectorLink .']', 0 + )->plaintext; + $item['author'] = $deal->find('span.thread-username', 0)->plaintext; + $item['content'] = '

' + . $deal->find('a[class='. $selectorLink .']', 0)->innertext + . '

' + . $this->getPrix($deal) + . $this->getReduction($deal) + . $this->getExpedition($deal) + . $this->getLivraison($deal) + . $this->getOrigine($deal) + . $deal->find('div[class='. $selectorDescription .']', 0)->innertext + . '
' + . $deal->find('div[class='. $selectorHot .']', 0)->children(0)->outertext + . '
'; + $dealDateDiv = $deal->find('div[class='. $selectorDate .']', 0) + ->find('span[class=hide--toW3]'); + $itemDate = end($dealDateDiv)->plaintext; + if(substr( $itemDate, 0, 6 ) === 'il y a') { + $item['timestamp'] = $this->relativeDateToTimestamp($itemDate); + } else { + $item['timestamp'] = $this->parseDate($itemDate); + } + $this->items[] = $item; } - $this->items[] = $item; } - } /** @@ -320,4 +456,19 @@ class DealabsBridge extends BridgeAbstract { return $date->getTimestamp(); } + public function getName(){ + switch($this->queriedContext) { + case 'Recherche par Mot(s) clé(s)': + return self::NAME . ' - Recherche : '. $this->getInput('q'); + break; + case 'Deals par groupe': + $values = self::PARAMETERS['Deals par groupe']['groupe']['values']; + $groupe = array_search($this->getInput('groupe'), $values); + return self::NAME . ' - Groupe : '. $groupe; + break; + default: // Return default value + return self::NAME; + } + } + } From 26ce16baa22b0d4afe48a1eb6cbf63e5c8428611 Mon Sep 17 00:00:00 2001 From: Mitsukarenai Date: Sat, 3 Mar 2018 21:04:40 +0100 Subject: [PATCH 06/11] [PlanetLibre] remove bridge (origin now has RSS) --- bridges/PlanetLibreBridge.php | 38 ----------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 bridges/PlanetLibreBridge.php diff --git a/bridges/PlanetLibreBridge.php b/bridges/PlanetLibreBridge.php deleted file mode 100644 index 03a6024d..00000000 --- a/bridges/PlanetLibreBridge.php +++ /dev/null @@ -1,38 +0,0 @@ -find('div[class="post-text"]', 0)->innertext; - return $text; - } - - public function collectData(){ - $html = getSimpleHTMLDOM(self::URI) - or returnServerError('Could not request PlanetLibre.'); - $limit = 0; - foreach($html->find('div.post') as $element) { - if($limit < 5) { - $item = array(); - $item['title'] = $element->find('h1', 0)->plaintext; - $item['uri'] = $element->find('a', 0)->href; - $item['timestamp'] = strtotime( - str_replace( - '/', - '-', - $element->find('div[class="post-date"]', 0)->plaintext - ) - ); - - $item['content'] = $this->extractContent($item['uri']); - $this->items[] = $item; - $limit++; - } - } - } -} From 159b00145dfc390e9e8e6315a1413985068142bf Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Mon, 5 Mar 2018 14:46:15 +0500 Subject: [PATCH 07/11] [VkBridge] Setting feed title (#635) * [VkBridge] Setting feed title --- bridges/VkBridge.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bridges/VkBridge.php b/bridges/VkBridge.php index 85bf60c5..4eba9610 100644 --- a/bridges/VkBridge.php +++ b/bridges/VkBridge.php @@ -17,6 +17,8 @@ class VkBridge extends BridgeAbstract ) ); + protected $pageName; + public function getURI() { if (!is_null($this->getInput('u'))) { @@ -26,15 +28,24 @@ class VkBridge extends BridgeAbstract return parent::getURI(); } + public function getName() + { + if ($this->pageName) { + return $this->pageName; + } + + return parent::getName(); + } + public function collectData() { - $text_html = $this->getContents() or returnServerError('No results for group or user name "' . $this->getInput('u') . '".'); $text_html = iconv('windows-1251', 'utf-8', $text_html); $html = str_get_html($text_html); $pageName = $html->find('.page_name', 0)->plaintext; + $this->pageName = $pageName; foreach ($html->find('.post') as $post) { From 6e916ddd35f22d048d71892c93f5248d929ba4e6 Mon Sep 17 00:00:00 2001 From: teromene Date: Tue, 6 Mar 2018 11:26:16 +0000 Subject: [PATCH 08/11] Fix Arte7Bridge. Fixes #633 --- bridges/Arte7Bridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 42b5afcc..1162d174 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -60,7 +60,7 @@ class Arte7Bridge extends BridgeAbstract { break; } - $url = 'https://api.arte.tv/api/opa/v3/videos?sort=broadcastBegin&limit=10&language=' + $url = 'https://api.arte.tv/api/opa/v3/videos?sort=-lastModified&limit=10&language=' . $lang . ($category != null ? '&category.code=' . $category : ''); From 2149af0e74a3c7cac6e90d58a8383bbddc790e33 Mon Sep 17 00:00:00 2001 From: teromene Date: Tue, 6 Mar 2018 12:01:48 +0000 Subject: [PATCH 09/11] Fix Pinterest bridge, remove the old JSON parsing, and return original sized image. Fixes #632 --- bridges/PinterestBridge.php | 62 ++++++------------------------------- 1 file changed, 10 insertions(+), 52 deletions(-) diff --git a/bridges/PinterestBridge.php b/bridges/PinterestBridge.php index c5282ff5..7eeafc1a 100644 --- a/bridges/PinterestBridge.php +++ b/bridges/PinterestBridge.php @@ -15,12 +15,6 @@ class PinterestBridge extends FeedExpander { 'b' => array( 'name' => 'board', 'required' => true - ), - 'r' => array( - 'name' => 'Use custom RSS', - 'type' => 'checkbox', - 'required' => false, - 'title' => 'Uncheck to return data via custom filters (more data)' ) ), 'From search' => array( @@ -34,12 +28,8 @@ class PinterestBridge extends FeedExpander { public function collectData(){ switch($this->queriedContext) { case 'By username and board': - if($this->getInput('r')) { - $html = getSimpleHTMLDOMCached($this->getURI()); - $this->getUserResults($html); - } else { - $this->collectExpandableDatas($this->getURI() . '.rss'); - } + $this->collectExpandableDatas($this->getURI() . '.rss'); + $this->fixLowRes(); break; case 'From search': default: @@ -48,49 +38,17 @@ class PinterestBridge extends FeedExpander { } } - private function getUserResults($html){ - $json = json_decode($html->find('#jsInit1', 0)->innertext, true); - $results = $json['tree']['children'][0]['children'][0]['children'][0]['options']['props']['data']['board_feed']; - $username = $json['resourceDataCache'][0]['data']['owner']['username']; - $fullname = $json['resourceDataCache'][0]['data']['owner']['full_name']; - $avatar = $json['resourceDataCache'][0]['data']['owner']['image_small_url']; + private function fixLowRes() { - foreach($results as $result) { - $item = array(); + $newitems = []; + $pattern = '/https\:\/\/i\.pinimg\.com\/[a-zA-Z0-9]*x\//'; + foreach($this->items as $item) { - $item['uri'] = $result['link']; - - // Some use regular titles, others provide 'advanced' infos, a few - // provide even less info. Thus we attempt multiple options. - $item['title'] = trim($result['title']); - - if($item['title'] === "") - $item['title'] = trim($result['rich_summary']['display_name']); - - if($item['title'] === "") - $item['title'] = trim($result['description']); - - $item['timestamp'] = strtotime($result['created_at']); - $item['username'] = $username; - $item['fullname'] = $fullname; - $item['avatar'] = $avatar; - $item['author'] = $item['username'] . ' (' . $item['fullname'] . ')'; - $item['content'] = '

' - . $item['username'] - . '
' - . $item['fullname'] - . '



' - . $result['description'] - . '

'; - - $item['enclosures'] = array($result['images']['orig']['url']); - - $this->items[] = $item; + $item["content"] = preg_replace($pattern, 'https://i.pinimg.com/originals/', $item["content"]); + $newitems[] = $item; } + $this->items = $newitems; + } private function getSearchResults($html){ From 6eea51eeeb1f988a366ac315c411d2420ac47967 Mon Sep 17 00:00:00 2001 From: teromene Date: Wed, 7 Mar 2018 10:24:33 +0000 Subject: [PATCH 10/11] Fix SteamBridge. Fixes #636 --- bridges/SteamBridge.php | 77 +++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/bridges/SteamBridge.php b/bridges/SteamBridge.php index b0f1033f..8d6e4f13 100644 --- a/bridges/SteamBridge.php +++ b/bridges/SteamBridge.php @@ -2,7 +2,7 @@ class SteamBridge extends BridgeAbstract { const NAME = 'Steam Bridge'; - const URI = 'https://steamcommunity.com/'; + const URI = 'https://store.steampowered.com/'; const CACHE_TIMEOUT = 3600; // 1h const DESCRIPTION = 'Returns games list'; const MAINTAINER = 'jacknumber'; @@ -68,62 +68,65 @@ class SteamBridge extends BridgeAbstract { $username = $this->getInput('username'); $params = array( - 'sort' => $this->getInput('sort'), - 'cc' => $this->getInput('currency') + 'cc' => $this->getInput('currency'), + 'sort' => $this->getInput('sort') ); - $url = self::URI . 'id/' . $username . '/wishlist?' . http_build_query($params); + $url = self::URI . 'wishlist/id/' . $username . '/?' . http_build_query($params); - $html = ''; - $html = getSimpleHTMLDOM($url) + $jsonDataRegex = '/var g_rg(?:WishlistData|AppInfo) = ([^;]*)/'; + $content = getContents($url) or returnServerError("Could not request Steam Wishlist. Tried:\n - $url"); - foreach($html->find('#wishlist_items .wishlistRow') as $element) { + preg_match_all($jsonDataRegex, $content, $matches, PREG_SET_ORDER, 0); - $gameTitle = $element->find('h4', 0)->plaintext; - $gameUri = $element->find('.storepage_btn_ctn a', 0)->href; - $gameImg = $element->find('.gameListRowLogo img', 0)->src; + $appList = json_decode($matches[0][1], true); + $fullAppList = json_decode($matches[1][1], true); + //var_dump($matches[1][1]); + //var_dump($fullAppList); + $sortedElementList = array_fill(0, count($appList), 0); + foreach($appList as $app) { - $discountBlock = $element->find('.discount_block', 0); + $sortedElementList[$app["priority"] - 1] = $app["appid"]; - if($element->find('.discount_block', 0)) { - $gameHasPromo = 1; - } else { + } - if($this->getInput('only_discount')) { - continue; - } + foreach($sortedElementList as $appId) { - $gameHasPromo = 0; - - } - - if($gameHasPromo) { - - $gamePromoValue = $discountBlock->find('.discount_pct', 0)->plaintext; - $gameOldPrice = $discountBlock->find('.discount_original_price', 0)->plaintext; - $gameNewPrice = $discountBlock->find('.discount_final_price', 0)->plaintext; - $gamePrice = $gameNewPrice; - - } else { - $gamePrice = $element->find('.gameListPriceData .price', 0)->plaintext; - } + $app = $fullAppList[$appId]; + $gameTitle = $app["name"]; + $gameUri = "http://store.steampowered.com/app/" . $appId . "/"; + $gameImg = $app["capsule"]; $item = array(); $item['uri'] = $gameUri; $item['title'] = $gameTitle; - $item['price'] = $gamePrice; - $item['hasPromo'] = $gameHasPromo; - if($gameHasPromo) { + if(count($app["subs"]) > 0) { + if($app["subs"][0]["discount_pct"] != 0) { - $item['promoValue'] = $gamePromoValue; - $item['oldPrice'] = $gameOldPrice; - $item['newPrice'] = $gameNewPrice; + $item['promoValue'] = $app["subs"][0]["discount_pct"]; + $item['oldPrice'] = $app["subs"][0]["price"] / 100 / ((100 - $gamePromoValue / 100)); + $item['newPrice'] = $app["subs"][0]["price"] / 100; + $item['price'] = $item['newPrice']; + + $item['hasPromo'] = true; + + } else { + + if($this->getInput('only_discount')) { + continue; + } + + $item['price'] = $app["subs"][0]["price"] / 100; + $item['hasPromo'] = false; + } } $this->items[] = $item; + } + } } From 29a1c7ac094bdbce03ffcc187310763de935f92d Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 7 Mar 2018 19:06:42 +0100 Subject: [PATCH 11/11] [index.php] Add extension check for 'mbstring' The mbstring extension is required by all formats in order to convert multi- byte characters to UTF-8. This commit adds an extension check to throw an error message if the extension is not enabled. --- index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.php b/index.php index 799980b5..851f0f92 100644 --- a/index.php +++ b/index.php @@ -70,6 +70,9 @@ if(!extension_loaded('openssl')) if(!extension_loaded('libxml')) die('"libxml" extension not loaded. Please check "php.ini"'); +if(!extension_loaded('mbstring')) + die('"mbstring" extension not loaded. Please check "php.ini"'); + // configuration checks if(ini_get('allow_url_fopen') !== "1") die('"allow_url_fopen" is not set to "1". Please check "php.ini');