From 7e91186c6ce3209b13475e5d30158df3039aa546 Mon Sep 17 00:00:00 2001 From: Albirew Date: Sat, 9 Jan 2016 10:23:19 +0100 Subject: [PATCH 01/13] TPB changed domain (again) TPB added .ms TLD and on the fly, .vg got down. PS: .se TLD still exist. --- bridges/ThePirateBayBridge.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bridges/ThePirateBayBridge.php b/bridges/ThePirateBayBridge.php index adb3641..020f4e8 100644 --- a/bridges/ThePirateBayBridge.php +++ b/bridges/ThePirateBayBridge.php @@ -5,9 +5,9 @@ class ThePirateBayBridge extends BridgeAbstract{ $this->maintainer = "mitsukarenai"; $this->name = "The Pirate Bay"; - $this->uri = "https://thepiratebay.vg/"; + $this->uri = "https://thepiratebay.ms/"; $this->description = "Returns results for the keywords. You can put several list of keywords by separating them with a semicolon (e.g. \"one show;another show\")"; - $this->update = "2014-05-26"; + $this->update = "2015-01-09"; $this->parameters[] = '[ @@ -60,7 +60,7 @@ class ThePirateBayBridge extends BridgeAbstract{ $keywordsList = explode(";",$param['q']); foreach($keywordsList as $keywords){ - $html = file_get_html('https://thepiratebay.vg/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnError('Could not request TPB.', 404); + $html = file_get_html('https://thepiratebay.ms/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnError('Could not request TPB.', 404); if ($html->find('table#searchResult', 0) == FALSE) $this->returnError('No result for query '.$keywords, 404); @@ -68,7 +68,7 @@ class ThePirateBayBridge extends BridgeAbstract{ foreach($html->find('tr') as $element) { $item = new \Item(); - $item->uri = 'https://thepiratebay.vg/'.$element->find('a.detLink',0)->href; + $item->uri = 'https://thepiratebay.ms/'.$element->find('a.detLink',0)->href; $item->id = $item->uri; $item->timestamp = parseDateTimestamp($element); $item->title = $element->find('a.detLink',0)->plaintext; @@ -86,7 +86,7 @@ class ThePirateBayBridge extends BridgeAbstract{ } public function getURI(){ - return 'https://thepiratebay.vg/'; + return 'https://thepiratebay.ms/'; } public function getCacheDuration(){ From 29481c73c1cdd1d74bea9d66edf705028ca2778f Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 9 Jan 2016 20:59:39 +0100 Subject: [PATCH 02/13] Clarify meaning of Broadcasts option Twitch returns Broadcasts when set to true, highlights otherwise. See also: https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-channelschannelvideos --- bridges/TwitchApiBridge.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridges/TwitchApiBridge.php b/bridges/TwitchApiBridge.php index aaa0d3b..c3dbdef 100644 --- a/bridges/TwitchApiBridge.php +++ b/bridges/TwitchApiBridge.php @@ -13,7 +13,7 @@ class TwitchApiBridge extends BridgeAbstract{ $this->name = "Twitch API Bridge"; $this->uri = "http://www.twitch.tv"; $this->description = "Returns the newest broadcasts or highlights by channel name using the Twitch API (v3)"; - $this->update = "2015-07-14"; + $this->update = "2016-01-09"; $this->parameters["Get channel without limit"] = '[ @@ -31,7 +31,7 @@ class TwitchApiBridge extends BridgeAbstract{ "value" : "true" }, { - "name" : "Don\'t show broadcasts", + "name" : "Show highlights", "value" : "false" } ] @@ -58,7 +58,7 @@ class TwitchApiBridge extends BridgeAbstract{ "value" : "true" }, { - "name" : "Don\'t show broadcasts", + "name" : "Show highlights", "value" : "false" } ] From 6deebb56a5a3cd20fe4dde1f2439318560e48816 Mon Sep 17 00:00:00 2001 From: Albirew Date: Fri, 15 Jan 2016 18:20:30 +0100 Subject: [PATCH 03/13] changed TLD .ms -> .se On continue le jeu du chat et de la souris =) --- bridges/ThePirateBayBridge.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridges/ThePirateBayBridge.php b/bridges/ThePirateBayBridge.php index 020f4e8..3e55c60 100644 --- a/bridges/ThePirateBayBridge.php +++ b/bridges/ThePirateBayBridge.php @@ -5,7 +5,7 @@ class ThePirateBayBridge extends BridgeAbstract{ $this->maintainer = "mitsukarenai"; $this->name = "The Pirate Bay"; - $this->uri = "https://thepiratebay.ms/"; + $this->uri = "https://thepiratebay.se/"; $this->description = "Returns results for the keywords. You can put several list of keywords by separating them with a semicolon (e.g. \"one show;another show\")"; $this->update = "2015-01-09"; @@ -60,7 +60,7 @@ class ThePirateBayBridge extends BridgeAbstract{ $keywordsList = explode(";",$param['q']); foreach($keywordsList as $keywords){ - $html = file_get_html('https://thepiratebay.ms/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnError('Could not request TPB.', 404); + $html = file_get_html('https://thepiratebay.se/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnError('Could not request TPB.', 404); if ($html->find('table#searchResult', 0) == FALSE) $this->returnError('No result for query '.$keywords, 404); @@ -68,7 +68,7 @@ class ThePirateBayBridge extends BridgeAbstract{ foreach($html->find('tr') as $element) { $item = new \Item(); - $item->uri = 'https://thepiratebay.ms/'.$element->find('a.detLink',0)->href; + $item->uri = 'https://thepiratebay.se/'.$element->find('a.detLink',0)->href; $item->id = $item->uri; $item->timestamp = parseDateTimestamp($element); $item->title = $element->find('a.detLink',0)->plaintext; @@ -86,7 +86,7 @@ class ThePirateBayBridge extends BridgeAbstract{ } public function getURI(){ - return 'https://thepiratebay.ms/'; + return 'https://thepiratebay.se/'; } public function getCacheDuration(){ From 379c89045b81443b0c69501e23bc480aacbb88e6 Mon Sep 17 00:00:00 2001 From: Teromene Date: Tue, 19 Jan 2016 12:15:16 +0000 Subject: [PATCH 04/13] Quoted the "r" and "k" in the parameters --- bridges/LeBonCoinBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index 19016cc..72d2109 100755 --- a/bridges/LeBonCoinBridge.php +++ b/bridges/LeBonCoinBridge.php @@ -134,7 +134,7 @@ class LeBonCoinBridge extends BridgeAbstract{ public function collectData(array $param){ $html = ''; - $link = 'http://www.leboncoin.fr/annonces/offres/' . $param[r] . '/?f=a&th=1&q=' . $param[k]; + $link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r'] . '/?f=a&th=1&q=' . $param['k']; $html = file_get_html($link) or $this->returnError('Could not request LeBonCoin.', 404); $list = $html->find('.list-lbc', 0); From 5f01b7fe7dbc4cf2f05365e8f00e27e2817f1725 Mon Sep 17 00:00:00 2001 From: Teromene Date: Tue, 19 Jan 2016 12:17:27 +0000 Subject: [PATCH 05/13] Added a function to re-encode everything to UTF-8 --- lib/Cache.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/Cache.php b/lib/Cache.php index fa80bc0..a165148 100644 --- a/lib/Cache.php +++ b/lib/Cache.php @@ -70,6 +70,26 @@ class Cache{ return preg_match('@^[A-Z][a-zA-Z0-9-]*$@', $nameCache); } + + static public function utf8_encode_deep(&$input) { + if (is_string($input)) { + $input = utf8_encode($input); + } else if (is_array($input)) { + foreach ($input as &$value) { + Cache::utf8_encode_deep($value); + } + + unset($value); + } else if (is_object($input)) { + $vars = array_keys(get_object_vars($input)); + + foreach ($vars as $var) { + Cache::utf8_encode_deep($input->$var); + } + } + } + + static public function purge() { $cacheTimeLimit = time() - 60*60*24 ; $cachePath = 'cache'; From 259e5ef9defeb8bb00270172a441890997573398 Mon Sep 17 00:00:00 2001 From: Teromene Date: Tue, 19 Jan 2016 12:18:54 +0000 Subject: [PATCH 06/13] Casting to UTF-8 before converting to JSON. --- caches/FileCache.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/caches/FileCache.php b/caches/FileCache.php index f2e0dbb..f2a3ea8 100644 --- a/caches/FileCache.php +++ b/caches/FileCache.php @@ -24,6 +24,9 @@ class FileCache extends CacheAbstract{ public function saveData($datas){ $this->isPrepareCache(); + //Re-encode datas to UTF-8 + $datas = Cache::utf8_encode_deep($datas); + $writeStream = file_put_contents($this->getCacheFile(), json_encode($datas)); if(!$writeStream) { From e7595391cd689a69881b67c0916f32ba01b19e2d Mon Sep 17 00:00:00 2001 From: Teromene Date: Tue, 19 Jan 2016 12:34:21 +0000 Subject: [PATCH 07/13] Ignore emacs save files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2359a6d..4c658bf 100644 --- a/.gitignore +++ b/.gitignore @@ -170,6 +170,7 @@ App_Data/*.ldf ## Other ide stuff ################# .idea/* +[#]*[#] ############# ## Windows detritus From 4deefdfd7d52843e7cf80d0134c1172ececa25a0 Mon Sep 17 00:00:00 2001 From: Teromene Date: Tue, 19 Jan 2016 12:34:38 +0000 Subject: [PATCH 08/13] Add enclosures support, see example in DemoBridge. --- bridges/DemoBridge.php | 12 +++++++++++- formats/AtomFormat.php | 10 ++++++++++ lib/Item.php | 12 ++++++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index 24cd389..b1d8515 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -53,6 +53,16 @@ class DemoBridge extends BridgeAbstract{ public function collectData(array $param){ + $item = new \Item(); + $item->name = "TestElement"; + $item->title = "Test"; + $item->content = "Awesome content !"; + $item->id = "Lalala"; + $item->uri = "http://test.test/test"; + $item->enclosures[] = "http://www.ardmediathek.de/ard/servlet/image/00/32/68/18/38/1135274624/16x9/960"; + + $this->items[] = $item; + } public function getName() { @@ -68,6 +78,6 @@ class DemoBridge extends BridgeAbstract{ } public function getCacheDuration(){ - return 3600; // 1 hour + return 00; // 1 hour } } diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index f3797e2..536c16a 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -36,6 +36,15 @@ class AtomFormat extends FormatAbstract{ // We prevent content from closing the CDATA too early. $entryContent = is_null($data->content) ? '' : 'sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>'; + // We generate a list of the enclosure links + $entryEnclosure = ""; + + foreach($data->enclosures as $enclosure) { + + $entryEnclosures .= ""; + + } + $entries .= << @@ -48,6 +57,7 @@ class AtomFormat extends FormatAbstract{ {$entryUri} {$entryTimestamp} {$entryContent} + {$entryEnclosures} EOD; diff --git a/lib/Item.php b/lib/Item.php index 2e15ffc..699ec3d 100644 --- a/lib/Item.php +++ b/lib/Item.php @@ -2,15 +2,19 @@ interface ItemInterface{} /** -* Object to store datas collect informations -* FIXME : not sur this logic is the good, I think recast all is necessary -*/ + * Object to store datas collect informations + * FIXME : not sur this logic is the good, I think recast all is necessary + */ class Item implements ItemInterface{ + + // FIXME : use the arrayInterface instead + public $enclosures = array(); + public function __set($name, $value){ $this->$name = $value; } public function __get($name){ - return isset($this->$name) ? $this->$name : null; + return (isset($this->$name) ? $this->$name : null); } } From 195ba94115244345ec5363ab5b991967d22a7844 Mon Sep 17 00:00:00 2001 From: Ginko-Aloe Date: Tue, 19 Jan 2016 19:20:21 +0100 Subject: [PATCH 09/13] Create JapanExpoBridge.php --- bridges/JapanExpoBridge.php | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 bridges/JapanExpoBridge.php diff --git a/bridges/JapanExpoBridge.php b/bridges/JapanExpoBridge.php new file mode 100644 index 0000000..c9ebbba --- /dev/null +++ b/bridges/JapanExpoBridge.php @@ -0,0 +1,42 @@ +maintainer = "Ginko"; + $this->name = "JapanExpo"; + $this->uri = "http://www.japan-expo-paris.com/fr/actualites"; + $this->description = "Returns most recent results from Japan Expo actualités."; + $this->update = "2016-01-19"; + + } + + public function collectData(array $param){ + $link = 'http://www.japan-expo-paris.com/fr/actualites'; + + $html = file_get_html($link) or $this->returnError('Could not request JapanExpo. for : ' . $link , 404); + + foreach($html->find('a._tile2') as $element) { + $item = new Item(); + $item->uri = $element->href; + $item->title = $element->find('span._title', 0)->plaintext; + $style = $element->find('img.rspvimgset', 0)->style; + preg_match('/url\(([^)]+)\)/', $style, $match); + $item->content = "
".$element->find('span.date', 0)->plaintext; + $this->items[] = $item; + } + + } + + public function getName(){ + return 'Japan Expo Actualités'; + } + + public function getURI(){ + return 'http://www.japan-expo-paris.com/fr/actualites'; + } + + public function getCacheDuration(){ + return 86400; // 1 day + } +} From 8db5dde69d707026c73a059acde8aea65b56fbeb Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Tue, 19 Jan 2016 21:57:24 +0100 Subject: [PATCH 10/13] Add new parameter 'title' to guide the user The 'title' attribute will render as tooltip in the browser which is useful to provide guidance to the operator. --- lib/HTMLUtils.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/HTMLUtils.php b/lib/HTMLUtils.php index 3838c35..dce8b8f 100644 --- a/lib/HTMLUtils.php +++ b/lib/HTMLUtils.php @@ -80,6 +80,11 @@ CARD; $additionalInfoString .= " pattern=\"".$inputEntry['pattern']."\""; } + if(isset($inputEntry['title'])) { + + $additionalInfoString .= " title=\"" .$inputEntry['title']."\""; + + } if(!isset($inputEntry['exampleValue'])) $inputEntry['exampleValue'] = ""; $idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . urlencode($inputEntry['identifier']); From 58e828e69ad342dca4f0a61e1ea515ec8ac9ca0b Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Tue, 19 Jan 2016 22:00:18 +0100 Subject: [PATCH 11/13] Add optional parameter 'title' to the readme --- CREATE_BRIDGE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CREATE_BRIDGE.md b/CREATE_BRIDGE.md index 6324221..7041ec9 100644 --- a/CREATE_BRIDGE.md +++ b/CREATE_BRIDGE.md @@ -90,6 +90,7 @@ Parameter Name | Parameter values | Description type|text, number, list, checkbox| Type of the input, default is text required| true | Set this if you want your attribute to be required values| [ {"name" : option1Name, "value" : "option1Value"}, ...] | Values list, required with the 'list' type +title| text | Will be shown as tooltip when mouse-hovering over the input #### Guidelines From f22b4b33df7369c13c796d7b940cdac3adcb35fb Mon Sep 17 00:00:00 2001 From: Paul de Rosanbo Date: Thu, 21 Jan 2016 14:05:14 +0100 Subject: [PATCH 12/13] Fix notice about undefined variable --- formats/AtomFormat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index 536c16a..74e78db 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -37,7 +37,7 @@ class AtomFormat extends FormatAbstract{ $entryContent = is_null($data->content) ? '' : 'sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>'; // We generate a list of the enclosure links - $entryEnclosure = ""; + $entryEnclosures = ""; foreach($data->enclosures as $enclosure) { From e59bf64c42ea199c73fad35f24f2e189c22ee5f8 Mon Sep 17 00:00:00 2001 From: Paul de Rosanbo Date: Thu, 21 Jan 2016 14:06:48 +0100 Subject: [PATCH 13/13] Fix cache bug, the content of the cache was encoded in utf8 before converting to json and saved, resulting in double-encoded caracters in output --- caches/FileCache.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/caches/FileCache.php b/caches/FileCache.php index f2a3ea8..c348fdf 100644 --- a/caches/FileCache.php +++ b/caches/FileCache.php @@ -8,7 +8,7 @@ class FileCache extends CacheAbstract{ public function loadData(){ $this->isPrepareCache(); - $datas = json_decode(file_get_contents($this->getCacheFile()),true); + $datas = unserialize(file_get_contents($this->getCacheFile())); $items = array(); foreach($datas as $aData){ $item = new \Item(); @@ -25,9 +25,9 @@ class FileCache extends CacheAbstract{ $this->isPrepareCache(); //Re-encode datas to UTF-8 - $datas = Cache::utf8_encode_deep($datas); + //$datas = Cache::utf8_encode_deep($datas); - $writeStream = file_put_contents($this->getCacheFile(), json_encode($datas)); + $writeStream = file_put_contents($this->getCacheFile(), serialize($datas)); if(!$writeStream) {