From 5353697e67e56dd0d8b45bcd2acb21393b43faff Mon Sep 17 00:00:00 2001 From: ORelio Date: Sun, 17 Jul 2016 14:39:14 +0200 Subject: [PATCH 1/2] [T411] Cleanup advertisments --- bridges/T411Bridge.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/bridges/T411Bridge.php b/bridges/T411Bridge.php index 47815beb..9d9ff245 100644 --- a/bridges/T411Bridge.php +++ b/bridges/T411Bridge.php @@ -3,11 +3,11 @@ class T411Bridge extends BridgeAbstract { public function loadMetadatas() { - $this->maintainer = "ORelio"; - $this->name = "T411"; + $this->maintainer = 'ORelio'; + $this->name = 'T411'; $this->uri = $this->getURI(); - $this->description = "Returns the 5 newest torrents with specified search terms
Use url part after '?' mark when using their search engine"; - $this->update = "2016-02-06"; + $this->description = 'Returns the 10 newest torrents with specified search terms
Use url part after "?" mark when using their search engine.'; + $this->update = '2016-06-25'; $this->parameters[] = '[ @@ -43,10 +43,10 @@ class T411Bridge extends BridgeAbstract { $limit = 0; //Process each item individually - foreach($results->find('tr') as $element) { + foreach ($results->find('tr') as $element) { - //Limit total amount of requests - if ($limit < 10) { + //Limit total amount of requests and ignore table header + if ($limit < 10 && !is_object($element->find('th', 0))) { //Requests are rate-limited usleep(500000); //So we need to wait (500ms) @@ -66,12 +66,20 @@ class T411Bridge extends BridgeAbstract { //Retrieve image for thumbnail or generic logo fallback $item_image = $this->getURI().'themes/blue/images/logo.png'; foreach ($item_desc->find('img') as $img) { - if (strpos($img->src, 'prez') === false) { + if (strpos($img->src, 'prez') === false && strpos($img->src, '/ad/') === false) { $item_image = $img->src; break; } } + //Cleanup advertisments + $divs = explode('
', $item_desc->innertext); + $item_desc = ''; + foreach ($divs as $text) + if (strpos($text, 'adprovider.adlure.net') === false) + $item_desc = $item_desc.'
'.$text; + $item_desc = preg_replace('/

LIENS DE T..?L..?CHARGEMENT<\/h2>/i', '', $item_desc); + //Build and add final item $item = new \Item(); $item->uri = $item_uri; @@ -79,7 +87,7 @@ class T411Bridge extends BridgeAbstract { $item->author = $item_author; $item->timestamp = $item_date; $item->thumbnailUri = $item_image; - $item->content = $item_desc->innertext; + $item->content = $item_desc; $this->items[] = $item; $limit++; } From 6abca16f06334784a87b5fd20a1239dd87780289 Mon Sep 17 00:00:00 2001 From: ORelio Date: Sun, 17 Jul 2016 14:40:03 +0200 Subject: [PATCH 2/2] [EstCeQuonMetEnProd] Add EstCeQuonMetEnProd Bridge Should we put a website in production today? --- bridges/EstCeQuonMetEnProdBridge.php | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 bridges/EstCeQuonMetEnProdBridge.php diff --git a/bridges/EstCeQuonMetEnProdBridge.php b/bridges/EstCeQuonMetEnProdBridge.php new file mode 100644 index 00000000..7d3e6523 --- /dev/null +++ b/bridges/EstCeQuonMetEnProdBridge.php @@ -0,0 +1,56 @@ +maintainer = 'ORelio'; + $this->name = $this->getName(); + $this->uri = $this->getURI(); + $this->description = $this->getDescription(); + $this->update = "02/07/2016"; + } + + public function collectData(array $param) { + function ExtractFromDelimiters($string, $start, $end) { + if (strpos($string, $start) !== false) { + $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); + $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); + return $section_retrieved; + } return false; + } + + $html = $this->file_get_html($this->getURI()) or $this->returnError('Could not request EstCeQuonMetEnProd: '.$this->getURI(), 500); + + $img = $html->find('img', 0); + if (is_object($img)) { + $img = $img->src; + if ($img[0] == '/') + $img = substr($this->getURI(), 0, strlen($this->getURI()) - 1).$img; + } + + $item = new \Item(); + $item->uri = $this->getURI().'#'.date('Y-m-d'); + $item->thumbnailUri = $img; + $item->title = $this->getName(); + $item->author = 'Nicolas Hoffmann'; + $item->timestamp = strtotime('today midnight'); + $item->content = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '', '

'))); + $this->items[] = $item; + } + + public function getName() { + return 'Est-ce qu\'on met en prod aujourd\'hui ?'; + } + + public function getURI() { + return 'https://www.estcequonmetenprodaujourdhui.info/'; + } + + public function getDescription() { + return 'Should we put a website in production today? (French)'; + } + + public function getCacheDuration() { + return 21600; // 6 hours + } +} +?> \ No newline at end of file