From 98d551f0b2de50401065fe794795ba063f74793a Mon Sep 17 00:00:00 2001 From: Damien Calesse Date: Fri, 18 Jul 2014 15:07:51 +0200 Subject: [PATCH 1/4] Change WhydBridge.php --- bridges/WhydBridge.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bridges/WhydBridge.php b/bridges/WhydBridge.php index 6f98f57..6b1633e 100644 --- a/bridges/WhydBridge.php +++ b/bridges/WhydBridge.php @@ -21,7 +21,17 @@ class WhydBridge extends BridgeAbstract{ if (isset($param['u'])) { $this->request = $param['u']; - $html = file_get_html('http://www.whyd.com/u/'.urlencode($this->request)) or $this->returnError('No results for this query.', 404); + if (strlen(preg_replace("/[^0-9a-f]/",'', $this->request)) == 24) { // is input the userid ? + $html = file_get_html('http://www.whyd.com/u/'.preg_replace("/[^0-9a-f]/",'', $this->request)) or $this->returnError('No results for this query.', 404); + } else { // input may be the username + $html = file_get_html('http://www.whyd.com/search?q='.urlencode($this->request)) or $this->returnError('No results for this query.', 404); + for ($j = 0; $j < 5; $j++) { + if (strtolower($html->find('div.user', $j)->find('a',0)->plaintext) == strtolower($this->request)) { + $html = file_get_html('http://www.whyd.com' . $html->find('div.user', $j)->find('a', 0)->getAttribute('href')) or $this->returnError('No results for this query', 404); + break; + } + } + } $this->name = $html->find('div#profileTop', 0)->find('h1', 0)->plaintext; } else From ce9a5e2489e8339c411027848778d5c60cd694f0 Mon Sep 17 00:00:00 2001 From: Damien Calesse Date: Fri, 18 Jul 2014 15:10:18 +0200 Subject: [PATCH 2/4] Change WhydBridge.php --- bridges/WhydBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/WhydBridge.php b/bridges/WhydBridge.php index 6b1633e..18a6a76 100644 --- a/bridges/WhydBridge.php +++ b/bridges/WhydBridge.php @@ -59,6 +59,6 @@ class WhydBridge extends BridgeAbstract{ } public function getCacheDuration(){ - return 1; // 10 minutes + return 600; // 10 minutes } } From 9156552f91c0c0edb1c076db43109be1f9d52f53 Mon Sep 17 00:00:00 2001 From: 16mhz Date: Fri, 18 Jul 2014 18:21:07 +0200 Subject: [PATCH 3/4] Add Humble Store Discount Bridge --- bridges/HumbleStoreDiscountBridge.php | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 bridges/HumbleStoreDiscountBridge.php diff --git a/bridges/HumbleStoreDiscountBridge.php b/bridges/HumbleStoreDiscountBridge.php new file mode 100644 index 0000000..4bcea23 --- /dev/null +++ b/bridges/HumbleStoreDiscountBridge.php @@ -0,0 +1,59 @@ +returnError('Could not request the Humble Store.', 404); + $string = json_decode($result, true); + $items = $string['results']; + $store_link = 'https://www.humblebundle.com/store/p/'; + $limit = 0; + + foreach ($items as $key => $value) { + if ($limit < 10) { + $new_price = $value['current_price'][0] . ' ' . $value['current_price'][1]; + $full_price = $value['full_price'][0] . ' ' . $value['full_price'][1]; + $product_name = $value['human_name']; + $product_uri = $store_link . $value['machine_name']; + $platforms = str_replace('\'', '', implode("','", $value['platforms'])); + $delivery_methods = str_replace('\'', '', implode("','", $value['delivery_methods'])); + + $content = '' . $product_name . '
Current price: ' . $new_price . '
Full price: ' . $full_price + . '
Delivery methods: ' . $delivery_methods . '
Platforms: ' + . $platforms . '
' . $value['description']; + + $item = new \Item(); + $item->title = $product_name . ' - ' . $new_price; + $item->uri = $product_uri; + $item->content = $content; + $this->items[] = $item; + $limit++; + } + } + } + + public function getName(){ + return 'HumbleStoreDiscount'; + } + + public function getURI(){ + return 'https://www.humblebundle.com/store'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} + From 92f1d580269848f07f34846b63337681613610b3 Mon Sep 17 00:00:00 2001 From: Paul Vayssiere Date: Fri, 18 Jul 2014 12:52:55 -0500 Subject: [PATCH 4/4] oops, it was a bit too short... --- bridges/DeveloppezDotComBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/DeveloppezDotComBridge.php b/bridges/DeveloppezDotComBridge.php index bc868ae..985b68c 100644 --- a/bridges/DeveloppezDotComBridge.php +++ b/bridges/DeveloppezDotComBridge.php @@ -47,7 +47,7 @@ class DeveloppezDotComBridge extends BridgeAbstract{ $limit = 0; foreach($rssFeed->find('item') as $element) { - if($limit < 2) { + if($limit < 10) { $item = new \Item(); $item->title = DeveloppezDotComStripCDATA($element->find('title', 0)->innertext); $item->uri = DeveloppezDotComStripCDATA($element->find('guid', 0)->plaintext);