diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php index 6031d316..51a767a0 100644 --- a/bridges/ABCTabsBridge.php +++ b/bridges/ABCTabsBridge.php @@ -1,16 +1,10 @@ maintainer = "kranack"; - $this->name = "ABC Tabs Bridge"; - $this->uri = "http://www.abc-tabs.com/"; - $this->description = "Returns 22 newest tabs"; - - } + public $maintainer = "kranack"; + public $name = "ABC Tabs Bridge"; + public $uri = "http://www.abc-tabs.com/"; + public $description = "Returns 22 newest tabs"; public function collectData(){ $html = ''; diff --git a/bridges/AcrimedBridge.php b/bridges/AcrimedBridge.php index 8ddbc853..a0bf4551 100644 --- a/bridges/AcrimedBridge.php +++ b/bridges/AcrimedBridge.php @@ -1,18 +1,15 @@ maintainer = "qwertygc"; - $this->name = "Acrimed Bridge"; - $this->uri = "http://www.acrimed.org/"; - $this->description = "Returns the newest articles."; - - } + public $maintainer = "qwertygc"; + public $name = "Acrimed Bridge"; + public $uri = "http://www.acrimed.org/"; + public $description = "Returns the newest articles."; public function collectData(){ - parent::collectExpandableDatas("http://www.acrimed.org/spip.php?page=backend"); + $this->collectExpandableDatas("http://www.acrimed.org/spip.php?page=backend"); } diff --git a/bridges/AllocineFRBridge.php b/bridges/AllocineFRBridge.php index c9c0f0f8..f180f5d1 100644 --- a/bridges/AllocineFRBridge.php +++ b/bridges/AllocineFRBridge.php @@ -1,58 +1,60 @@ maintainer = "superbaillot.net"; - $this->name = "Allo Cine Bridge"; - $this->uri = "http://www.allocine.fr"; - $this->description = "Bridge for allocine.fr"; - - $this->parameters[] = array( - 'category'=>array( + public $maintainer = "superbaillot.net"; + public $name = "Allo Cine Bridge"; + public $uri = "http://www.allocine.fr"; + public $description = "Bridge for allocine.fr"; + public $parameters = array( array( + 'category'=>array( 'name'=>'category', 'type'=>'list', 'required'=>true, 'exampleValue'=>'Faux Raccord', 'title'=>'Select your category', 'values'=>array( - 'Faux Raccord'=>'faux-raccord', - 'Top 5'=>'top-5', - 'Tueurs En Serie'=>'tuers-en-serie' + 'Faux Raccord'=>'faux-raccord', + 'Top 5'=>'top-5', + 'Tueurs en Séries'=>'tueurs-en-serie' ) - ) - ); + ) + )); + + public function getURI(){ + switch($this->getInput('category')){ + case 'faux-raccord': + $uri = 'http://www.allocine.fr/video/programme-12284/saison-24580/'; + break; + case 'top-5': + $uri = 'http://www.allocine.fr/video/programme-12299/saison-22542/'; + break; + case 'tueurs-en-serie': + $uri = 'http://www.allocine.fr/video/programme-12286/saison-22938/'; + break; + } + + return $uri; + } + + public function getName(){ + return $this->name.' : ' + .array_search( + $this->getInput('category'), + $this->parameters[$this->queriedContext]['category']['values'] + ); } public function collectData(){ - $params=$this->parameters[$this->queriedContext]; - // Check all parameters - if(!isset($params['category']['value'])) - $this->returnClientError('You must specify a valid category (&category= )!'); + $html = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError("Could not request ".$this->getURI()." !"); - $category = ''; - switch($params['category']['value']){ - case 'faux-raccord': - $this->uri = 'http://www.allocine.fr/video/programme-12284/saison-24580/'; - $category = 'Faux Raccord'; - break; - case 'top-5': - $this->uri = 'http://www.allocine.fr/video/programme-12299/saison-22542/'; - $category = 'Top 5'; - break; - case 'tuers-en-serie': - $this->uri = 'http://www.allocine.fr/video/programme-12286/saison-22938/'; - $category = 'Tueurs en Séries'; - break; - default: - $this->returnClientError('You must select a valid category!'); - } + $category=array_search( + $this->getInput('category'), + $this->parameters[$this->queriedContext]['category']['values'] + ); - // Update bridge name to match selection - $this->name .= ' : ' . $category; - - $html = $this->getSimpleHTMLDOM($this->uri) or $this->returnServerError("Could not request {$this->uri}!"); foreach($html->find('figure.media-meta-fig') as $element) { diff --git a/bridges/AnimeUltimeBridge.php b/bridges/AnimeUltimeBridge.php index 3f0370c7..629f459b 100644 --- a/bridges/AnimeUltimeBridge.php +++ b/bridges/AnimeUltimeBridge.php @@ -1,16 +1,11 @@ maintainer = 'ORelio'; - $this->name = 'Anime-Ultime'; - $this->uri = 'http://www.anime-ultime.net/'; - $this->description = 'Returns the 10 newest releases posted on Anime-Ultime'; - - $this->parameters[] = array( + public $maintainer = 'ORelio'; + public $name = 'Anime-Ultime'; + public $uri = 'http://www.anime-ultime.net/'; + public $description = 'Returns the 10 newest releases posted on Anime-Ultime'; + public $parameters = array( array( 'type'=>array( 'name'=>'Type', 'type'=>'list', @@ -21,22 +16,17 @@ class AnimeUltimeBridge extends BridgeAbstract { 'Tokusatsu'=>'T' ) ) - ); - } + )); + + private $filter = 'Releases'; public function collectData(){ - $param=$this->parameters[$this->queriedContext]; //Add type filter if provided - $typeFilter = ''; - if (!empty($param['type']['value'])) { - if ($param['type']['value'] == 'A' || $param['type']['value'] == 'D' || $param['type']['value'] == 'T') { - $typeFilter = $param['type']['value']; - if ($typeFilter == 'A') { $this->filter = 'Anime'; } - if ($typeFilter == 'D') { $this->filter = 'Drama'; } - if ($typeFilter == 'T') { $this->filter = 'Tokusatsu'; } - } else $this->returnClientError('The provided type filter is invalid. Expecting A, D, T, or no filter'); - } + $typeFilter = array_search( + $this->getInput('type'), + $this->parameters[$this->queriedContext]['type']['values'] + ); //Build date and filters for making requests $thismonth = date('mY').$typeFilter; @@ -47,9 +37,9 @@ class AnimeUltimeBridge extends BridgeAbstract { foreach (array($thismonth, $lastmonth) as $requestFilter) { //Retrive page contents - $website = 'http://www.anime-ultime.net/'; - $url = $website.'history-0-1/'.$requestFilter; - $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Anime-Ultime: '.$url); + $url = $this->uri.'history-0-1/'.$requestFilter; + $html = $this->getSimpleHTMLDOM($url) + or $this->returnServerError('Could not request Anime-Ultime: '.$url); //Relases are sorted by day : process each day individually foreach ($html->find('div.history', 0)->find('h3') as $daySection) { @@ -57,7 +47,9 @@ class AnimeUltimeBridge extends BridgeAbstract { //Retrieve day and build date information $dateString = $daySection->plaintext; $day = intval(substr($dateString, strpos($dateString, ' ') + 1, 2)); - $item_date = strtotime(str_pad($day, 2, '0', STR_PAD_LEFT).'-'.substr($requestFilter, 0, 2).'-'.substr($requestFilter, 2, 4)); + $item_date = strtotime(str_pad($day, 2, '0', STR_PAD_LEFT).'-' + .substr($requestFilter, 0, 2).'-' + .substr($requestFilter, 2, 4)); $release = $daySection->next_sibling()->next_sibling()->first_child(); //

day


<-- useful data in table rows //Process each release of that day, ignoring first table row: contains table headers @@ -66,7 +58,7 @@ class AnimeUltimeBridge extends BridgeAbstract { //Retrieve metadata from table columns $item_link_element = $release->find('td', 0)->find('a', 0); - $item_uri = $website.$item_link_element->href; + $item_uri = $this->uri.$item_link_element->href; $item_name = html_entity_decode($item_link_element->plaintext); $item_episode = html_entity_decode(str_pad($release->find('td', 1)->plaintext, 2, '0', STR_PAD_LEFT)); $item_fansub = $release->find('td', 2)->plaintext; @@ -75,10 +67,21 @@ class AnimeUltimeBridge extends BridgeAbstract { if (!empty($item_uri)) { //Retrieve description from description page and convert relative image src info absolute image src - $html_item = $this->getContents($item_uri) or $this->returnServerError('Could not request Anime-Ultime: '.$item_uri); - $item_description = substr($html_item, strpos($html_item, 'class="principal_contain" align="center">') + 41); - $item_description = substr($item_description, 0, strpos($item_description, '
')); - $item_description = str_replace('src="images', 'src="'.$website.'images', $item_description); + $html_item = $this->getContents($item_uri) + or $this->returnServerError('Could not request Anime-Ultime: '.$item_uri); + $item_description = substr( + $html_item, + strpos($html_item, 'class="principal_contain" align="center">') + + 41 + ); + $item_description = substr($item_description, + 0, + strpos($item_description, '
') + ); + $item_description = str_replace( + 'src="images', 'src="'.$this->uri.'images', + $item_description + ); $item_description = str_replace("\r", '', $item_description); $item_description = str_replace("\n", '', $item_description); $item_description = utf8_encode($item_description); @@ -104,7 +107,12 @@ class AnimeUltimeBridge extends BridgeAbstract { } public function getName() { - return 'Latest '.$this->filter.' - Anime-Ultime Bridge'; + $typeFilter = array_search( + $this->getInput('type'), + $this->parameters[$this->queriedContext]['type']['values'] + ); + + return 'Latest '.$typeFilter.' - Anime-Ultime Bridge'; } public function getCacheDuration() { diff --git a/bridges/ArstechnicaBridge.php b/bridges/ArstechnicaBridge.php index 6c5521f4..d2a62b2b 100644 --- a/bridges/ArstechnicaBridge.php +++ b/bridges/ArstechnicaBridge.php @@ -3,14 +3,10 @@ #error_reporting(E_ALL); class ArstechnicaBridge extends BridgeAbstract { - public function loadMetadatas() { - - $this->maintainer = "prysme"; - $this->name = "ArstechnicaBridge"; - $this->uri = "http://arstechnica.com"; - $this->description = "The PC enthusiast's resource. Power users and the tools they love, without computing religion"; - - } + public $maintainer = "prysme"; + public $name = "ArstechnicaBridge"; + public $uri = "http://arstechnica.com"; + public $description = "The PC enthusiast's resource. Power users and the tools they love, without computing religion"; function StripWithDelimiters($string, $start, $end) { while (strpos($string, $start) !== false) { diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index bc8725bd..19e039f8 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -1,75 +1,73 @@ -maintainer = "mitsukarenai"; - $this->name = "Arte +7"; - $this->uri = "http://www.arte.tv/"; - $this->description = "Returns newest videos from ARTE +7"; - $this->parameters["Catégorie (Français)"] = array( - 'catfr'=>array( - 'type'=>'list', - 'name'=>'Catégorie', - 'values'=>array( - 'Toutes les vidéos (français)'=>'toutes-les-videos', - 'Actu & société'=>'actu-société', - 'Séries & fiction'=>'séries-fiction', - 'Cinéma'=>'cinéma', - 'Arts & spectacles classiques'=>'arts-spectacles-classiques', - 'Culture pop'=>'culture-pop', - 'Découverte'=>'découverte', - 'Histoire'=>'histoire', - 'Junior'=>'junior' + public $maintainer = "mitsukarenai"; + public $name = "Arte +7"; + public $uri = "http://www.arte.tv/"; + public $description = "Returns newest videos from ARTE +7"; + public $parameters = array( + 'Catégorie (Français)' => array( + 'catfr'=>array( + 'type'=>'list', + 'name'=>'Catégorie', + 'values'=>array( + 'Toutes les vidéos (français)'=>'toutes-les-videos', + 'Actu & société'=>'actu-société', + 'Séries & fiction'=>'séries-fiction', + 'Cinéma'=>'cinéma', + 'Arts & spectacles classiques'=>'arts-spectacles-classiques', + 'Culture pop'=>'culture-pop', + 'Découverte'=>'découverte', + 'Histoire'=>'histoire', + 'Junior'=>'junior' + ) + ) + ), + 'Catégorie (Allemand)' => array( + 'catde'=>array( + 'type'=>'list', + 'name'=>'Catégorie', + 'values'=>array( + 'Alle Videos (deutsch)'=>'alle-videos', + 'Aktuelles & Gesellschaft'=>'aktuelles-gesellschaft', + 'Fernsehfilme & Serien'=>'fernsehfilme-serien', + 'Kino'=>'kino', + 'Kunst & Kultur'=>'kunst-kultur', + 'Popkultur & Alternativ'=>'popkultur-alternativ', + 'Entdeckung'=>'entdeckung', + 'Geschichte'=>'geschichte', + 'Junior'=>'junior' + ) + ) ) - ) ); - $this->parameters["Catégorie (Allemand)"] = array( - 'catde'=>array( - 'type'=>'list', - 'name'=>'Catégorie', - 'values'=>array( - 'Alle Videos (deutsch)'=>'alle-videos', - 'Aktuelles & Gesellschaft'=>'aktuelles-gesellschaft', - 'Fernsehfilme & Serien'=>'fernsehfilme-serien', - 'Kino'=>'kino', - 'Kunst & Kultur'=>'kunst-kultur', - 'Popkultur & Alternativ'=>'popkultur-alternativ', - 'Entdeckung'=>'entdeckung', - 'Geschichte'=>'geschichte', - 'Junior'=>'junior' - ) - ) - ); - } - - protected function extractVideoset($category='toutes-les-videos', $lang='fr'){ - $url = 'http://www.arte.tv/guide/'.$lang.'/plus7/'.$category; - $input = $this->getContents($url) or die('Could not request ARTE.'); - if(strpos($input, 'categoryVideoSet') !== FALSE){ - $input = explode('categoryVideoSet: ', $input); - $input = explode('}},', $input[1]); - $input = $input[0].'}}'; - }else{ - $input = explode('videoSet: ', $input); - $input = explode('}]},', $input[1]); - $input = $input[0].'}]}'; - } - $input = json_decode($input, TRUE); - return $input; - } - public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $category='toutes-les-videos'; $lang='fr'; - if (!empty($param['catfr']['value'])) - $category=$param['catfr']['value']; - if (!empty($param['catde']['value'])) - { $category=$param['catde']['value']; $lang='de'; } - $input_json = $this->extractVideoset($category, $lang); + switch($this->queriedContext){ + case 'Catégorie (Français)': + $category=$this->getInput('catfr'); + $lang='fr'; + break; + case 'Catégorie (Allemand)': + $category=$this->getInput('catde'); + $lang='de'; + break; + } + + $url = $this->uri.'guide/'.$lang.'/plus7/'.$category; + $input = $this->getContents($url) or die('Could not request ARTE.'); + if(strpos($input, 'categoryVideoSet') !== FALSE){ + $input = explode('categoryVideoSet: ', $input); + $input = explode('}},', $input[1]); + $input = $input[0].'}}'; + }else{ + $input = explode('videoSet: ', $input); + $input = explode('}]},', $input[1]); + $input = $input[0].'}]}'; + } + $input_json = json_decode($input, TRUE); foreach($input_json['videos'] as $element) { $item = array(); diff --git a/bridges/AskfmBridge.php b/bridges/AskfmBridge.php index 0ff36556..7a8b9e21 100644 --- a/bridges/AskfmBridge.php +++ b/bridges/AskfmBridge.php @@ -1,35 +1,26 @@ maintainer = "az5he6ch"; - $this->name = "Ask.fm Answers"; - $this->uri = "http://ask.fm/"; - $this->description = "Returns answers from an Ask.fm user"; - - $this->parameters["Ask.fm username"] = array( - 'u'=>array( - 'name'=>'Username', - 'required'=>true - ) - ); - } + public $maintainer = "az5he6ch"; + public $name = "Ask.fm Answers"; + public $uri = "http://ask.fm/"; + public $description = "Returns answers from an Ask.fm user"; + public $parameters = array( + 'Ask.fm username'=>array( + 'u'=>array( + 'name'=>'Username', + 'required'=>true + ) + ) + ); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $html = ''; - if (isset($param['u']['value'])) { - $this->request = $param['u']['value']; - $html = $this->getSimpleHTMLDOM('http://ask.fm/'.urlencode($this->request).'/answers/more?page=0') or $this->returnServerError('Requested username can\'t be found.'); - } - else { - $this->returnClientError('You must specify a username (?u=...).'); - } + $html = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError('Requested username can\'t be found.'); foreach($html->find('div.streamItem-answer') as $element) { $item = array(); - $item['uri'] = 'http://ask.fm'.$element->find('a.streamItemsAge',0)->href; + $item['uri'] = $this->uri.$element->find('a.streamItemsAge',0)->href; $question = trim($element->find('h1.streamItemContent-question',0)->innertext); $item['title'] = trim(htmlspecialchars_decode($element->find('h1.streamItemContent-question',0)->plaintext, ENT_QUOTES)); $answer = trim($element->find('p.streamItemContent-answer',0)->innertext); @@ -44,18 +35,18 @@ class AskfmBridge extends BridgeAbstract{ } $content = '

' . $question . '

' . $answer . '

' . $visual . '

'; // Fix relative links without breaking // scheme used by YouTube stuff - $content = preg_replace('#href="\/(?!\/)#', 'href="http://ask.fm/',$content); + $content = preg_replace('#href="\/(?!\/)#', 'href="'.$this->uri,$content); $item['content'] = $content; $this->items[] = $item; } } public function getName(){ - return empty($this->request) ? $this->name : $this->request; + return $this->name.' : '.$this->getInput('u'); } public function getURI(){ - return empty($this->request) ? $this->uri : 'http://ask.fm/'.urlencode($this->request); + return $this->uri.urlencode($this->getInput('u')).'/answers/more?page=0'; } public function getCacheDuration(){ diff --git a/bridges/BandcampBridge.php b/bridges/BandcampBridge.php index b9dbaa27..4e110915 100644 --- a/bridges/BandcampBridge.php +++ b/bridges/BandcampBridge.php @@ -1,33 +1,21 @@ maintainer = "sebsauvage"; - $this->name = "Bandcamp Tag"; - $this->uri = "http://bandcamp.com/"; - $this->description = "New bandcamp release by tag"; - - $this->parameters[] = array( - 'tag'=>array( + public $maintainer = "sebsauvage"; + public $name = "Bandcamp Tag"; + public $uri = "http://bandcamp.com/"; + public $description = "New bandcamp release by tag"; + public $parameters = array( array( + 'tag'=>array( 'name'=>'tag', - 'type'=>'text' - ) - ); - } + 'type'=>'text', + 'required'=>true + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $html = ''; - if (isset($param['tag']['value'])) { - $this->request = $param['tag']['value']; - $html = $this->getSimpleHTMLDOM('http://bandcamp.com/tag/'.urlencode($this->request).'?sort_field=date') or $this->returnServerError('No results for this query.'); - } - else { - $this->returnClientError('You must specify tag (/tag/...)'); - } + $html = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError('No results for this query.'); foreach($html->find('li.item') as $release) { $script = $release->find('div.art', 0)->getAttribute('onclick'); @@ -44,8 +32,12 @@ class BandcampBridge extends BridgeAbstract{ } } + public function getURI(){ + return $this->uri.'tag/'.urlencode($this->getInput('tag')).'?sort_field=date'; + } + public function getName(){ - return (!empty($this->request) ? $this->request .' - ' : '') .'Bandcamp Tag'; + return $this->getInput('tag') .' - '.'Bandcamp Tag'; } public function getCacheDuration(){ diff --git a/bridges/BastaBridge.php b/bridges/BastaBridge.php index ec46b5f9..a7a7c829 100644 --- a/bridges/BastaBridge.php +++ b/bridges/BastaBridge.php @@ -1,19 +1,18 @@ maintainer = "qwertygc"; - $this->name = "Bastamag Bridge"; - $this->uri = "http://www.bastamag.net/"; - $this->description = "Returns the newest articles."; - } + public $maintainer = "qwertygc"; + public $name = "Bastamag Bridge"; + public $uri = "http://www.bastamag.net/"; + public $description = "Returns the newest articles."; public function collectData(){ // Replaces all relative image URLs by absolute URLs. Relative URLs always start with 'local/'! function ReplaceImageUrl($content){ - return preg_replace('/src=["\']{1}([^"\']+)/ims', 'src=\'http://www.bastamag.net/$1\'', $content); + return preg_replace('/src=["\']{1}([^"\']+)/ims', 'src=\''.$this->uri.'$1\'', $content); } - $html = $this->getSimpleHTMLDOM('http://www.bastamag.net/spip.php?page=backend') or $this->returnServerError('Could not request Bastamag.'); + $html = $this->getSimpleHTMLDOM($this->uri.'spip.php?page=backend') + or $this->returnServerError('Could not request Bastamag.'); $limit = 0; foreach($html->find('item') as $element) { diff --git a/bridges/BlaguesDeMerdeBridge.php b/bridges/BlaguesDeMerdeBridge.php index 0f32467d..e0f65e19 100644 --- a/bridges/BlaguesDeMerdeBridge.php +++ b/bridges/BlaguesDeMerdeBridge.php @@ -1,17 +1,15 @@ maintainer = "superbaillot.net"; - $this->name = "Blagues De Merde"; - $this->uri = "http://www.blaguesdemerde.fr/"; - $this->description = "Blagues De Merde"; - - } public function collectData(){ - $html = $this->getSimpleHTMLDOM('http://www.blaguesdemerde.fr/') or $this->returnServerError('Could not request BDM.'); + $html = $this->getSimpleHTMLDOM($this->uri) + or $this->returnServerError('Could not request BDM.'); foreach($html->find('article.joke_contener') as $element) { $item = array(); diff --git a/bridges/BooruprojectBridge.php b/bridges/BooruprojectBridge.php index a4e3aeb4..eb3f5ac5 100644 --- a/bridges/BooruprojectBridge.php +++ b/bridges/BooruprojectBridge.php @@ -1,48 +1,42 @@ maintainer = "mitsukarenai"; - $this->name = "Booruproject"; - $this->uri = "http://booru.org/"; - $this->description = "Returns images from given page and booruproject instance (****.booru.org)"; - - $this->parameters[] = array( + public $parameters = array( array( 'i'=>array( 'name'=>'instance (required)', 'required'=>true ), - 'p'=>array('name'=>'page'), + 'p'=>array( + 'name'=>'page', + 'type'=>'number' + ), 't'=>array('name'=>'tags') - ); - } + )); + function getURI(){ + return 'http://'.$this->getInput('i').'.booru.org/'; + } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $page = 0; $tags = ''; - if (!empty($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); - $page = $page - 1; - $page = $page * 20; - } - if (!empty($param['t']['value'])) { - $tags = '&tags='.urlencode($param['t']['value']); - } - if (empty($param['i']['value'])) { - $this->returnServerError('Please enter a ***.booru.org instance.'); - } - $html = $this->getSimpleHTMLDOM("http://".$param['i']['value'].".booru.org/index.php?page=post&s=list&pid=".$page.$tags) or $this->returnServerError('Could not request Booruproject.'); + $html = $this->getSimpleHTMLDOM( + $this->getURI().'index.php?page=post&s=list' + .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*20:'') + .'&tags='.urlencode($this->getInput('t')) + ) or $this->returnServerError('Could not request Booruprojec.'); foreach($html->find('div[class=content] span') as $element) { $item = array(); - $item['uri'] = 'http://'.$param['i']['value'].'.booru.org/'.$element->find('a', 0)->href; + $item['uri'] = $this->getURI().$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('a', 0)->getAttribute('id')); $item['timestamp'] = time(); $item['tags'] = $element->find('img', 0)->getAttribute('title'); - $item['title'] = 'Booruproject '.$param['i']['value'].' | '.$item['postid']; + $item['title'] = 'Booruproject '.$this->getInput('i').' | '.$item['postid']; $item['content'] = '
Tags: '.$item['tags']; $this->items[] = $item; } diff --git a/bridges/CADBridge.php b/bridges/CADBridge.php index 4c695f06..8073f86a 100644 --- a/bridges/CADBridge.php +++ b/bridges/CADBridge.php @@ -1,11 +1,9 @@ maintainer = "nyutag"; - $this->name = "CAD Bridge"; - $this->uri = "http://www.cad-comic.com/"; - $this->description = "Returns the newest articles."; - } + public $maintainer = "nyutag"; + public $name = "CAD Bridge"; + public $uri = "http://www.cad-comic.com/"; + public $description = "Returns the newest articles."; private function CADExtractContent($url) { $html3 = $this->getSimpleHTMLDOM($url); diff --git a/bridges/CNETBridge.php b/bridges/CNETBridge.php index 2fbed359..e9519766 100644 --- a/bridges/CNETBridge.php +++ b/bridges/CNETBridge.php @@ -1,22 +1,16 @@ You may specify a topic found in some section URLs, else all topics are selected.'; - public function loadMetadatas() { - - $this->maintainer = 'ORelio'; - $this->name = 'CNET News'; - $this->uri = 'http://www.cnet.com/'; - $this->description = 'Returns the newest articles.
You may specify a topic found in some section URLs, else all topics are selected.'; - - $this->parameters[] = array( - 'topic'=>array('name'=>'Topic name') - ); - } + public $parameters = array( array( + 'topic'=>array('name'=>'Topic name') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { @@ -43,10 +37,7 @@ class CNETBridge extends BridgeAbstract { return $article_html; } - if (!empty($param['topic']['value'])) - $this->topicName = $param['topic']['value']; - - $pageUrl = 'http://www.cnet.com/'.(empty($this->topicName) ? '' : 'topics/'.$this->topicName.'/'); + $pageUrl = $this->uri.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/'); $html = $this->getSimpleHTMLDOM($pageUrl) or $this->returnServerError('Could not request CNET: '.$pageUrl); $limit = 0; @@ -54,7 +45,7 @@ class CNETBridge extends BridgeAbstract { if ($limit < 8) { $article_title = trim($element->find('h2', 0)->plaintext); - $article_uri = 'http://www.cnet.com'.($element->find('a', 0)->href); + $article_uri = $this->uri.($element->find('a', 0)->href); $article_timestamp = strtotime($element->find('time.assetTime', 0)->plaintext); $article_author = trim($element->find('a[rel=author]', 0)->plaintext); @@ -78,7 +69,7 @@ class CNETBridge extends BridgeAbstract { } public function getName() { - return 'CNET News Bridge'.(empty($this->topicName) ? '' : ' - '.$this->topicName); + return 'CNET News Bridge'.(empty($this->getInput('topic')) ? '' : ' - '.$this->getInput('topic')); } public function getCacheDuration() { diff --git a/bridges/CastorusBridge.php b/bridges/CastorusBridge.php index 73e8a1af..35736b80 100644 --- a/bridges/CastorusBridge.php +++ b/bridges/CastorusBridge.php @@ -1,31 +1,31 @@ maintainer = "logmanoriginal"; - $this->name = "Castorus Bridge"; - $this->uri = 'http://www.castorus.com'; - $this->description = "Returns the latest changes"; + public $maintainer = "logmanoriginal"; + public $name = "Castorus Bridge"; + public $uri = 'http://www.castorus.com'; + public $description = "Returns the latest changes"; - $this->parameters["Get latest changes"] = array(); - $this->parameters["Get latest changes via ZIP code"] = array( - 'zip'=>array( - 'name'=>'ZIP code', - 'type'=>'text', - 'required'=>true, - 'exampleValue'=>'74910, 74', - 'title'=>'Insert ZIP code (complete or partial)' - ) - ); - $this->parameters["Get latest changes via city name"] = array( - 'city'=>array( - 'name'=>'City name', - 'type'=>'text', - 'required'=>true, - 'exampleValue'=>'Seyssel, Seys', - 'title'=>'Insert city name (complete or partial)' - ) - ); - } + public $parameters = array( + 'Get latest changes' => array(), + 'Get latest changes via ZIP code' => array( + 'zip'=>array( + 'name'=>'ZIP code', + 'type'=>'text', + 'required'=>true, + 'exampleValue'=>'74910, 74', + 'title'=>'Insert ZIP code (complete or partial)' + ) + ), + 'Get latest changes via city name' => array( + 'city'=>array( + 'name'=>'City name', + 'type'=>'text', + 'required'=>true, + 'exampleValue'=>'Seyssel, Seys', + 'title'=>'Insert city name (complete or partial)' + ) + ) + ); // Extracts the tile from an actitiy private function ExtractActivityTitle($activity){ @@ -74,12 +74,8 @@ class CastorusBridge extends BridgeAbstract { } public function collectData(){ - $params=$this->parameters[$this->queriedContext]; - if(isset($params['zip']['value'])) - $zip_filter = trim($params['zip']['value']); - - if(isset($params['city']['value'])) - $city_filter = trim($params['city']['value']); + $zip_filter = trim($this->getInput('zip')); + $city_filter = trim($this->getInput('city')); $html = $this->getSimpleHTMLDOM($this->uri); diff --git a/bridges/CollegeDeFranceBridge.php b/bridges/CollegeDeFranceBridge.php index 241e6f38..3d9a21c1 100644 --- a/bridges/CollegeDeFranceBridge.php +++ b/bridges/CollegeDeFranceBridge.php @@ -1,12 +1,10 @@ maintainer = "pit-fgfjiudghdf"; - $this->name = "CollegeDeFrance"; - $this->uri = "http://www.college-de-france.fr/"; - $this->description = "Returns the latest audio and video from CollegeDeFrance"; - } + public $maintainer = "pit-fgfjiudghdf"; + public $name = "CollegeDeFrance"; + public $uri = "http://www.college-de-france.fr/"; + public $description = "Returns the latest audio and video from CollegeDeFrance"; public function collectData(){ $months = array( @@ -32,7 +30,8 @@ class CollegeDeFranceBridge extends BridgeAbstract{ * * */ - $html = $this->getSimpleHTMLDOM('http://www.college-de-france.fr/components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') or $this->returnServerError('Could not request CollegeDeFrance.'); + $html = $this->getSimpleHTMLDOM($this->uri.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') + or $this->returnServerError('Could not request CollegeDeFrance.'); foreach($html->find('a[data-target]') as $element) { $item = array(); $item['title'] = $element->find('.title', 0)->plaintext; @@ -45,10 +44,25 @@ class CollegeDeFranceBridge extends BridgeAbstract{ // $timezone = new DateTimeZone('Europe/Paris'); // strpos($element->href, '201') will break in 2020 but it'll probably break prior to then due to site changes anyway - $d = DateTime::createFromFormat('!Y-m-d-H\hi', substr($element->href, strpos($element->href, '201'), 16), $timezone) ?: DateTime::createFromFormat('!d m Y', trim(str_replace(array_values($months), array_keys($months), $element->find('.date', 0)->plaintext)), $timezone); - $item['timestamp'] = $d->format('U'); + $d = DateTime::createFromFormat( + '!Y-m-d-H\hi', + substr($element->href, strpos($element->href, '201'), 16), + $timezone + ); + if(!$d){ + $d=DateTime::createFromFormat( + '!d m Y', + trim(str_replace( + array_values($months), + array_keys($months), + $element->find('.date', 0)->plaintext + )), + $timezone + ); + } + $item['timestamp'] = $d->format('U'); $item['content'] = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext; - $item['uri'] = 'http://www.college-de-france.fr' . $element->href; + $item['uri'] = $this->uri . $element->href; $this->items[] = $item; } } diff --git a/bridges/CommonDreamsBridge.php b/bridges/CommonDreamsBridge.php index 21dfcbe1..23627e3b 100644 --- a/bridges/CommonDreamsBridge.php +++ b/bridges/CommonDreamsBridge.php @@ -1,12 +1,10 @@ maintainer = "nyutag"; - $this->name = "CommonDreams Bridge"; - $this->uri = "http://www.commondreams.org/"; - $this->description = "Returns the newest articles."; - } + public $maintainer = "nyutag"; + public $name = "CommonDreams Bridge"; + public $uri = "http://www.commondreams.org/"; + public $description = "Returns the newest articles."; private function CommonDreamsExtractContent($url) { $html3 = $this->getSimpleHTMLDOM($url); diff --git a/bridges/CopieDoubleBridge.php b/bridges/CopieDoubleBridge.php index a4420e6f..6e787dbe 100644 --- a/bridges/CopieDoubleBridge.php +++ b/bridges/CopieDoubleBridge.php @@ -1,24 +1,19 @@ maintainer = "superbaillot.net"; - $this->name = "CopieDouble"; - $this->uri = "http://www.copie-double.com/"; - $this->description = "CopieDouble"; - - } - + public $maintainer = "superbaillot.net"; + public $name = "CopieDouble"; + public $uri = "http://www.copie-double.com/"; + public $description = "CopieDouble"; public function collectData(){ - $html = $this->getSimpleHTMLDOM('http://www.copie-double.com/') or $this->returnServerError('Could not request CopieDouble.'); + $html = $this->getSimpleHTMLDOM($this->uri) + or $this->returnServerError('Could not request CopieDouble.'); $table = $html->find('table table', 2); foreach($table->find('tr') as $element) { $td = $element->find('td', 0); - $cpt++; if($td->class == "couleur_1") { $item = array(); @@ -31,10 +26,10 @@ class CopieDoubleBridge extends BridgeAbstract{ elseif(strpos($element->innertext, "/images/suivant.gif") === false) { $a=$element->find("a", 0); - $item['uri'] = "http://www.copie-double.com" . $a->href; + $item['uri'] = $this->uri . $a->href; - $content = str_replace('src="/', 'src="http://www.copie-double.com/',$element->find("td", 0)->innertext); - $content = str_replace('href="/', 'href="http://www.copie-double.com/',$content); + $content = str_replace('src="/', 'src="/'.$this->uri,$element->find("td", 0)->innertext); + $content = str_replace('href="/', 'href="'.$this->uri,$content); $item['content'] = $content; $this->items[] = $item; } diff --git a/bridges/CourrierInternationalBridge.php b/bridges/CourrierInternationalBridge.php index 62c8feec..09d1aa6d 100644 --- a/bridges/CourrierInternationalBridge.php +++ b/bridges/CourrierInternationalBridge.php @@ -1,22 +1,15 @@ maintainer = "teromene"; - $this->name = "Courrier International Bridge"; - $this->uri = "http://CourrierInternational.fr/"; - $this->description = "Courrier International bridge"; - - } + public $maintainer = "teromene"; + public $name = "Courrier International Bridge"; + public $uri = "http://CourrierInternational.com/"; + public $description = "Courrier International bridge"; public function collectData(){ - $html = ''; - - $html = $this->getSimpleHTMLDOM('http://www.courrierinternational.com/') or $this->returnServerError('Error.'); - - + $html = $this->getSimpleHTMLDOM($this->uri) + or $this->returnServerError('Error.'); $element = $html->find("article"); @@ -29,7 +22,7 @@ class CourrierInternationalBridge extends BridgeAbstract{ $item['uri'] = $article->parent->getAttribute("href"); if(strpos($item['uri'], "http") === FALSE) { - $item['uri'] = "http://courrierinternational.fr/".$item['uri']; + $item['uri'] = $this->uri.$item['uri']; } $page = $this->getSimpleHTMLDOM($item['uri']); diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index 862e58bb..c9b70211 100644 --- a/bridges/CpasbienBridge.php +++ b/bridges/CpasbienBridge.php @@ -1,38 +1,28 @@ maintainer = "lagaisse"; - $this->name = "Cpasbien Bridge"; - $this->uri = "http://www.cpasbien.io"; - $this->description = "Returns latest torrents from a request query"; - - $this->parameters[] = array( - 'q'=>array( + public $parameters = array( array( + 'q'=>array( 'name'=>'Search', 'required'=>true, 'title'=>'Type your search' - ) - ); - - } - + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $html = ''; - if (isset($param['q']['value'])) { /* keyword search mode */ - $request = str_replace(" ","-",trim($param['q']['value'])); - $html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($request).'.html') or $this->returnServerError('No results for this query.'); - } else { - $this->returnClientError('You must specify a keyword (?q=...).'); - } + $request = str_replace(" ","-",trim($this->getInput('q'))); + $html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($request).'.html') + or $this->returnServerError('No results for this query.'); foreach ($html->find('#gauche',0)->find('div') as $episode) { - if ($episode->getAttribute('class')=='ligne0' || $episode->getAttribute('class')=='ligne1') + if ($episode->getAttribute('class')=='ligne0' || + $episode->getAttribute('class')=='ligne1') { - $htmlepisode=$this->get_cached($episode->find('a', 0)->getAttribute('href')); $item = array(); @@ -58,8 +48,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ public function getName(){ - return $this->parameters[$this->queriedContext]['q']['value'] - .' : '.$this->name; + return $this->getInput('q').' : '.$this->name; } public function getCacheDuration(){ diff --git a/bridges/CryptomeBridge.php b/bridges/CryptomeBridge.php index daf404fb..072fbd59 100644 --- a/bridges/CryptomeBridge.php +++ b/bridges/CryptomeBridge.php @@ -1,43 +1,34 @@ maintainer = "BoboTiG"; - $this->name = "Cryptome"; - $this->uri = "http://cryptome.org/"; - $this->description = "Returns the N most recent documents."; - - $this->parameters[] = array( - 'n'=>array( + public $parameters = array( array( + 'n'=>array( 'name'=>'number of elements', 'type'=>'number', + 'defaultValue'=>20, 'exampleValue'=>10 - ) - ); - } - + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $html = ''; - $num = 20; - $link = 'http://cryptome.org/'; - // If you want HTTPS access instead, uncomment the following line: - //$link = 'https://secure.netsolhost.com/cryptome.org/'; - - $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request Cryptome.'); - if (!empty($param['n']['value'])) { /* number of documents */ - $num = min(max(1, $param['n']['value']+0), $num); + $html = $this->getSimpleHTMLDOM($this->uri) + or $this->returnServerError('Could not request Cryptome.'); + if (!empty($this->getInput('n'))) { /* number of documents */ + $num = min($this->getInput('n'), 20); } foreach($html->find('pre') as $element) { for ( $i = 0; $i < $num; ++$i ) { $item = array(); - $item['uri'] = $link.substr($element->find('a', $i)->href, 20); + $item['uri'] = $this->uri.substr($element->find('a', $i)->href, 20); $item['title'] = substr($element->find('b', $i)->plaintext, 22); - $item['content'] = preg_replace('#http://cryptome.org/#', $link, $element->find('b', $i)->innertext); + $item['content'] = preg_replace('#http://cryptome.org/#', $this->uri, $element->find('b', $i)->innertext); $this->items[] = $item; } break; diff --git a/bridges/DailymotionBridge.php b/bridges/DailymotionBridge.php index 0a73df8f..7849ba64 100644 --- a/bridges/DailymotionBridge.php +++ b/bridges/DailymotionBridge.php @@ -1,92 +1,117 @@ maintainer = "mitsukarenai"; - $this->name = "Dailymotion Bridge"; - $this->uri = "https://www.dailymotion.com/"; - $this->description = "Returns the 5 newest videos by username/playlist or search"; - - $this->parameters["By username"] = array( - 'u'=>array('name'=>'username') - ); - - $this->parameters["By playlist id"] = array( - 'p'=>array( - 'name'=>'playlist id', - 'type'=>'text', - 'required'=>true - ) - ); - - $this->parameters["From search results"] = array( - 's'=>array( - 'name'=>'Search keyword', - 'required'=>true + public $parameters = array ( + 'By username' => array( + 'u'=>array( + 'name'=>'username', + 'required'=>true + ) ), - 'pa'=>array( - 'name'=>'Page', - 'type'=>'number' - ) + + 'By playlist id' => array( + 'p'=>array( + 'name'=>'playlist id', + 'required'=>true + ) + ), + + 'From search results' => array( + 's'=>array( + 'name'=>'Search keyword', + 'required'=>true + ), + 'pa'=>array( + 'name'=>'Page', + 'type'=>'number' + ) + ) ); - } function getMetadata($id) { - $metadata=array(); - $html2 = $this->getSimpleHTMLDOM('http://www.dailymotion.com/video/'.$id) or $this->returnServerError('Could not request Dailymotion.'); - $metadata['title'] = $html2->find('meta[property=og:title]', 0)->getAttribute('content'); - $metadata['timestamp'] = strtotime($html2->find('meta[property=video:release_date]', 0)->getAttribute('content') ); - $metadata['thumbnailUri'] = $html2->find('meta[property=og:image]', 0)->getAttribute('content'); - $metadata['uri'] = $html2->find('meta[property=og:url]', 0)->getAttribute('content'); + $metadata=array(); + $html2 = $this->getSimpleHTMLDOM($this->uri.'video/'.$id); + if(!$html2){ + return $metadata; + } - return $metadata; + $metadata['title'] = $html2->find('meta[property=og:title]', 0)->getAttribute('content'); + $metadata['timestamp'] = strtotime($html2->find('meta[property=video:release_date]', 0)->getAttribute('content') ); + $metadata['thumbnailUri'] = $html2->find('meta[property=og:image]', 0)->getAttribute('content'); + $metadata['uri'] = $html2->find('meta[property=og:url]', 0)->getAttribute('content'); + return $metadata; } - public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $html = ''; - $limit = 5; - $count = 0; + public function collectData(){ + $html = ''; + $limit = 5; + $count = 0; - if (isset($param['u']['value'])) { // user timeline mode - $this->request = $param['u']['value']; - $html = $this->getSimpleHTMLDOM('http://www.dailymotion.com/user/'.urlencode($this->request).'/1') or $this->returnServerError('Could not request Dailymotion.'); - } - else if (isset($param['p']['value'])) { // playlist mode - $this->request = strtok($param['p']['value'], '_'); - $html = $this->getSimpleHTMLDOM('http://www.dailymotion.com/playlist/'.urlencode($this->request).'') or $this->returnServerError('Could not request Dailymotion.'); - } - else if (isset($param['s']['value'])) { // search mode - $this->request = $param['s']['value']; $page = 1; if (isset($param['pa']['value'])) $page = (int)preg_replace("/[^0-9]/",'', $param['pa']['value']); - $html = $this->getSimpleHTMLDOM('http://www.dailymotion.com/search/'.urlencode($this->request).'/'.$page.'') or $this->returnServerError('Could not request Dailymotion.'); - } - else { - $this->returnClientError('You must either specify a Dailymotion username (?u=...) or a playlist id (?p=...) or search (?s=...)'); - } + $html = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError('Could not request Dailymotion.'); - foreach($html->find('div.media a.preview_link') as $element) { - if($count < $limit) { - $item = array(); - $item['id'] = str_replace('/video/', '', strtok($element->href, '_')); - $metadata = $this->getMetadata($item['id']); - $item['uri'] = $metadata['uri']; - $item['title'] = $metadata['title']; - $item['timestamp'] = $metadata['timestamp']; - $item['content'] = '
' . $item['title'] . ''; - $this->items[] = $item; - $count++; - } - } - } + foreach($html->find('div.media a.preview_link') as $element) { + if($count < $limit) { + $item = array(); + $item['id'] = str_replace('/video/', '', strtok($element->href, '_')); + $metadata = $this->getMetadata($item['id']); + if(empty($metadata)){ + continue; + } + $item['uri'] = $metadata['uri']; + $item['title'] = $metadata['title']; + $item['timestamp'] = $metadata['timestamp']; + $item['content'] = '
' . $item['title'] . ''; + $this->items[] = $item; + $count++; + } + } + } - public function getName(){ - return (!empty($this->request) ? $this->request .' - ' : '') .'Dailymotion Bridge'; - } + public function getName(){ + switch($this->queriedContext){ + case 'By username': + $specific=$this->getInput('u'); + break; + case 'By playlist id': + $specific=strtok($this->getInput('p'), '_'); + break; + case 'From search results': + $specific=$this->getInput('s'); + break; + } - public function getCacheDuration(){ - return 3600*3; // 3 hours - } + return $specific.' : Dailymotion Bridge'; + } + + public function getURI(){ + $uri=$this->uri; + switch($this->queriedContext){ + case 'By username': + $uri.='user/' + .urlencode($this->getInput('u')).'/1'; + break; + case 'By playlist id': + $uri.='playlist/' + .urlencode(strtok($this->getInput('p'), '_')); + break; + case 'From search results': + $uri.='search/' + .urlencode($this->getInput('s')); + if($this->getInput('pa')){ + $uri.='/'.$this->getInput('pa'); + } + break; + } + return $uri; + } + + public function getCacheDuration(){ + return 3600*3; // 3 hours + } } diff --git a/bridges/DanbooruBridge.php b/bridges/DanbooruBridge.php index f41bc776..9f6f63aa 100644 --- a/bridges/DanbooruBridge.php +++ b/bridges/DanbooruBridge.php @@ -1,35 +1,31 @@ maintainer = "mitsukarenai"; - $this->name = "Danbooru"; - $this->uri = "http://donmai.us/"; - $this->description = "Returns images from given page"; - - $this->parameters[] = array( - 'p'=>array('name'=>'page'), - 't'=>array('name'=>'tags') - ); - } + public $parameters = array( array( + 'p'=>array( + 'name'=>'page', + 'type'=>'number' + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $page = 1;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); - } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); - } - $html = $this->getSimpleHTMLDOM("http://donmai.us/posts?&page=$page&tags=$tags") or $this->returnServerError('Could not request Danbooru.'); + $page = $this->getInput('p')?$this->getInput('p'):1; + $tags = urlencode($this->getInput('t')); + + $html = $this->getSimpleHTMLDOM($this->uri."posts?&page=$page&tags=$tags") + or $this->returnServerError('Could not request Danbooru.'); foreach($html->find('div[id=posts] article') as $element) { $item = array(); - $item['uri'] = 'http://donmai.us'.$element->find('a', 0)->href; + $item['uri'] = $this->uri.$element->find('a', 0)->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-id')); $item['timestamp'] = time(); - $thumbnailUri = 'http://donmai.us'.$element->find('img', 0)->src; + $thumbnailUri = $this->uri.$element->find('img', 0)->src; $item['tags'] = $element->find('img', 0)->getAttribute('alt'); $item['title'] = 'Danbooru | '.$item['postid']; $item['content'] = '
Tags: '.$item['tags']; diff --git a/bridges/DansTonChatBridge.php b/bridges/DansTonChatBridge.php index 83f6cd2a..f94f1cee 100644 --- a/bridges/DansTonChatBridge.php +++ b/bridges/DansTonChatBridge.php @@ -1,20 +1,15 @@ maintainer = "Astalaseven"; - $this->name = "DansTonChat Bridge"; - $this->uri = "http://danstonchat.com"; - $this->description = "Returns latest quotes from DansTonChat."; - - } + public $maintainer = "Astalaseven"; + public $name = "DansTonChat Bridge"; + public $uri = "http://danstonchat.com/"; + public $description = "Returns latest quotes from DansTonChat."; public function collectData(){ - $html = ''; - $link = 'http://danstonchat.com/latest.html'; - $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request DansTonChat.'); + $html = $this->getSimpleHTMLDOM($this->uri.'latest.html') + or $this->returnServerError('Could not request DansTonChat.'); foreach($html->find('div.item') as $element) { $item = array(); diff --git a/bridges/DauphineLibereBridge.php b/bridges/DauphineLibereBridge.php index d97a0a59..1084969d 100644 --- a/bridges/DauphineLibereBridge.php +++ b/bridges/DauphineLibereBridge.php @@ -1,64 +1,52 @@ maintainer = "qwertygc"; - $this->name = "Dauphine Bridge"; - $this->uri = "http://www.ledauphine.com/"; - $this->description = "Returns the newest articles."; - - $this->parameters[] = array( - 'u'=>array( + public $parameters = array( array( + 'u'=>array( 'name'=>'Catégorie de l\'article', 'type'=>'list', 'values'=>array( - 'À la une'=>'', - 'France Monde'=>'france-monde', - 'Faits Divers'=>'faits-divers', - 'Économie et Finance'=>'economie-et-finance', - 'Politique'=>'politique', - 'Sport'=>'sport', - 'Ain'=>'ain', - 'Alpes-de-Haute-Provence'=>'haute-provence', - 'Hautes-Alpes'=>'hautes-alpes', - 'Ardèche'=>'ardeche', - 'Drôme'=>'drome', - 'Isère Sud'=>'isere-sud', - 'Savoie'=>'savoie', - 'Haute-Savoie'=>'haute-savoie', - 'Vaucluse'=>'vaucluse' + 'À la une'=>'', + 'France Monde'=>'france-monde', + 'Faits Divers'=>'faits-divers', + 'Économie et Finance'=>'economie-et-finance', + 'Politique'=>'politique', + 'Sport'=>'sport', + 'Ain'=>'ain', + 'Alpes-de-Haute-Provence'=>'haute-provence', + 'Hautes-Alpes'=>'hautes-alpes', + 'Ardèche'=>'ardeche', + 'Drôme'=>'drome', + 'Isère Sud'=>'isere-sud', + 'Savoie'=>'savoie', + 'Haute-Savoie'=>'haute-savoie', + 'Vaucluse'=>'vaucluse' ) - ) - ); - } + ) + )); private function ExtractContent($url, $context) { - $html2 = $this->getSimpleHTMLDOM($url,false,$context); + $html2 = $this->getSimpleHTMLDOM($url); $text = $html2->find('div.column', 0)->innertext; $text = preg_replace('@]*?>.*?@si', '', $text); return $text; } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - - // Simulate Mozilla user-agent to fix error 403 (Forbidden) - $opts = array('http' => - array( - 'method' => 'GET', - 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36' - ) - ); $context = stream_context_create($opts); - if (isset($param['u']['value'])) { /* user timeline mode */ - $this->request = $param['u']['value']; - $html = $this->getSimpleHTMLDOM('http://www.ledauphine.com/'.$this->request.'/rss',false,$context) or $this->returnServerError('Could not request DauphineLibere.'); - } - else { - $html = $this->getSimpleHTMLDOM('http://www.ledauphine.com/rss',false,$context) or $this->returnServerError('Could not request DauphineLibere.'); + if (empty($this->getInput('u'))) { + $html = $this->getSimpleHTMLDOM($this->uri.$this->getInput('u').'/rss') + or $this->returnServerError('Could not request DauphineLibere.'); + } else { + $html = $this->getSimpleHTMLDOM($this->uri.'rss') + or $this->returnServerError('Could not request DauphineLibere.'); } $limit = 0; diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index f6d6efb1..2fff948a 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -1,54 +1,53 @@ maintainer = "teromene"; - $this->name = "DemoBridge"; - $this->uri = "http://github.com/sebsauvage/rss-bridge"; - $this->description = "Bridge used for demos"; - - $this->parameters['testCheckbox'] = array( - 'testCheckbox'=>array( - 'type'=>'checkbox', - 'name'=>'test des checkbox' - ) - ); - - $this->parameters['testList'] = array( - 'testList'=>array( - 'type'=>'list', - 'name'=>'test des listes', - 'values'=>array( - 'Test'=>'test', - 'Test 2'=>'test2' + public $parameters = array( + 'testCheckbox' => array( + 'testCheckbox'=>array( + 'type'=>'checkbox', + 'name'=>'test des checkbox' ) - ) - ); + ), - $this->parameters['testNumber'] = array( - 'testNumber'=>array( - 'type'=>'number', - 'name'=>'test des numéros', - 'exampleValue'=>'1515632' - ) - ); - } + 'testList' => array( + 'testList'=>array( + 'type'=>'list', + 'name'=>'test des listes', + 'values'=>array( + 'Test'=>'test', + 'Test 2'=>'test2' + ) + ) + ), - public function collectData(){ + 'testNumber' => array( + 'testNumber'=>array( + 'type'=>'number', + 'name'=>'test des numéros', + 'exampleValue'=>'1515632' + ) + ) + ); - $item = array(); - $item['author'] = "Me!"; - $item['title'] = "Test"; - $item['content'] = "Awesome content !"; - $item['id'] = "Lalala"; - $item['uri'] = "http://test.test/test"; + public function collectData(){ - $this->items[] = $item; + $item = array(); + $item['author'] = "Me!"; + $item['title'] = "Test"; + $item['content'] = "Awesome content !"; + $item['id'] = "Lalala"; + $item['uri'] = "http://example.com/test"; + + $this->items[] = $item; } - public function getCacheDuration(){ - return 00; // 1 hour - } + public function getCacheDuration(){ + return 00; // 1 hour + } } diff --git a/bridges/DeveloppezDotComBridge.php b/bridges/DeveloppezDotComBridge.php index ca18fe39..a7958e67 100644 --- a/bridges/DeveloppezDotComBridge.php +++ b/bridges/DeveloppezDotComBridge.php @@ -1,12 +1,10 @@ maintainer = "polopollo"; - $this->name = "Developpez.com Actus (FR)"; - $this->uri = "http://www.developpez.com/"; - $this->description = "Returns the 15 newest posts from DeveloppezDotCom (full text)."; - } + public $maintainer = "polopollo"; + public $name = "Developpez.com Actus (FR)"; + public $uri = "http://www.developpez.com/"; + public $description = "Returns the 15 newest posts from DeveloppezDotCom (full text)."; private function DeveloppezDotComStripCDATA($string) { $string = str_replace('getSimpleHTMLDOM('http://www.developpez.com/index/rss') or $this->returnServerError('Could not request http://www.developpez.com/index/rss'); + $rssFeed = $this->getSimpleHTMLDOM($this->uri.'index/rss') + or $this->returnServerError('Could not request '.$this->uri.'index/rss'); $limit = 0; foreach($rssFeed->find('item') as $element) { diff --git a/bridges/DilbertBridge.php b/bridges/DilbertBridge.php index e0c23e6f..05d94fcb 100644 --- a/bridges/DilbertBridge.php +++ b/bridges/DilbertBridge.php @@ -1,14 +1,10 @@ maintainer = 'kranack'; - $this->name = 'Dilbert Daily Strip'; - $this->uri = 'http://dilbert.com'; - $this->description = 'The Unofficial Dilbert Daily Comic Strip'; - - } + public $maintainer = 'kranack'; + public $name = 'Dilbert Daily Strip'; + public $uri = 'http://dilbert.com'; + public $description = 'The Unofficial Dilbert Daily Comic Strip'; public function collectData(){ diff --git a/bridges/DollbooruBridge.php b/bridges/DollbooruBridge.php index fb3a5da6..73f2c196 100644 --- a/bridges/DollbooruBridge.php +++ b/bridges/DollbooruBridge.php @@ -1,41 +1,33 @@ maintainer = "mitsukarenai"; - $this->name = "Dollbooru"; - $this->uri = "http://dollbooru.org/"; - $this->description = "Returns images from given page"; + public $maintainer = "mitsukarenai"; + public $name = "Dollbooru"; + public $uri = "http://dollbooru.org/"; + public $description = "Returns images from given page"; - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $page = 0;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); - } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); - } - $html = $this->getSimpleHTMLDOM("http://dollbooru.org/post/list/$tags/$page") or $this->returnServerError('Could not request Dollbooru.'); + $page=$this->getInput('p'); + $tags = urlencode($this->getInput('t')); + $html = $this->getSimpleHTMLDOM($this->uri."post/list/$tags/$page") + or $this->returnServerError('Could not request Dollbooru.'); foreach($html->find('div[class=shm-image-list] a') as $element) { $item = array(); - $item['uri'] = 'http://dollbooru.org'.$element->href; + $item['uri'] = $this->uri.$element->href; $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-post-id')); $item['timestamp'] = time(); - $thumbnailUri = 'http://dollbooru.org'.$element->find('img', 0)->src; + $thumbnailUri = $this->uri.$element->find('img', 0)->src; $item['tags'] = $element->getAttribute('data-tags'); $item['title'] = 'Dollbooru | '.$item['postid']; $item['content'] = '
Tags: '.$item['tags']; diff --git a/bridges/DuckDuckGoBridge.php b/bridges/DuckDuckGoBridge.php index 1522978e..29719a91 100644 --- a/bridges/DuckDuckGoBridge.php +++ b/bridges/DuckDuckGoBridge.php @@ -1,26 +1,20 @@ maintainer = "Astalaseven"; - $this->name = "DuckDuckGo"; - $this->uri = "https://duckduckgo.com/"; - $this->description = "Returns most recent results from DuckDuckGo."; - - $this->parameters[] = array( - 'u'=>array( + public $parameters = array( array( + 'u'=>array( 'name'=>'keyword', 'required'=>true) - ); - } + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $html = ''; - $link = 'http://duckduckgo.com/html/?q='.$param['u']['value'].'+sort:date'; - - $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request DuckDuckGo.'); + $html = $this->getSimpleHTMLDOM($this->uri.'html/?q='.$this->getInput('u').'+sort:date') + or $this->returnServerError('Could not request DuckDuckGo.'); foreach($html->find('div.results_links') as $element) { $item = array(); diff --git a/bridges/EZTVBridge.php b/bridges/EZTVBridge.php index 83b93d13..a6ab15eb 100644 --- a/bridges/EZTVBridge.php +++ b/bridges/EZTVBridge.php @@ -1,24 +1,20 @@ maintainer = "alexAubin"; - $this->name = "EZTV"; - $this->uri = "https://eztv.ch/"; - $this->description = "Returns list of *recent* torrents for a specific show on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name."; - - $this->parameters[] = array( - 'i'=>array( + public $parameters = array( array( + 'i'=>array( 'name'=>'Show ids', 'exampleValue'=>'showID1,showID2,…', 'required'=>true - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; // Make timestamp from relative released time in table function makeTimestamp($relativeReleaseTime){ @@ -33,16 +29,13 @@ class EZTVBridge extends BridgeAbstract{ return mktime(date('h')-$relativeHours,0,0,date('m'),date('d')-$relativeDays,date('Y')); } - // Check for ID provided - if (!isset($param['i']['value'])) - $this->returnClientError('You must provide a list of ID (?i=showID1,showID2,...)'); - // Loop on show ids - $showList = explode(",",$param['i']['value']); + $showList = explode(",",$this->getInput('i')); foreach($showList as $showID){ // Get show page - $html = $this->getSimpleHTMLDOM('https://eztv.ch/shows/'.rawurlencode($showID).'/') or $this->returnServerError('Could not request EZTV for id "'.$showID.'"'); + $html = $this->getSimpleHTMLDOM($this->uri.'shows/'.rawurlencode($showID).'/') + or $this->returnServerError('Could not request EZTV for id "'.$showID.'"'); // Loop on each element that look like an episode entry... foreach($html->find('.forum_header_border') as $element) { @@ -60,7 +53,7 @@ class EZTVBridge extends BridgeAbstract{ // Fill item $item = array(); - $item['uri'] = 'https://eztv.ch/'.$epinfo->href; + $item['uri'] = $this->uri.$epinfo->href; $item['id'] = $item['uri']; $item['timestamp'] = makeTimestamp($released->plaintext); $item['title'] = $epinfo->plaintext; diff --git a/bridges/EliteDangerousGalnetBridge.php b/bridges/EliteDangerousGalnetBridge.php index 9e9400d0..a15718a2 100644 --- a/bridges/EliteDangerousGalnetBridge.php +++ b/bridges/EliteDangerousGalnetBridge.php @@ -1,23 +1,20 @@ - maintainer = "corenting"; - $this->name = "Elite: Dangerous Galnet"; - $this->uri = "https://community.elitedangerous.com/galnet"; - $this->description = "Returns the latest page of news from Galnet"; - } + public $maintainer = "corenting"; + public $name = "Elite: Dangerous Galnet"; + public $uri = "https://community.elitedangerous.com/galnet/"; + public $description = "Returns the latest page of news from Galnet"; public function collectData() { - $html = $this->getSimpleHTMLDOM('https://community.elitedangerous.com/galnet') or $this->returnServerError('Error while downloading the website content'); + $html = $this->getSimpleHTMLDOM($this->uri) + or $this->returnServerError('Error while downloading the website content'); foreach($html->find('div.article') as $element) { $item = array(); $uri = $element->find('h3 a', 0)->href; - $uri = 'https://community.elitedangerous.com' . $uri; + $uri = $this->uri . substr($uri,strlen('/galnet/')); $item['uri'] = $uri; $title = $element->find('h3 a', 0)->plaintext; diff --git a/bridges/ElsevierBridge.php b/bridges/ElsevierBridge.php index 25a9446f..0444f63c 100644 --- a/bridges/ElsevierBridge.php +++ b/bridges/ElsevierBridge.php @@ -1,21 +1,18 @@ maintainer = 'Pierre Mazière'; - $this->name = 'Elsevier journals recent articles'; - $this->uri = 'http://www.journals.elsevier.com'; - $this->description = 'Returns the recent articles published in Elsevier journals'; - - $this->parameters[] = array( - 'j'=>array( + public $parameters = array( array( + 'j'=>array( 'name'=>'Journal name', 'required'=>true, 'exampleValue'=>'academic-pediactrics', 'title'=>'Insert html-part of your journal' - ) - ); - } + ) + )); // Extracts the list of names from an article as string private function ExtractArticleName ($article){ @@ -59,9 +56,8 @@ class ElsevierBridge extends BridgeAbstract{ } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $uri = 'http://www.journals.elsevier.com/' . $param['j']['value'] . '/recent-articles/'; - $html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for Elsevier journal '.$param['j']['value']); + $uri = $this->uri . $this->getInput('j') . '/recent-articles/'; + $html = $this->getSimpleHTMLDOM($uri) or $this->returnServerError('No results for Elsevier journal '.$this->getInput('j')); foreach($html->find('.pod-listing') as $article){ $item = array(); diff --git a/bridges/EstCeQuonMetEnProdBridge.php b/bridges/EstCeQuonMetEnProdBridge.php index 383d7712..531d68b1 100644 --- a/bridges/EstCeQuonMetEnProdBridge.php +++ b/bridges/EstCeQuonMetEnProdBridge.php @@ -1,12 +1,10 @@ maintainer = 'ORelio'; - $this->name = 'Est-ce qu\'on met en prod aujourd\'hui ?'; - $this->uri = 'https://www.estcequonmetenprodaujourdhui.info/'; - $this->description = 'Should we put a website in production today? (French)'; - } + public $maintainer = 'ORelio'; + public $name = 'Est-ce qu\'on met en prod aujourd\'hui ?'; + public $uri = 'https://www.estcequonmetenprodaujourdhui.info/'; + public $description = 'Should we put a website in production today? (French)'; public function collectData(){ function ExtractFromDelimiters($string, $start, $end) { diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index 4c67c50e..2c179909 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -1,23 +1,21 @@ maintainer = "teromene"; - $this->name = "Facebook"; - $this->uri = "http://www.facebook.com/"; - $this->description = "Input a page title or a profile log. For a profile log, please insert the parameter as follow : myExamplePage/132621766841117"; - - $this->parameters[] =array( - 'u'=>array( + public $parameters =array( array( + 'u'=>array( 'name'=>'Username', 'required'=>true - ) - ); - } + ) + )); + + private $authorName=''; public function collectData(){ - $param=$this->parameters[$this->queriedContext]; //Extract a string using start and end delimiters function ExtractFromDelimiters($string, $start, $end) { @@ -33,7 +31,7 @@ class FacebookBridge extends BridgeAbstract{ if (is_array($matches) && count($matches) > 1) { $link = $matches[1]; if (strpos($link, '/') === 0) - $link = 'https://www.facebook.com'.$link.'"'; + $link = $this->uri.$link.'"'; if (strpos($link, 'facebook.com/l.php?u=') !== false) $link = urldecode(ExtractFromDelimiters($link, 'facebook.com/l.php?u=', '&')); return ' href="'.$link.'"'; @@ -105,14 +103,12 @@ class FacebookBridge extends BridgeAbstract{ //Retrieve page contents if (is_null($html)) { - if (isset($param['u']['value'])) { - if (!strpos($param['u']['value'], "/")) { - $html = $this->getSimpleHTMLDOM('https://www.facebook.com/'.urlencode($param['u']['value']).'?_fb_noscript=1') or $this->returnServerError('No results for this query.'); - } else { - $html = $this->getSimpleHTMLDOM('https://www.facebook.com/pages/'.$param['u']['value'].'?_fb_noscript=1') or $this->returnServerError('No results for this query.'); - } + if (!strpos($this->getInput('u'), "/")) { + $html = $this->getSimpleHTMLDOM($this->uri.urlencode($this->getInput('u')).'?_fb_noscript=1') + or $this->returnServerError('No results for this query.'); } else { - $this->returnClientError('You must specify a Facebook username.'); + $html = $this->getSimpleHTMLDOM($this->uri.'pages/'.$this->getInput('u').'?_fb_noscript=1') + or $this->returnServerError('No results for this query.'); } } @@ -127,7 +123,7 @@ class FacebookBridge extends BridgeAbstract{ foreach ($captcha->find('input, button') as $input) $captcha_fields[$input->name] = $input->value; $_SESSION['captcha_fields'] = $captcha_fields; - $_SESSION['captcha_action'] = 'https://www.facebook.com'.$captcha->find('form', 0)->action; + $_SESSION['captcha_action'] = $this->uri.$captcha->find('form', 0)->action; //Show captcha filling form to the viewer, proxying the captcha image $img = base64_encode($this->getContents($captcha->find('img', 0)->src)); @@ -149,8 +145,8 @@ class FacebookBridge extends BridgeAbstract{ if(isset($element)) { $author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext); - $profilePic = 'https://graph.facebook.com/'.$param['u']['value'].'/picture?width=200&height=200'; - $this->name = $author; + $profilePic = 'https://graph.facebook.com/'.$this->getInput('u').'/picture?width=200&height=200'; + $this->authorName = $author; foreach($element->children() as $post) { @@ -196,7 +192,7 @@ class FacebookBridge extends BridgeAbstract{ $title = substr($title, 0, strpos(wordwrap($title, 64), "\n")).'...'; //Build and add final item - $item['uri'] = 'https://facebook.com'.$post->find('abbr')[0]->parent()->getAttribute('href'); + $item['uri'] = $this->uri.$post->find('abbr')[0]->parent()->getAttribute('href'); $item['content'] = $content; $item['title'] = $title; $item['author'] = $author; @@ -207,14 +203,8 @@ class FacebookBridge extends BridgeAbstract{ } } - public function setDatas(array $param){ - if (isset($param['captcha_response']['value'])) - unset($param['captcha_response']['value']); - parent::setDatas($param); - } - public function getName() { - return (isset($this->name) ? $this->name.' - ' : '').'Facebook Bridge'; + return (isset($this->authorName) ? $this->authorName.' - ' : '').'Facebook Bridge'; } public function getCacheDuration() { diff --git a/bridges/FierPandaBridge.php b/bridges/FierPandaBridge.php index 44a792ab..b6e00744 100644 --- a/bridges/FierPandaBridge.php +++ b/bridges/FierPandaBridge.php @@ -1,14 +1,10 @@ maintainer = "snroki"; - $this->name = "Fier Panda Bridge"; - $this->uri = "http://www.fier-panda.fr/"; - $this->description = "Returns latest articles from Fier Panda."; - - } + public $maintainer = "snroki"; + public $name = "Fier Panda Bridge"; + public $uri = "http://www.fier-panda.fr/"; + public $description = "Returns latest articles from Fier Panda."; public function collectData(){ $link = 'http://www.fier-panda.fr/'; diff --git a/bridges/FlickrExploreBridge.php b/bridges/FlickrExploreBridge.php index 09f946e7..d407f769 100644 --- a/bridges/FlickrExploreBridge.php +++ b/bridges/FlickrExploreBridge.php @@ -1,14 +1,10 @@ maintainer = "sebsauvage"; - $this->name = "Flickr Explore"; - $this->uri = "https://www.flickr.com/explore"; - $this->description = "Returns the latest interesting images from Flickr"; - - } + public $maintainer = "sebsauvage"; + public $name = "Flickr Explore"; + public $uri = "https://www.flickr.com/explore"; + public $description = "Returns the latest interesting images from Flickr"; public function collectData(){ $html = $this->getSimpleHTMLDOM('https://www.flickr.com/explore') or $this->returnServerError('Could not request Flickr.'); diff --git a/bridges/FlickrTagBridge.php b/bridges/FlickrTagBridge.php index 2c6158d7..869025ed 100644 --- a/bridges/FlickrTagBridge.php +++ b/bridges/FlickrTagBridge.php @@ -1,31 +1,29 @@ maintainer = "erwang"; - $this->name = "Flickr TagUser"; - $this->uri = "http://www.flickr.com/"; - $this->description = "Returns the tagged or user images from Flickr"; + public $parameters = array( + 'By keyword' => array( + 'q'=>array('name'=>'keyword') + ), - $this->parameters["By keyword"] = array( - 'q'=>array('name'=>'keyword') - ); - - $this->parameters["By username"] = array( - 'u'=>array('name'=>'Username') - ); - } + 'By username' => array( + 'u'=>array('name'=>'Username') + ), + ); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = $this->getSimpleHTMLDOM('http://www.flickr.com/search/?q=vendee&s=rec') or $this->returnServerError('Could not request Flickr.'); - if (isset($param['q']['value'])) { /* keyword search mode */ - $this->request = $param['q']['value']; + if (isset($this->getInput('q'))) { /* keyword search mode */ + $this->request = $this->getInput('q'); $html = $this->getSimpleHTMLDOM('http://www.flickr.com/search/?q='.urlencode($this->request).'&s=rec') or $this->returnServerError('No results for this query.'); } - elseif (isset($param['u']['value'])) { /* user timeline mode */ - $this->request = $param['u']['value']; + elseif (isset($this->getInput('u'))) { /* user timeline mode */ + $this->request = $this->getInput('u'); $html = $this->getSimpleHTMLDOM('http://www.flickr.com/photos/'.urlencode($this->request).'/') or $this->returnServerError('Requested username can\'t be found.'); } diff --git a/bridges/FootitoBridge.php b/bridges/FootitoBridge.php index 326cbd50..47518853 100644 --- a/bridges/FootitoBridge.php +++ b/bridges/FootitoBridge.php @@ -1,14 +1,10 @@ maintainer = "superbaillot.net"; - $this->name = "Footito"; - $this->uri = "http://www.footito.fr/"; - $this->description = "Footito"; - - } + public $maintainer = "superbaillot.net"; + public $name = "Footito"; + public $uri = "http://www.footito.fr/"; + public $description = "Footito"; public function collectData(){ $html = $this->getSimpleHTMLDOM('http://www.footito.fr/') or $this->returnServerError('Could not request Footito.'); diff --git a/bridges/FourchanBridge.php b/bridges/FourchanBridge.php index 976d8dba..ad92ac10 100644 --- a/bridges/FourchanBridge.php +++ b/bridges/FourchanBridge.php @@ -1,26 +1,21 @@ maintainer = "mitsukarenai"; - $this->name = "4chan"; - $this->uri = "https://www.4chan.org/"; - $this->description = "Returns posts from the specified thread"; - - $this->parameters[] = array( - 't'=>array('name'=>'Thread URL') - ); - } + public $maintainer = "mitsukarenai"; + public $name = "4chan"; + public $uri = "https://www.4chan.org/"; + public $description = "Returns posts from the specified thread"; + public $parameters = array( array( + 't'=>array('name'=>'Thread URL') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - if (!isset($param['t']['value'])) + if (!isset($this->getInput('t'))) $this->returnClientError('You must specify the thread URL (?t=...)'); - $thread = parse_url($param['t']['value']) or $this->returnClientError('This URL seems malformed, please check it.'); + $thread = parse_url($this->getInput('t')) or $this->returnClientError('This URL seems malformed, please check it.'); if($thread['host'] !== 'boards.4chan.org') $this->returnClientError('4chan thread URL only.'); diff --git a/bridges/FreenewsBridge.php b/bridges/FreenewsBridge.php index 0df3c6ca..6f98069d 100644 --- a/bridges/FreenewsBridge.php +++ b/bridges/FreenewsBridge.php @@ -2,13 +2,10 @@ define("FREENEWS_RSS", 'http://feeds.feedburner.com/Freenews-Freebox?format=xml'); class FreenewsBridge extends RssExpander { - public function loadMetadatas() { - - $this->maintainer = "mitsukarenai"; - $this->name = "Freenews"; - $this->uri = "http://freenews.fr"; - $this->description = "Un site d'actualité pour les freenautes (mais ne parlant pas que de la freebox). Ne rentrez pas d'id si vous voulez accéder aux actualités générales."; - } + public $maintainer = "mitsukarenai"; + public $name = "Freenews"; + public $uri = "http://freenews.fr"; + public $description = "Un site d'actualité pour les freenautes (mais ne parlant pas que de la freebox). Ne rentrez pas d'id si vous voulez accéder aux actualités générales."; public function collectData(){ parent::collectExpandableDatas(FREENEWS_RSS); diff --git a/bridges/FuturaSciencesBridge.php b/bridges/FuturaSciencesBridge.php index 06033935..cc252b86 100644 --- a/bridges/FuturaSciencesBridge.php +++ b/bridges/FuturaSciencesBridge.php @@ -1,88 +1,84 @@ maintainer = 'ORelio'; - $this->name = 'Futura-Sciences Bridge'; - $this->uri = 'http://www.futura-sciences.com/'; - $this->description = 'Returns the newest articles.'; - - $this->parameters[] = array( - 'feed'=> array( + public $parameters = array( array( + 'feed'=> array( 'name'=>'Feed', 'type'=>'list', 'values'=>array( - 'Les flux multi-magazines'=>array( - 'Les dernières actualités de Futura-Sciences'=>'actualites', - 'Les dernières définitions de Futura-Sciences'=>'definitions', - 'Les dernières photos de Futura-Sciences'=>'photos', - 'Les dernières questions - réponses de Futura-Sciences'=>'questions-reponses', - 'Les derniers dossiers de Futura-Sciences'=>'dossiers' - ), - 'Les flux Services'=> array( - 'Les cartes virtuelles de Futura-Sciences'=>'services/cartes-virtuelles', - 'Les fonds d\'écran de Futura-Sciences'=>'services/fonds-ecran' - ), - 'Les flux Santé'=>array( - 'Les dernières actualités de Futura-Santé'=>'sante/actualites', - 'Les dernières définitions de Futura-Santé'=>'sante/definitions', - 'Les dernières questions-réponses de Futura-Santé'=>'sante/question-reponses', - 'Les derniers dossiers de Futura-Santé'=>'sante/dossiers' - ), - 'Les flux High-Tech'=>array( - 'Les dernières actualités de Futura-High-Tech'=>'high-tech/actualites', - 'Les dernières astuces de Futura-High-Tech'=>'high-tech/question-reponses', - 'Les dernières définitions de Futura-High-Tech'=>'high-tech/definitions', - 'Les derniers dossiers de Futura-High-Tech'=>'high-tech/dossiers' - ), - 'Les flux Espace'=>array( - 'Les dernières actualités de Futura-Espace'=>'espace/actualites', - 'Les dernières définitions de Futura-Espace'=>'espace/definitions', - 'Les dernières questions-réponses de Futura-Espace'=>'espace/question-reponses', - 'Les derniers dossiers de Futura-Espace'=>'espace/dossiers' - ), - 'Les flux Environnement'=>array( - 'Les dernières actualités de Futura-Environnement'=>'environnement/actualites', - 'Les dernières définitions de Futura-Environnement'=>'environnement/definitions', - 'Les dernières questions-réponses de Futura-Environnement'=>'environnement/question-reponses', - 'Les derniers dossiers de Futura-Environnement'=>'environnement/dossiers' - ), - 'Les flux Maison'=>array( - 'Les dernières actualités de Futura-Maison'=>'maison/actualites', - 'Les dernières astuces de Futura-Maison'=>'maison/question-reponses', - 'Les dernières définitions de Futura-Maison'=>'maison/definitions', - 'Les derniers dossiers de Futura-Maison'=>'maison/dossiers' - ), - 'Les flux Nature'=>array( - 'Les dernières actualités de Futura-Nature'=>'nature/actualites', - 'Les dernières définitions de Futura-Nature'=>'nature/definitions', - 'Les dernières questions-réponses de Futura-Nature'=>'nature/question-reponses', - 'Les derniers dossiers de Futura-Nature'=>'nature/dossiers' - ), - 'Les flux Terre'=>array( - 'Les dernières actualités de Futura-Terre'=>'terre/actualites', - 'Les dernières définitions de Futura-Terre'=>'terre/definitions', - 'Les dernières questions-réponses de Futura-Terre'=>'terre/question-reponses', - 'Les derniers dossiers de Futura-Terre'=>'terre/dossiers' - ), - 'Les flux Matière'=>array( - 'Les dernières actualités de Futura-Matière'=>'matiere/actualites', - 'Les dernières définitions de Futura-Matière'=>'matiere/definitions', - 'Les dernières questions-réponses de Futura-Matière'=>'matiere/question-reponses', - 'Les derniers dossiers de Futura-Matière'=>'matiere/dossiers' - ), - 'Les flux Mathématiques'=>array( - 'Les dernières actualités de Futura-Mathématiques'=>'mathematiques/actualites', - 'Les derniers dossiers de Futura-Mathématiques'=>'mathematiques/dossiers' - ) + 'Les flux multi-magazines'=>array( + 'Les dernières actualités de Futura-Sciences'=>'actualites', + 'Les dernières définitions de Futura-Sciences'=>'definitions', + 'Les dernières photos de Futura-Sciences'=>'photos', + 'Les dernières questions - réponses de Futura-Sciences'=>'questions-reponses', + 'Les derniers dossiers de Futura-Sciences'=>'dossiers' + ), + 'Les flux Services'=> array( + 'Les cartes virtuelles de Futura-Sciences'=>'services/cartes-virtuelles', + 'Les fonds d\'écran de Futura-Sciences'=>'services/fonds-ecran' + ), + 'Les flux Santé'=>array( + 'Les dernières actualités de Futura-Santé'=>'sante/actualites', + 'Les dernières définitions de Futura-Santé'=>'sante/definitions', + 'Les dernières questions-réponses de Futura-Santé'=>'sante/question-reponses', + 'Les derniers dossiers de Futura-Santé'=>'sante/dossiers' + ), + 'Les flux High-Tech'=>array( + 'Les dernières actualités de Futura-High-Tech'=>'high-tech/actualites', + 'Les dernières astuces de Futura-High-Tech'=>'high-tech/question-reponses', + 'Les dernières définitions de Futura-High-Tech'=>'high-tech/definitions', + 'Les derniers dossiers de Futura-High-Tech'=>'high-tech/dossiers' + ), + 'Les flux Espace'=>array( + 'Les dernières actualités de Futura-Espace'=>'espace/actualites', + 'Les dernières définitions de Futura-Espace'=>'espace/definitions', + 'Les dernières questions-réponses de Futura-Espace'=>'espace/question-reponses', + 'Les derniers dossiers de Futura-Espace'=>'espace/dossiers' + ), + 'Les flux Environnement'=>array( + 'Les dernières actualités de Futura-Environnement'=>'environnement/actualites', + 'Les dernières définitions de Futura-Environnement'=>'environnement/definitions', + 'Les dernières questions-réponses de Futura-Environnement'=>'environnement/question-reponses', + 'Les derniers dossiers de Futura-Environnement'=>'environnement/dossiers' + ), + 'Les flux Maison'=>array( + 'Les dernières actualités de Futura-Maison'=>'maison/actualites', + 'Les dernières astuces de Futura-Maison'=>'maison/question-reponses', + 'Les dernières définitions de Futura-Maison'=>'maison/definitions', + 'Les derniers dossiers de Futura-Maison'=>'maison/dossiers' + ), + 'Les flux Nature'=>array( + 'Les dernières actualités de Futura-Nature'=>'nature/actualites', + 'Les dernières définitions de Futura-Nature'=>'nature/definitions', + 'Les dernières questions-réponses de Futura-Nature'=>'nature/question-reponses', + 'Les derniers dossiers de Futura-Nature'=>'nature/dossiers' + ), + 'Les flux Terre'=>array( + 'Les dernières actualités de Futura-Terre'=>'terre/actualites', + 'Les dernières définitions de Futura-Terre'=>'terre/definitions', + 'Les dernières questions-réponses de Futura-Terre'=>'terre/question-reponses', + 'Les derniers dossiers de Futura-Terre'=>'terre/dossiers' + ), + 'Les flux Matière'=>array( + 'Les dernières actualités de Futura-Matière'=>'matiere/actualites', + 'Les dernières définitions de Futura-Matière'=>'matiere/definitions', + 'Les dernières questions-réponses de Futura-Matière'=>'matiere/question-reponses', + 'Les derniers dossiers de Futura-Matière'=>'matiere/dossiers' + ), + 'Les flux Mathématiques'=>array( + 'Les dernières actualités de Futura-Mathématiques'=>'mathematiques/actualites', + 'Les derniers dossiers de Futura-Mathématiques'=>'mathematiques/dossiers' + ) ) - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; function StripCDATA($string) { $string = str_replace('getURI().'rss/'.$param['feed']['value'].'.xml'; - if (empty($param['feed']['value'])) + $url = $this->getURI().'rss/'.$this->getInput('feed').'.xml'; + if (empty($this->getInput('feed'))) $this->returnClientError('Please select a feed to display.'.$url); - if ($param['feed']['value'] !== preg_replace('/[^a-zA-Z-\/]+/', '', $param['feed']['value']) || substr_count($param['feed']['value'], '/') > 1 || strlen($param['feed']['value'] > 64)) + if ($this->getInput('feed') !== preg_replace('/[^a-zA-Z-\/]+/', '', $this->getInput('feed')) || substr_count($this->getInput('feed'), '/') > 1 || strlen($this->getInput('feed') > 64)) $this->returnClientError('Invalid "feed" parameter.'.$url); $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Futura-Sciences: '.$url); diff --git a/bridges/GBAtempBridge.php b/bridges/GBAtempBridge.php index f8fc9ff0..eccd090a 100644 --- a/bridges/GBAtempBridge.php +++ b/bridges/GBAtempBridge.php @@ -1,28 +1,24 @@ maintainer = 'ORelio'; - $this->name = 'GBAtemp'; - $this->uri = 'http://gbatemp.net/'; - $this->description = 'GBAtemp is a user friendly underground video game community.'; - - $this->parameters[] = array( - 'type'=>array( + public $parameters = array( array( + 'type'=>array( 'name'=>'Type', 'type'=>'list', + 'required'=>true, 'values'=>array( - 'News'=>'N', - 'Reviews'=>'R', - 'Tutorials'=>'T', - 'Forum'=>'F' + 'News'=>'N', + 'Reviews'=>'R', + 'Tutorials'=>'T', + 'Forum'=>'F' ) - ) - ); - } + ) + )); private function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { @@ -64,21 +60,11 @@ class GBAtempBridge extends BridgeAbstract { } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $typeFilter = ''; - if (!empty($param['type']['value'])) { - if ($param['type']['value'] == 'N' || $param['type']['value'] == 'R' || $param['type']['value'] == 'T' || $param['type']['value'] == 'F') { - $typeFilter = $param['type']['value']; - if ($typeFilter == 'N') { $this->filter = 'News'; } - if ($typeFilter == 'R') { $this->filter = 'Review'; } - if ($typeFilter == 'T') { $this->filter = 'Tutorial'; } - if ($typeFilter == 'F') { $this->filter = 'Forum'; } - } else $this->returnClientError('The provided type filter is invalid. Expecting N, R, T, or F.'); - } else $this->returnClientError('Please provide a type filter. Expecting N, R, T, or F.'); $html = $this->getSimpleHTMLDOM($this->uri) or $this->returnServerError('Could not request GBAtemp.'); - if ($typeFilter == 'N') { + switch($this->getInput('type')){ + case 'N': foreach ($html->find('li[class=news_item full]') as $newsItem) { $url = $this->uri.$newsItem->find('a', 0)->href; $time = intval($this->ExtractFromDelimiters($newsItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"')); @@ -87,7 +73,7 @@ class GBAtempBridge extends BridgeAbstract { $content = $this->fetch_post_content($url, $this->uri); $this->items[] = $this->build_item($url, $title, $author, $time, $content); } - } else if ($typeFilter == 'R') { + case 'R': foreach ($html->find('li.portal_review') as $reviewItem) { $url = $this->uri.$reviewItem->find('a', 0)->href; $title = $reviewItem->find('span.review_title', 0)->plaintext; @@ -102,7 +88,7 @@ class GBAtempBridge extends BridgeAbstract { $content = $this->cleanup_post_content($intro.$review.$subheader.$procons.$scores, $this->uri); $this->items[] = $this->build_item($url, $title, $author, $time, $content); } - } else if ($typeFilter == 'T') { + case 'T': foreach ($html->find('li.portal-tutorial') as $tutorialItem) { $url = $this->uri.$tutorialItem->find('a', 0)->href; $title = $tutorialItem->find('a', 0)->plaintext; @@ -111,7 +97,7 @@ class GBAtempBridge extends BridgeAbstract { $content = $this->fetch_post_content($url, $this->uri); $this->items[] = $this->build_item($url, $title, $author, $time, $content); } - } else if ($typeFilter == 'F') { + case 'F': foreach ($html->find('li.rc_item') as $postItem) { $url = $this->uri.$postItem->find('a', 1)->href; $title = $postItem->find('a', 1)->plaintext; @@ -124,7 +110,8 @@ class GBAtempBridge extends BridgeAbstract { } public function getName() { - return 'GBAtemp'.(empty($this->filter) ? '' : ' '.$this->filter).' Bridge'; + $type=array_search($this->getInput('type'),$param['type']['values']); + return 'GBAtemp '.$type.' Bridge'; } public function getCacheDuration() { diff --git a/bridges/GawkerBridge.php b/bridges/GawkerBridge.php index ac52ae0c..69b5c31d 100644 --- a/bridges/GawkerBridge.php +++ b/bridges/GawkerBridge.php @@ -4,20 +4,17 @@ define("RSS_SUFFIX", "/full"); class GawkerBridge extends RssExpander{ - public function loadMetadatas() { + public $maintainer = "mitsukarenai"; + public $name = "Gawker media"; + public $uri = "http://feeds.gawker.com/"; + public $description = "A bridge allowing access to any of the numerous Gawker media blogs (Lifehacker, deadspin, Kotaku, Jezebel, and so on. Notice you have to give its id to find the RSS stream in gawker maze"; - $this->maintainer = "mitsukarenai"; - $this->name = "Gawker media"; - $this->uri = "http://feeds.gawker.com/"; - $this->description = "A bridge allowing access to any of the numerous Gawker media blogs (Lifehacker, deadspin, Kotaku, Jezebel, and so on. Notice you have to give its id to find the RSS stream in gawker maze"; - - $this->parameters[] = array( - 'site'=>array( - 'name'=>'site id to put in uri between feeds.gawker.com and /full .. which is obviously not full AT ALL', - 'required'=>true - ) - ); - } + public $parameters = array( array( + 'site'=>array( + 'name'=>'site id to put in uri between feeds.gawker.com and /full .. which is obviously not full AT ALL', + 'required'=>true + ) + )); private function toURI($name) { @@ -25,12 +22,11 @@ class GawkerBridge extends RssExpander{ } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - if (empty($param['site']['value'])) { + if (empty($this->getInput('site'))) { trigger_error("If no site is provided, nothing is gonna happen", E_USER_ERROR); } else { - $this->name = $param['site']['value']; - $url = $this->toURI(strtolower($param['site']['value'])); + $this->name = $this->getInput('site'); + $url = $this->toURI(strtolower($this->getInput('site'))); } $this->debugMessage("loading feed from ".$this->getURI()); parent::collectExpandableDatas($url); diff --git a/bridges/GelbooruBridge.php b/bridges/GelbooruBridge.php index 94d35949..67ec92b3 100644 --- a/bridges/GelbooruBridge.php +++ b/bridges/GelbooruBridge.php @@ -1,33 +1,28 @@ maintainer = "mitsukarenai"; - $this->name = "Gelbooru"; - $this->uri = "http://gelbooru.com/"; - $this->description = "Returns images from given page"; - - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 0; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); $page = $page - 1; $page = $page * 63; } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://gelbooru.com/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Gelbooru.'); diff --git a/bridges/GiphyBridge.php b/bridges/GiphyBridge.php index b294969b..6705a0d1 100644 --- a/bridges/GiphyBridge.php +++ b/bridges/GiphyBridge.php @@ -3,41 +3,36 @@ define('GIPHY_LIMIT', 10); class GiphyBridge extends BridgeAbstract{ - public function loadMetadatas() { + public $maintainer = "kraoc"; + public $name = "Giphy Bridge"; + public $uri = "http://giphy.com/"; + public $description = "Bridge for giphy.com"; - $this->maintainer = "kraoc"; - $this->name = "Giphy Bridge"; - $this->uri = "http://giphy.com/"; - $this->description = "Bridge for giphy.com"; - - $this->parameters[] = array( - 's'=>array('name'=>'search tag'), - 'n'=>array( - 'name'=>'max number of returned items', - 'type'=>'number' - ) - ); - - } + public $parameters = array( array( + 's'=>array('name'=>'search tag'), + 'n'=>array( + 'name'=>'max number of returned items', + 'type'=>'number' + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; $base_url = 'http://giphy.com'; - if (isset($param['s']['value'])) { /* keyword search mode */ - $html = $this->getSimpleHTMLDOM($base_url.'/search/'.urlencode($param['s']['value'].'/')) or $this->returnServerError('No results for this query.'); + if (isset($this->getInput('s'))) { /* keyword search mode */ + $html = $this->getSimpleHTMLDOM($base_url.'/search/'.urlencode($this->getInput('s').'/')) or $this->returnServerError('No results for this query.'); } else { $this->returnClientError('You must specify a search worf (?s=...).'); } $max = GIPHY_LIMIT; - if (isset($param['n']['value'])) { - $max = (integer) $param['n']['value']; + if (isset($this->getInput('n'))) { + $max = (integer) $this->getInput('n'); } $limit = 0; - $kw = urlencode($param['s']['value']); + $kw = urlencode($this->getInput('s')); foreach($html->find('div.hoverable-gif') as $entry) { if($limit < $max) { $node = $entry->first_child(); diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php index 3374ed8b..8b520e9b 100644 --- a/bridges/GithubIssueBridge.php +++ b/bridges/GithubIssueBridge.php @@ -1,13 +1,13 @@ maintainer = 'Pierre Mazière'; - $this->name = 'Github Issue'; - $this->uri = ''; - $this->description = 'Returns the issues or comments of an issue of a github project'; + public $maintainer = 'Pierre Mazière'; + public $name = 'Github Issue'; + public $uri = ''; + public $description = 'Returns the issues or comments of an issue of a github project'; - $this->parameters['global']=array ( + public $parameters=array( + 'global'=>array ( 'u'=>array( 'name'=>'User name', 'required'=>true @@ -16,25 +16,24 @@ class GithubIssueBridge extends BridgeAbstract{ 'name'=>'Project name', 'required'=>true ) - ); + ), - $this->parameters['Project Issues']=array(); - $this->parameters['Issue comments']=array( + 'Project Issues'=>array(), + 'Issue comments'=>array( 'i'=>array( 'name'=>'Issue number', 'type'=>'number', 'required'=>'true' ) - ); - } + ) + ); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $uri = 'https://github.com/'.$param['u']['value'].'/'.$param['p']['value'].'/issues/'.(isset($param['i']['value'])?$param['i']['value']:''); + $uri = 'https://github.com/'.$this->getInput('u').'/'.$this->getInput('p').'/issues/'.(isset($this->getInput('i'))?$this->getInput('i'):''); $html = $this->getSimpleHTMLDOM($uri) - or $this->returnServerError('No results for Github Issue '.$param['i']['value'].' in project '.$param['u']['value'].'/'.$param['p']['value']); + or $this->returnServerError('No results for Github Issue '.$this->getInput('i').' in project '.$this->getInput('u').'/'.$this->getInput('p')); - if(isset($param['i']['value'])){ + if(isset($this->getInput('i'))){ foreach($html->find('.js-comment-container') as $comment){ $item = array(); diff --git a/bridges/GitlabCommitsBridge.php b/bridges/GitlabCommitsBridge.php index 61c15b57..dd7af0c4 100644 --- a/bridges/GitlabCommitsBridge.php +++ b/bridges/GitlabCommitsBridge.php @@ -1,19 +1,12 @@ maintainer = 'Pierre Mazière'; - $this->name = 'Gitlab Commits'; - $this->uri = ''; - $this->description = 'Returns the commits of a project hosted on a gitlab instance'; + public $maintainer = 'Pierre Mazière'; + public $name = 'Gitlab Commits'; + public $uri = ''; + public $description = 'Returns the commits of a project hosted on a gitlab instance'; - $this->parameters[] = array( + public $parameters = array( array( 'uri'=>array( 'name'=>'Base URI', 'defaultValue'=>'https://gitlab.com' @@ -30,33 +23,31 @@ class GitlabCommitsBridge extends BridgeAbstract{ 'name'=>'Project branch', 'defaultValue'=>'master' ) - ); - } + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $uri = $param['uri']['value'].'/'.$param['u']['value'].'/'.$param['p']['value'].'/commits/'; - if(isset($param['b']['value'])){ - $uri.=$param['b']['value']; + $uri = $this->getInput('uri').'/'.$this->getInput('u').'/'.$this->getInput('p').'/commits/'; + if(isset($this->getInput('b'))){ + $uri.=$this->getInput('b'); }else{ $uri.='master'; } $html = $this->getSimpleHTMLDOM($uri) - or $this->returnServerError('No results for Gitlab Commits of project '.$param['uri']['value'].'/'.$param['u']['value'].'/'.$param['p']['value']); + or $this->returnServerError('No results for Gitlab Commits of project '.$this->getInput('uri').'/'.$this->getInput('u').'/'.$this->getInput('p')); foreach($html->find('li.commit') as $commit){ $item = array(); - $item['uri']=$param['uri']['value']; + $item['uri']=$this->getInput('uri'); foreach($commit->getElementsByTagName('a') as $a){ $classes=explode(' ',$a->getAttribute("class")); if(in_array('commit-short-id',$classes) || in_array('commit_short_id',$classes)){ $href=$a->getAttribute('href'); - $item['uri'].=substr($href,strpos($href,'/'.$param['u']['value'].'/'.$param['p']['value'])); + $item['uri'].=substr($href,strpos($href,'/'.$this->getInput('u').'/'.$this->getInput('p'))); } if(in_array('commit-row-message',$classes)){ $item['title']=$a->plaintext; diff --git a/bridges/GizmodoFRBridge.php b/bridges/GizmodoFRBridge.php index ce4e96d2..e79dcd4c 100644 --- a/bridges/GizmodoFRBridge.php +++ b/bridges/GizmodoFRBridge.php @@ -1,14 +1,10 @@ maintainer = "polopollo"; - $this->name = "GizmodoFR"; - $this->uri = "http://www.gizmodo.fr/"; - $this->description = "Returns the 15 newest posts from GizmodoFR (full text)."; - - } + public $maintainer = "polopollo"; + public $name = "GizmodoFR"; + public $uri = "http://www.gizmodo.fr/"; + public $description = "Returns the 15 newest posts from GizmodoFR (full text)."; public function collectData(){ diff --git a/bridges/GooglePlusPostBridge.php b/bridges/GooglePlusPostBridge.php index 56af4524..ad780edc 100644 --- a/bridges/GooglePlusPostBridge.php +++ b/bridges/GooglePlusPostBridge.php @@ -4,32 +4,29 @@ class GooglePlusPostBridge extends BridgeAbstract protected $_title; protected $_url; - public function loadMetadatas() { + public $maintainer = "Grummfy"; + public $name = "Google Plus Post Bridge"; + public $uri = "http://plus.google.com/"; + public $description = "Returns user public post (without API)."; - $this->maintainer = "Grummfy"; - $this->name = "Google Plus Post Bridge"; - $this->uri = "http://plus.google.com/"; - $this->description = "Returns user public post (without API)."; - - $this->parameters[] = array( - 'username'=>array( - 'name'=>'username or Id', - 'required'=>true - ) - ); - - } + public $parameters = array( array( + 'username'=>array( + 'name'=>'username or Id', + 'required'=>true + ) + )); const GOOGLE_PLUS_BASE_URL = 'https://plus.google.com/'; public function collectData() { - if (!isset($param['username']['value'])) + $param=$this->parameters[$queriedContext]; + if (!isset($this->getInput('username'))) { $this->returnClientError('You must specify a username (?username=...).'); } - $this->request = $param['username']['value']; + $this->request = $this->getInput('username'); // get content parsed // $html = $this->getSimpleHTMLDOM(__DIR__ . '/../posts2.html' $html = $this->getSimpleHTMLDOM(self::GOOGLE_PLUS_BASE_URL . urlencode($this->request) . '/posts' diff --git a/bridges/GoogleSearchBridge.php b/bridges/GoogleSearchBridge.php index 5585cea2..2c2ecac8 100644 --- a/bridges/GoogleSearchBridge.php +++ b/bridges/GoogleSearchBridge.php @@ -9,33 +9,24 @@ */ class GoogleSearchBridge extends BridgeAbstract{ - private $request; - public function loadMetadatas() { + public $maintainer = "sebsauvage"; + public $name = "Google search"; + public $uri = "https://www.google.com/"; + public $description = "Returns most recent results from Google search."; - $this->maintainer = "sebsauvage"; - $this->name = "Google search"; - $this->uri = "https://www.google.com/"; - $this->description = "Returns most recent results from Google search."; - - $this->parameters[] = array( - 'q'=>array('name'=>"keyword") - ); - - } + public $parameters = array( array( + 'q'=>array( + 'name'=>"keyword", + 'required'=>true + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['q']['value'])) { /* keyword search mode */ - $this->request = $param['q']['value']; - $html = $this->getSimpleHTMLDOM('https://www.google.com/search?q=' . urlencode($this->request) . '&num=100&complete=0&tbs=qdr:y,sbd:1') or $this->returnServerError('No results for this query.'); - } - else{ - $this->returnClientError('You must specify a keyword (?q=...).'); - } + $html = $this->getSimpleHTMLDOM('https://www.google.com/search?q=' . urlencode($this->getInput('q')) . '&num=100&complete=0&tbs=qdr:y,sbd:1') or $this->returnServerError('No results for this query.'); $emIsRes = $html->find('div[id=ires]',0); if( !is_null($emIsRes) ){ @@ -55,7 +46,7 @@ class GoogleSearchBridge extends BridgeAbstract{ } public function getName(){ - return (!empty($this->request) ? $this->request .' - ' : '') .'Google search'; + return $this->getInput('q') .' - Google search'; } public function getCacheDuration(){ diff --git a/bridges/GuruMedBridge.php b/bridges/GuruMedBridge.php index 65617559..a91e5e32 100644 --- a/bridges/GuruMedBridge.php +++ b/bridges/GuruMedBridge.php @@ -1,12 +1,10 @@ maintainer = "qwertygc"; - $this->name = "GuruMed"; - $this->uri = "http://www.gurumed.org"; - $this->description = "Returns the 5 newest posts from Gurumed (full text)"; - } + public $maintainer = "qwertygc"; + public $name = "GuruMed"; + public $uri = "http://www.gurumed.org"; + public $description = "Returns the 5 newest posts from Gurumed (full text)"; private function GurumedStripCDATA($string) { $string = str_replace('maintainer = "nel50n"; - $this->name = "HD Wallpapers Bridge"; - $this->uri = "http://www.hdwallpapers.in/"; - $this->description = "Returns the latests wallpapers from HDWallpapers"; + public $maintainer = "nel50n"; + public $name = "HD Wallpapers Bridge"; + public $uri = "http://www.hdwallpapers.in/"; + public $description = "Returns the latests wallpapers from HDWallpapers"; - $this->parameters[] = array( - 'c'=>array('name'=>'category'), - 'm'=>array('name'=>'max number of wallpapers'), - 'r'=>array( + public $parameters = array( array( + 'c'=>array('name'=>'category'), + 'm'=>array('name'=>'max number of wallpapers'), + 'r'=>array( 'name'=>'resolution', 'exampleValue'=>'1920x1200, 1680x1050,…' - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; $baseUri = 'http://www.hdwallpapers.in'; - $this->category = $param['c']['value'] ?: 'latest_wallpapers'; // Latest default - $this->resolution = $param['r']['value'] ?: '1920x1200'; // Wide wallpaper default + $this->category = $this->getInput('c') ?: 'latest_wallpapers'; // Latest default + $this->resolution = $this->getInput('r') ?: '1920x1200'; // Wide wallpaper default $category = $this->category; if (strrpos($category, 'wallpapers') !== strlen($category)-strlen('wallpapers')) { @@ -35,7 +32,7 @@ class HDWallpapersBridge extends BridgeAbstract { } $num = 0; - $max = $param['m']['value'] ?: 14; + $max = $this->getInput('m') ?: 14; $lastpage = 1; for ($page = 1; $page <= $lastpage; $page++) { diff --git a/bridges/HentaiHavenBridge.php b/bridges/HentaiHavenBridge.php index 22381924..7be61450 100644 --- a/bridges/HentaiHavenBridge.php +++ b/bridges/HentaiHavenBridge.php @@ -1,14 +1,10 @@ maintainer = "albirew"; - $this->name = "Hentai Haven"; - $this->uri = "http://hentaihaven.org/"; - $this->description = "Returns releases from Hentai Haven"; - - } + public $maintainer = "albirew"; + public $name = "Hentai Haven"; + public $uri = "http://hentaihaven.org/"; + public $description = "Returns releases from Hentai Haven"; public function collectData(){ $html = $this->getSimpleHTMLDOM('http://hentaihaven.org/') or $this->returnServerError('Could not request Hentai Haven.'); diff --git a/bridges/IdenticaBridge.php b/bridges/IdenticaBridge.php index a9d30173..d0896313 100644 --- a/bridges/IdenticaBridge.php +++ b/bridges/IdenticaBridge.php @@ -1,51 +1,39 @@ maintainer = "mitsukarenai"; - $this->name = "Identica Bridge"; - $this->uri = "https://identi.ca/"; - $this->description = "Returns user timelines"; - - $this->parameters[] = array( - 'u'=>array( - 'name'=>'username', - 'required'=>true - ) - ); - - } + public $parameters = array( array( + 'u'=>array( + 'name'=>'username', + 'required'=>true + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u']['value'])) { /* user timeline mode */ - $this->request = $param['u']['value']; - $html = $this->getSimpleHTMLDOM('https://identi.ca/'.urlencode($this->request)) or $this->returnServerError('Requested username can\'t be found.'); - } - else { - $this->returnClientError('You must specify an Identica username (?u=...).'); - } + $html = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError('Requested username can\'t be found.'); foreach($html->find('li.major') as $dent) { $item = array(); $item['uri'] = html_entity_decode($dent->find('a', 0)->href); // get dent link $item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext); // extract dent timestamp $item['content'] = trim($dent->find('div.activity-content', 0)->innertext); // extract dent text - $item['title'] = $param['u']['value'] . ' | ' . $item['content']; + $item['title'] = $this->getInput('u') . ' | ' . $item['content']; $this->items[] = $item; } } public function getName(){ - return (!empty($this->request) ? $this->request .' - ' : '') .'Identica Bridge'; + return $this->getInput('u') .' - Identica Bridge'; } public function getURI(){ - return 'https://identica.com'; + return $this->uri.urlencode($this->getInput('u')); } public function getCacheDuration(){ diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index 85709474..4551e279 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -1,31 +1,21 @@ maintainer = "pauder"; - $this->name = "Instagram Bridge"; - $this->uri = "http://instagram.com/"; - $this->description = "Returns the newest images"; - - $this->parameters[] = array( - 'u'=>array('name'=>'username') - ); - - } + public $parameters = array( array( + 'u'=>array( + 'name'=>'username', + 'required'=>true + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - $html = ''; - if (isset($param['u']['value'])) { /* user timeline mode */ - $this->request = $param['u']['value']; - $html = $this->getSimpleHTMLDOM('http://instagram.com/'.urlencode($this->request)) or $this->returnServerError('Could not request Instagram.'); - } - else { - $this->returnClientError('You must specify a Instagram username (?u=...).'); - } + $html = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError('Could not request Instagram.'); $innertext = null; @@ -71,6 +61,11 @@ class InstagramBridge extends BridgeAbstract{ } public function getName(){ - return (!empty($this->request) ? $this->request .' - ' : '') .'Instagram Bridge'; + return $this->param['u']['value'] .' - Instagram Bridge'; + } + + public function getURI(){ + return $this->uri.urlencode($this->getInput('u')); } } + diff --git a/bridges/IsoHuntBridge.php b/bridges/IsoHuntBridge.php index bfeb2fd9..8defbd86 100644 --- a/bridges/IsoHuntBridge.php +++ b/bridges/IsoHuntBridge.php @@ -1,112 +1,111 @@ maintainer = 'logmanoriginal'; - $this->name = 'isoHunt Bridge'; // Is replaced later! - $this->uri = 'https://isohunt.to'; // Is replaced later! - $this->description = 'Returns the latest results by category or search result'; + public $maintainer = 'logmanoriginal'; + public $name = 'isoHunt Bridge'; // Is replaced later! + public $uri = 'https://isohunt.to'; // Is replaced later! + public $description = 'Returns the latest results by category or search result'; + + public $parameters = array( + /* + * Get feeds for one of the "latest" categories + * Notice: The categories "News" and "Top Searches" are received from the main page + * Elements are sorted by name ascending! + */ + 'By "Latest" category' => array( + 'latest_category'=>array( + 'name'=>'Latest category', + 'type'=>'list', + 'required'=>true, + 'title'=>'Select your category', + 'defaultValue'=>'News', + 'values'=>array( + 'Hot Torrents'=>'hot_torrents', + 'News'=>'news', + 'Releases'=>'releases', + 'Torrents'=>'torrents' + ) + ) + ), /* - * Get feeds for one of the "latest" categories - * Notice: The categories "News" and "Top Searches" are received from the main page - * Elements are sorted by name ascending! - */ - $this->parameters['By "Latest" category'] = array( - 'latest_category'=>array( - 'name'=>'Latest category', - 'type'=>'list', - 'required'=>true, - 'title'=>'Select your category', - 'defaultValue'=>'News', - 'values'=>array( - 'Hot Torrents'=>'hot_torrents', - 'News'=>'news', - 'Releases'=>'releases', - 'Torrents'=>'torrents' + * Get feeds for one of the "torrent" categories + * Make sure to add new categories also to get_torrent_category_index($)! + * Elements are sorted by name ascending! + */ + 'By "Torrent" category' => array( + 'torrent_category'=>array( + 'name'=>'Torrent category', + 'type'=>'list', + 'required'=>true, + 'title'=>'Select your category', + 'defaultValue'=>'Anime', + 'values'=>array( + 'Adult'=>'adult', + 'Anime'=>'anime', + 'Books'=>'books', + 'Games'=>'games', + 'Movies'=>'movies', + 'Music'=>'music', + 'Other'=>'other', + 'Series & TV'=>'series_tv', + 'Software'=>'software' + ) + ), + 'torrent_popularity'=>array( + 'name'=>'Sort by popularity', + 'type'=>'checkbox', + 'title'=>'Activate to receive results by popularity' ) - ) - ); + ), /* - * Get feeds for one of the "torrent" categories - * Make sure to add new categories also to get_torrent_category_index($)! - * Elements are sorted by name ascending! - */ - $this->parameters['By "Torrent" category'] = array( - 'torrent_category'=>array( - 'name'=>'Torrent category', - 'type'=>'list', - 'required'=>true, - 'title'=>'Select your category', - 'defaultValue'=>'Anime', - 'values'=>array( - 'Adult'=>'adult', - 'Anime'=>'anime', - 'Books'=>'books', - 'Games'=>'games', - 'Movies'=>'movies', - 'Music'=>'music', - 'Other'=>'other', - 'Series & TV'=>'series_tv', - 'Software'=>'software' + * Get feeds for a specific search request + */ + 'Search torrent by name' => array( + 'search_name'=>array( + 'name'=>'Name', + 'required'=>true, + 'title'=>'Insert your search query', + 'exampleValue'=>'Bridge' + ), + 'search_category'=>array( + 'name'=>'Category', + 'type'=>'list', + 'title'=>'Select your category', + 'defaultValue'=>'All', + 'values'=>array( + 'Adult'=>'adult', + 'All'=>'all', + 'Anime'=>'anime', + 'Books'=>'books', + 'Games'=>'games', + 'Movies'=>'movies', + 'Music'=>'music', + 'Other'=>'other', + 'Series & TV'=>'series_tv', + 'Software'=>'software' + ) ) - ), - 'torrent_popularity'=>array( - 'name'=>'Sort by popularity', - 'type'=>'checkbox', - 'title'=>'Activate to receive results by popularity' - ) - ); - - /* - * Get feeds for a specific search request - */ - $this->parameters['Search torrent by name'] = array( - 'search_name'=>array( - 'name'=>'Name', - 'required'=>true, - 'title'=>'Insert your search query', - 'exampleValue'=>'Bridge' - ), - 'search_category'=>array( - 'name'=>'Category', - 'type'=>'list', - 'title'=>'Select your category', - 'defaultValue'=>'All', - 'values'=>array( - 'Adult'=>'adult', - 'All'=>'all', - 'Anime'=>'anime', - 'Books'=>'books', - 'Games'=>'games', - 'Movies'=>'movies', - 'Music'=>'music', - 'Other'=>'other', - 'Series & TV'=>'series_tv', - 'Software'=>'software' - ) - ) - ); - } + ) + ); public function collectData(){ - $params=$this->parameters[$this->queriedContext]; $request_path = '/'; // We'll request the main page by default - if(isset($params['latest_category']['value'])){ // Requesting one of the latest categories - $this->request_latest_category($params['latest_category']['value']); - } elseif(isset($params['torrent_category']['value'])){ // Requesting one of the torrent categories + if(isset($this->getInput('latest_category'))){ // Requesting one of the latest categories + $this->request_latest_category($this->getInput('latest_category')); + } elseif(isset($this->getInput('torrent_category'))){ // Requesting one of the torrent categories $order_popularity = false; - if(isset($params['torrent_popularity']['value'])) - $order_popularity = $params['torrent_popularity']['value']; + if(isset($this->getInput('torrent_popularity'))) + $order_popularity = $this->getInput('torrent_popularity'); - $this->request_torrent_category($params['torrent_category']['value'], $order_popularity); - } else if(isset($params['search_name']['value'])){ // Requesting search - if(isset($params['search_category']['value'])) - $this->request_search($params['search_name']['value'], $params['search_category']['value']); + $this->request_torrent_category($this->getInput('torrent_category'), $order_popularity); + } else if(isset($this->getInput('search_name'))){ // Requesting search + if(isset($this->getInput('search_category'))) + $this->request_search($this->getInput('search_name'), $this->getInput('search_category')); else - $this->request_search($params['search_name']['value']); + $this->request_search($this->getInput('search_name')); } else { $this->returnClientError('Unknown request!'); } diff --git a/bridges/JapanExpoBridge.php b/bridges/JapanExpoBridge.php index ea20592f..0a722bbc 100644 --- a/bridges/JapanExpoBridge.php +++ b/bridges/JapanExpoBridge.php @@ -1,25 +1,22 @@ maintainer = 'Ginko'; - $this->name = 'Japan Expo Actualités'; - $this->uri = 'http://www.japan-expo-paris.com/fr/actualites'; - $this->description = 'Returns most recent entries from Japan Expo actualités.'; - $this->parameters[] = array( - 'mode'=>array( + public $maintainer = 'Ginko'; + public $name = 'Japan Expo Actualités'; + public $uri = 'http://www.japan-expo-paris.com/fr/actualites'; + public $description = 'Returns most recent entries from Japan Expo actualités.'; + public $parameters = array( array( + 'mode'=>array( 'name'=>'Mode', 'type'=>'list', 'values'=>array( - 'Titles only'=>'light', - 'Full Contents'=>'full' + 'Titles only'=>'light', + 'Full Contents'=>'full' ) - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; function french_pubdate_to_timestamp($date_to_parse) { return strtotime( @@ -51,7 +48,7 @@ class JapanExpoBridge extends HttpCachingBridgeAbstract { $link = 'http://www.japan-expo-paris.com/fr/actualites'; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request JapanExpo: '.$link); - $fullcontent = (!empty($param['mode']['value']) && $param['mode']['value'] == 'full'); + $fullcontent = (!empty($this->getInput('mode')) && $this->getInput('mode') == 'full'); $count = 0; foreach ($html->find('a._tile2') as $element) { diff --git a/bridges/KonachanBridge.php b/bridges/KonachanBridge.php index 1ae4fff3..dcdb9d90 100644 --- a/bridges/KonachanBridge.php +++ b/bridges/KonachanBridge.php @@ -1,30 +1,26 @@ maintainer = "mitsukarenai"; - $this->name = "Konachan"; - $this->uri = "http://konachan.com/"; - $this->description = "Returns images from given page"; - - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 1;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://konachan.com/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Konachan.'); $input_json = explode('Post.register(', $html); diff --git a/bridges/KoreusBridge.php b/bridges/KoreusBridge.php index 66fe3733..4cb86c81 100644 --- a/bridges/KoreusBridge.php +++ b/bridges/KoreusBridge.php @@ -1,12 +1,10 @@ maintainer = "pit-fgfjiudghdf"; - $this->name = "Koreus"; - $this->uri = "http://www.koreus.com/"; - $this->description = "Returns the 5 newest posts from Koreus (full text)"; - } + public $maintainer = "pit-fgfjiudghdf"; + public $name = "Koreus"; + public $uri = "http://www.koreus.com/"; + public $description = "Returns the 5 newest posts from Koreus (full text)"; private function KoreusStripCDATA($string) { $string = str_replace('maintainer = "logmanoriginal"; - $this->name = "Kununu Bridge"; /* This will be replaced later! */ - $this->uri = "https://www.kununu.com"; /* This will be replaced later! */ - $this->description = "Returns the latest reviews for a company and site of your choice."; + public $maintainer = "logmanoriginal"; + public $name = "Kununu Bridge"; /* This will be replaced later! */ + public $uri = "https://www.kununu.com"; /* This will be replaced later! */ + public $description = "Returns the latest reviews for a company and site of your choice."; - $this->parameters['global'] = array( + public $parameters = array( + 'global' => array( 'site'=>array( 'name'=>'Site', 'type'=>'list', @@ -27,34 +27,33 @@ class KununuBridge extends HttpCachingBridgeAbstract { 'exampleValue'=>'checked', 'title'=>'Activate to load full article' ) - ); + ), - $this->parameters[] = array( + array( 'company'=>array( 'name'=>'Company', 'required'=>true, 'exampleValue'=>'kununu-us', 'title'=>'Insert company name (i.e. Kununu US) or URI path (i.e. kununu-us)' ) - ); - } + ) + ); public function collectData(){ - $params=$this->parameters[$this->queriedContext]; // Get Site - $site = strtolower(trim($params['site']['value'])); + $site = strtolower(trim($this->getInput('site'))); if(!isset($site) || empty($site) || !$this->site_is_valid($site)) $this->returnClientError('You must specify a valid site (&site=...)!'); // Get Company (fixing whitespace and umlauts) - $company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($params['company']['value'])))); + $company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($this->getInput('company'))))); if(!isset($company) || empty($company)) $this->returnClientError('You must specify a company (&company=...)!'); $full = false; // By default we'll load only short article - if(isset($params['full']['value'])) - $full = strtolower(trim($params['full']['value'])); + if(isset($this->getInput('full'))) + $full = strtolower(trim($this->getInput('full'))); // Get reviews section name (depends on site) $section = ''; diff --git a/bridges/LWNprevBridge.php b/bridges/LWNprevBridge.php index 32a79447..9e64a5cd 100644 --- a/bridges/LWNprevBridge.php +++ b/bridges/LWNprevBridge.php @@ -1,19 +1,9 @@ maintainer = 'Pierre Mazière'; - $this->name = 'LWN Free Weekly Edition'; - $this->uri = 'https://lwn.net/free/bigpage'; - $this->description = 'LWN Free Weekly Edition available one week late'; - - } + public $maintainer = 'Pierre Mazière'; + public $name = 'LWN Free Weekly Edition'; + public $uri = 'https://lwn.net/free/bigpage'; + public $description = 'LWN Free Weekly Edition available one week late'; private function jumpToNextTag(&$node){ while($node && $node->nodeType===XML_TEXT_NODE){ diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index 855600fe..3779952e 100755 --- a/bridges/LeBonCoinBridge.php +++ b/bridges/LeBonCoinBridge.php @@ -1,14 +1,12 @@ maintainer = "16mhz"; - $this->name = "LeBonCoin"; - $this->uri = "http://www.leboncoin.fr"; - $this->description = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword ."; - - $this->parameters[] = array( + public $parameters = array( array( 'k'=>array('name'=>'Mot Clé'), 'r'=>array( 'name'=>'Région', @@ -132,21 +130,18 @@ class LeBonCoinBridge extends BridgeAbstract{ ), 'AUTRES'=>'autres' ) - ) - ); - - } - + ) + ) + ); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; - if (empty($param['c']['value'])) { - $link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r']['value'] . '/?f=a&th=1&q=' . urlencode($param['k']['value']); + if (empty($this->getInput('c'))) { + $link = 'http://www.leboncoin.fr/annonces/offres/' . $this->getInput('r') . '/?f=a&th=1&q=' . urlencode($this->getInput('k')); } else { - $link = 'http://www.leboncoin.fr/' . $param['c']['value'] . '/offres/' . $param['r']['value'] . '/?f=a&th=1&q=' . urlencode($param['k']['value']); + $link = 'http://www.leboncoin.fr/' . $this->getInput('c') . '/offres/' . $this->getInput('r') . '/?f=a&th=1&q=' . urlencode($this->getInput('k')); } $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request LeBonCoin.'); diff --git a/bridges/LeJournalDuGeekBridge.php b/bridges/LeJournalDuGeekBridge.php index 19f06e19..370a1892 100644 --- a/bridges/LeJournalDuGeekBridge.php +++ b/bridges/LeJournalDuGeekBridge.php @@ -1,12 +1,10 @@ maintainer = "polopollo"; - $this->name = "journaldugeek.com (FR)"; - $this->uri = "http://www.journaldugeek.com/"; - $this->description = "Returns the 5 newest posts from LeJournalDuGeek (full text)."; - } + public $maintainer = "polopollo"; + public $name = "journaldugeek.com (FR)"; + public $uri = "http://www.journaldugeek.com/"; + public $description = "Returns the 5 newest posts from LeJournalDuGeek (full text)."; private function LeJournalDuGeekStripCDATA($string) { $string = str_replace('maintainer = "ORelio"; - $this->name = "Le Monde Informatique"; - $this->uri = "http://www.lemondeinformatique.fr/"; - $this->description = "Returns the newest articles."; - - } + public $maintainer = "ORelio"; + public $name = "Le Monde Informatique"; + public $uri = "http://www.lemondeinformatique.fr/"; + public $description = "Returns the newest articles."; public function collectData(){ diff --git a/bridges/Les400CulsBridge.php b/bridges/Les400CulsBridge.php index 2925a290..14f701b8 100644 --- a/bridges/Les400CulsBridge.php +++ b/bridges/Les400CulsBridge.php @@ -4,14 +4,10 @@ define("SEXE_FEED", "http://sexes.blogs.liberation.fr/feeds/"); class Les400CulsBridge extends RssExpander{ - public function loadMetadatas() { - - $this->maintainer = "unknown"; - $this->name = "Les 400 Culs"; - $this->uri = "http://sexes.blogs.liberation.fr"; - $this->description = "La planete sexe vue par Agnes Girard via rss-bridge"; - - } + public $maintainer = "unknown"; + public $name = "Les 400 Culs"; + public $uri = "http://sexes.blogs.liberation.fr"; + public $description = "La planete sexe vue par Agnes Girard via rss-bridge"; public function collectData(){ diff --git a/bridges/LesJoiesDuCodeBridge.php b/bridges/LesJoiesDuCodeBridge.php index d3299395..db40bff4 100644 --- a/bridges/LesJoiesDuCodeBridge.php +++ b/bridges/LesJoiesDuCodeBridge.php @@ -1,14 +1,10 @@ maintainer = "superbaillot.net"; - $this->name = "Les Joies Du Code"; - $this->uri = "http://lesjoiesducode.fr/"; - $this->description = "LesJoiesDuCode"; - - } + public $maintainer = "superbaillot.net"; + public $name = "Les Joies Du Code"; + public $uri = "http://lesjoiesducode.fr/"; + public $description = "LesJoiesDuCode"; public function collectData(){ $html = $this->getSimpleHTMLDOM('http://lesjoiesducode.fr/') or $this->returnServerError('Could not request LesJoiesDuCode.'); diff --git a/bridges/LichessBridge.php b/bridges/LichessBridge.php index 1a340053..12a178de 100644 --- a/bridges/LichessBridge.php +++ b/bridges/LichessBridge.php @@ -2,13 +2,10 @@ class LichessBridge extends HttpCachingBridgeAbstract { - public function loadMetadatas() - { - $this->maintainer = 'AmauryCarrade'; - $this->name = 'Lichess Blog'; - $this->uri = 'http://lichess.org/blog'; - $this->description = 'Returns the 5 newest posts from the Lichess blog (full text)'; - } + public $maintainer = 'AmauryCarrade'; + public $name = 'Lichess Blog'; + public $uri = 'http://lichess.org/blog'; + public $description = 'Returns the 5 newest posts from the Lichess blog (full text)'; public function collectData() { diff --git a/bridges/LinkedInCompany.php b/bridges/LinkedInCompany.php index 7640d15b..ccdf16c8 100644 --- a/bridges/LinkedInCompany.php +++ b/bridges/LinkedInCompany.php @@ -1,25 +1,21 @@ apple)"; - $this->maintainer = "regisenguehard"; - $this->name = "LinkedIn Company"; - $this->uri = "https://www.linkedin.com/"; - $this->description = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/apple)"; - - $this->parameters[] = array( - 'c'=>array( + public $parameters = array( array( + 'c'=>array( 'name'=>'Company name', 'required'=>true - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; - $link = 'https://www.linkedin.com/company/'.$param['c']['value']; + $link = 'https://www.linkedin.com/company/'.$this->getInput('c'); $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request LinkedIn.'); diff --git a/bridges/LolibooruBridge.php b/bridges/LolibooruBridge.php index 66892167..76288600 100644 --- a/bridges/LolibooruBridge.php +++ b/bridges/LolibooruBridge.php @@ -1,30 +1,26 @@ maintainer = "mitsukarenai"; - $this->name = "Lolibooru"; - $this->uri = "http://lolibooru.moe/"; - $this->description = "Returns images from given page and tags"; - - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 1; $tags = ''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://lolibooru.moe/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Lolibooru.'); $input_json = explode('Post.register(', $html); diff --git a/bridges/MangareaderBridge.php b/bridges/MangareaderBridge.php index 59cb0649..7df542d7 100644 --- a/bridges/MangareaderBridge.php +++ b/bridges/MangareaderBridge.php @@ -2,15 +2,14 @@ define('MANGAREADER_LIMIT', 10); // The default limit class MangareaderBridge extends BridgeAbstract{ - public function loadMetadatas() { + public $maintainer = "logmanoriginal"; + public $name = "Mangareader Bridge"; + public $uri = "http://www.mangareader.net"; + public $description = "Returns the latest updates, popular mangas or manga updates (new chapters)"; - $this->maintainer = "logmanoriginal"; - $this->name = "Mangareader Bridge"; - $this->uri = "http://www.mangareader.net"; - $this->description = "Returns the latest updates, popular mangas or manga updates (new chapters)"; - - $this->parameters["Get latest updates"] = array(); - $this->parameters["Get popular mangas"] = array( + public $parameters = array( + 'Get latest updates' => array(), + 'Get popular mangas' => array( 'category'=>array( 'name'=>'Category', 'type'=>'list', @@ -58,8 +57,8 @@ class MangareaderBridge extends BridgeAbstract{ 'exampleValue'=>'All', 'title'=>'Select your category' ) - ); - $this->parameters["Get manga updates"] = array( + ), + 'Get manga updates' => array( 'path'=>array( 'name'=>'Path', 'required'=>true, @@ -73,11 +72,10 @@ class MangareaderBridge extends BridgeAbstract{ 'exampleValue'=>10, 'title'=>'Number of items to return [-1 returns all]' ) - ); - } + ) + ); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $this->request = ''; @@ -85,21 +83,21 @@ class MangareaderBridge extends BridgeAbstract{ $path = "latest"; $limit = MANGAREADER_LIMIT; - if(isset($param['category']['value'])){ // Get popular updates + if(isset($this->getInput('category'))){ // Get popular updates $type = "popular"; $path = "popular"; - if($param['category']['value'] !== "all"){ - $path .= "/" . $param['category']['value']; + if($this->getInput('category') !== "all"){ + $path .= "/" . $this->getInput('category'); } } - if(isset($param['path']['value'])){ // Get manga updates + if(isset($this->getInput('path'))){ // Get manga updates $type = "path"; - $path = $param['path']['value']; + $path = $this->getInput('path'); } - if(isset($param['limit']['value']) && $param['limit']['value'] !== ""){ // Get manga updates (optional parameter) - $limit = $param['limit']['value']; + if(isset($this->getInput('limit')) && $this->getInput('limit') !== ""){ // Get manga updates (optional parameter) + $limit = $this->getInput('limit'); } // We'll use the DOM parser for this as it makes navigation easier diff --git a/bridges/MilbooruBridge.php b/bridges/MilbooruBridge.php index 58b539f8..46a84a66 100644 --- a/bridges/MilbooruBridge.php +++ b/bridges/MilbooruBridge.php @@ -1,30 +1,27 @@ maintainer = "mitsukarenai"; - $this->name = "Milbooru"; - $this->uri = "http://sheslostcontrol.net/moe/shimmie/"; - $this->description = "Returns images from given page"; + public $maintainer = "mitsukarenai"; + public $name = "Milbooru"; + public $uri = "http://sheslostcontrol.net/moe/shimmie/"; + public $description = "Returns images from given page"; - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://sheslostcontrol.net/moe/shimmie/index.php?q=/post/list/$tags/$page") or $this->returnServerError('Could not request Milbooru.'); diff --git a/bridges/MondeDiploBridge.php b/bridges/MondeDiploBridge.php index 0bbab2a2..5123ccd8 100644 --- a/bridges/MondeDiploBridge.php +++ b/bridges/MondeDiploBridge.php @@ -1,12 +1,10 @@ maintainer = "Pitchoule"; - $this->name = 'Monde Diplomatique'; - $this->uri = 'http://www.monde-diplomatique.fr'; - $this->description = "Returns most recent results from MondeDiplo."; - } + public $maintainer = "Pitchoule"; + public $name = 'Monde Diplomatique'; + public $uri = 'http://www.monde-diplomatique.fr'; + public $description = "Returns most recent results from MondeDiplo."; public function collectData(){ $html = $this->getSimpleHTMLDOM($this->uri) or $this->returnServerError('Could not request MondeDiplo. for : ' . $link); diff --git a/bridges/MsnMondeBridge.php b/bridges/MsnMondeBridge.php index e4af1374..17a8a44d 100644 --- a/bridges/MsnMondeBridge.php +++ b/bridges/MsnMondeBridge.php @@ -1,12 +1,10 @@ maintainer = "kranack"; - $this->name = 'MSN Actu Monde'; - $this->uri = 'http://www.msn.com/fr-fr/actualite/monde'; - $this->description = "Returns the 10 newest posts from MSN Actualités (full text)"; - } + public $maintainer = "kranack"; + public $name = 'MSN Actu Monde'; + public $uri = 'http://www.msn.com/fr-fr/actualite/monde'; + public $description = "Returns the 10 newest posts from MSN Actualités (full text)"; private function MsnMondeExtractContent($url, &$item) { $html2 = $this->getSimpleHTMLDOM($url); diff --git a/bridges/MspabooruBridge.php b/bridges/MspabooruBridge.php index 5a7f8a2b..5ade1855 100644 --- a/bridges/MspabooruBridge.php +++ b/bridges/MspabooruBridge.php @@ -1,33 +1,29 @@ maintainer = "mitsukarenai"; - $this->name = "Mspabooru"; - $this->uri = "http://mspabooru.com/"; - $this->description = "Returns images from given page"; + public $maintainer = "mitsukarenai"; + public $name = "Mspabooru"; + public $uri = "http://mspabooru.com/"; + public $description = "Returns images from given page"; - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); $page = $page - 1; $page = $page * 50; } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://mspabooru.com/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Mspabooru.'); diff --git a/bridges/NakedSecurityBridge.php b/bridges/NakedSecurityBridge.php index 0ad8370b..5d0fb36c 100644 --- a/bridges/NakedSecurityBridge.php +++ b/bridges/NakedSecurityBridge.php @@ -1,12 +1,10 @@ maintainer = 'ORelio'; - $this->name = 'Naked Security'; - $this->uri = 'https://nakedsecurity.sophos.com/'; - $this->description = 'Returns the newest articles.'; - } + public $maintainer = 'ORelio'; + public $name = 'Naked Security'; + public $uri = 'https://nakedsecurity.sophos.com/'; + public $description = 'Returns the newest articles.'; public function collectData(){ diff --git a/bridges/NasaApodBridge.php b/bridges/NasaApodBridge.php index 2209c4d3..c30eccfc 100644 --- a/bridges/NasaApodBridge.php +++ b/bridges/NasaApodBridge.php @@ -1,14 +1,10 @@ maintainer = "corenting"; - $this->name = "NASA APOD Bridge"; - $this->uri = "http://apod.nasa.gov/apod/astropix.html"; - $this->description = "Returns the 3 latest NASA APOD pictures and explanations"; - - } + public $maintainer = "corenting"; + public $name = "NASA APOD Bridge"; + public $uri = "http://apod.nasa.gov/apod/astropix.html"; + public $description = "Returns the 3 latest NASA APOD pictures and explanations"; public function collectData(){ diff --git a/bridges/NeuviemeArtBridge.php b/bridges/NeuviemeArtBridge.php index 0d7ae981..ff33fa1d 100644 --- a/bridges/NeuviemeArtBridge.php +++ b/bridges/NeuviemeArtBridge.php @@ -1,12 +1,10 @@ maintainer = "ORelio"; - $this->name = '9ème Art Bridge'; - $this->uri = "http://www.9emeart.fr/"; - $this->description = "Returns the newest articles."; - } + public $maintainer = "ORelio"; + public $name = '9ème Art Bridge'; + public $uri = "http://www.9emeart.fr/"; + public $description = "Returns the newest articles."; public function collectData(){ diff --git a/bridges/NextInpactBridge.php b/bridges/NextInpactBridge.php index 93b3a819..1422a315 100644 --- a/bridges/NextInpactBridge.php +++ b/bridges/NextInpactBridge.php @@ -1,12 +1,10 @@ maintainer = "qwertygc"; - $this->name = "NextInpact Bridge"; - $this->uri = "http://www.nextinpact.com/"; - $this->description = "Returns the newest articles."; - } + public $maintainer = "qwertygc"; + public $name = "NextInpact Bridge"; + public $uri = "http://www.nextinpact.com/"; + public $description = "Returns the newest articles."; private function StripCDATA($string) { $string = str_replace('maintainer = 'ORelio'; - $this->name = 'Nextgov Bridge'; - $this->uri = 'https://www.nextgov.com/'; - $this->description = 'USA Federal technology news, best practices, and web 2.0 tools.'; - - $this->parameters[] = array( - 'category'=>array( + public $parameters = array( array( + 'category'=>array( 'name'=>'Category', 'type'=>'list', 'values'=>array( - 'All'=>'all', - 'Technology News'=>'technology-news', - 'CIO Briefing'=>'cio-briefing', - 'Emerging Tech'=>'emerging-tech', - 'Cloud'=>'cloud-computing', - 'Cybersecurity'=>'cybersecurity', - 'Mobile'=>'mobile', - 'Health'=>'health', - 'Defense'=>'defense', - 'Big Data'=>'big-data' + 'All'=>'all', + 'Technology News'=>'technology-news', + 'CIO Briefing'=>'cio-briefing', + 'Emerging Tech'=>'emerging-tech', + 'Cloud'=>'cloud-computing', + 'Cybersecurity'=>'cybersecurity', + 'Mobile'=>'mobile', + 'Health'=>'health', + 'Defense'=>'defense', + 'Big Data'=>'big-data' ) - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; function ExtractFromDelimiters($string, $start, $end) { if (strpos($string, $start) !== false) { @@ -47,7 +43,7 @@ class NextgovBridge extends BridgeAbstract { } return $string; } - $category = $param['category']['value']; + $category = $this->getInput('category'); if (empty($category)) $category = 'all'; if ($category !== preg_replace('/[^a-z-]+/', '', $category) || strlen($category > 32)) diff --git a/bridges/NiceMatinBridge.php b/bridges/NiceMatinBridge.php index d56fc275..d01ef53c 100644 --- a/bridges/NiceMatinBridge.php +++ b/bridges/NiceMatinBridge.php @@ -1,12 +1,10 @@ maintainer = "pit-fgfjiudghdf"; - $this->name = "NiceMatin"; - $this->uri = "http://www.nicematin.com/"; - $this->description = "Returns the 10 newest posts from NiceMatin (full text)"; - } + public $maintainer = "pit-fgfjiudghdf"; + public $name = "NiceMatin"; + public $uri = "http://www.nicematin.com/"; + public $description = "Returns the 10 newest posts from NiceMatin (full text)"; private function NiceMatinExtractContent($url) { $html = $this->getSimpleHTMLDOM($url); diff --git a/bridges/NovelUpdatesBridge.php b/bridges/NovelUpdatesBridge.php index 84da2a9d..de69087d 100644 --- a/bridges/NovelUpdatesBridge.php +++ b/bridges/NovelUpdatesBridge.php @@ -1,25 +1,21 @@ maintainer = "albirew"; - $this->name = "Novel Updates"; - $this->uri = "http://www.novelupdates.com/"; - $this->description = "Returns releases from Novel Updates"; - $this->parameters[] = array( - 'n'=>array( + public $maintainer = "albirew"; + public $name = "Novel Updates"; + public $uri = "http://www.novelupdates.com/"; + public $description = "Returns releases from Novel Updates"; + public $parameters = array( array( + 'n'=>array( 'name'=>'Novel URL', 'required'=>true - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - if (!isset($param['n']['value'])) + if (!isset($this->getInput('n'))) $this->returnClientError('You must specify the novel URL (/series/...)'); - $thread = parse_url($param['n']['value']) or $this->returnClientError('This URL seems malformed, please check it.'); + $thread = parse_url($this->getInput('n')) or $this->returnClientError('This URL seems malformed, please check it.'); if($thread['host'] !== 'www.novelupdates.com') $this->returnClientError('NovelUpdates URL only.'); if(strpos($thread['path'], 'series/') === FALSE) diff --git a/bridges/NumeramaBridge.php b/bridges/NumeramaBridge.php index 132c1e6a..5754e573 100644 --- a/bridges/NumeramaBridge.php +++ b/bridges/NumeramaBridge.php @@ -1,14 +1,10 @@ maintainer = 'mitsukarenai'; - $this->name = 'Numerama'; - $this->uri = 'http://www.numerama.com/'; - $this->description = 'Returns the 5 newest posts from Numerama (full text)'; - - } + public $maintainer = 'mitsukarenai'; + public $name = 'Numerama'; + public $uri = 'http://www.numerama.com/'; + public $description = 'Returns the 5 newest posts from Numerama (full text)'; public function collectData(){ diff --git a/bridges/OpenClassroomsBridge.php b/bridges/OpenClassroomsBridge.php index 8f26275e..9e560f9e 100644 --- a/bridges/OpenClassroomsBridge.php +++ b/bridges/OpenClassroomsBridge.php @@ -1,43 +1,38 @@ maintainer = "sebsauvage"; - $this->name = "OpenClassrooms Bridge"; - $this->uri = "https://openclassrooms.com/"; - $this->description = "Returns latest tutorials from OpenClassrooms."; - - - $this->parameters[] = array( - 'u'=>array( + public $parameters = array( array( + 'u'=>array( 'name'=>'Catégorie', 'type'=>'list', 'values'=>array( - 'Arts & Culture'=>'arts', - 'Code'=>'code', - 'Design'=>'design', - 'Entreprise'=>'business', - 'Numérique'=>'digital', - 'Sciences'=>'sciences', - 'Sciences Humaines'=>'humainities', - 'Systèmes d\'information'=>'it', - 'Autres'=>'others' + 'Arts & Culture'=>'arts', + 'Code'=>'code', + 'Design'=>'design', + 'Entreprise'=>'business', + 'Numérique'=>'digital', + 'Sciences'=>'sciences', + 'Sciences Humaines'=>'humainities', + 'Systèmes d\'information'=>'it', + 'Autres'=>'others' ) - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - if (empty($param['u']['value'])) + if (empty($this->getInput('u'))) { $this->returnServerError('Error: You must chose a category.'); } $html = ''; - $link = 'https://openclassrooms.com/courses?categories='.$param['u']['value'].'&title=&sort=updatedAt+desc'; + $link = 'https://openclassrooms.com/courses?categories='.$this->getInput('u').'&title=&sort=updatedAt+desc'; $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request OpenClassrooms.'); diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index 345ef97d..5a1cb5cb 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -1,33 +1,27 @@ maintainer = "polo2ro"; - $this->name = "Paru Vendu Immobilier"; - $this->uri = "http://www.paruvendu.fr"; - $this->description = "Returns the ads from the first page of search result."; + public $maintainer = "polo2ro"; + public $name = "Paru Vendu Immobilier"; + public $uri = "http://www.paruvendu.fr"; + public $description = "Returns the ads from the first page of search result."; - $this->parameters[] = array( - 'minarea'=>array( + public $parameters = array( array( + 'minarea'=>array( 'name'=>'Minimal surface m²', 'type'=>'number' - ), - 'maxprice'=>array( + ), + 'maxprice'=>array( 'name'=>'Max price', 'type'=>'number' - ), - 'pa'=>array( + ), + 'pa'=>array( 'name'=>'Country code', 'exampleValue'=>'FR' - ), - 'lo'=>array('name'=>'department numbers or postal codes, comma-separated') - ); - } + ), + 'lo'=>array('name'=>'department numbers or postal codes, comma-separated') + )); public function collectData() { @@ -37,22 +31,20 @@ class ParuVenduImmoBridge extends BridgeAbstract $maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1'; $link = $this->uri.'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison; - if (isset($param['minarea']['value'])) { - $this->request .= ' '.$param['minarea']['value'].' m2'; - $link .= '&sur0='.urlencode($param['minarea']['value']); + if (isset($this->getInput('minarea'))) { + $link .= '&sur0='.urlencode($this->getInput('minarea')); } - if (isset($param['maxprice']['value'])) { - $link .= '&px1='.urlencode($param['maxprice']['value']); + if (isset($this->getInput('maxprice'))) { + $link .= '&px1='.urlencode($this->getInput('maxprice')); } - if (isset($param['pa']['value'])) { - $link .= '&pa='.urlencode($param['pa']['value']); + if (isset($this->getInput('pa'))) { + $link .= '&pa='.urlencode($this->getInput('pa')); } - if (isset($param['lo']['value'])) { - $this->request .= ' In: '.$param['lo']['value']; - $link .= '&lo='.urlencode($param['lo']['value']); + if (isset($this->getInput('lo'))) { + $link .= '&lo='.urlencode($this->getInput('lo')); } $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request paruvendu.'); @@ -88,7 +80,17 @@ class ParuVenduImmoBridge extends BridgeAbstract } public function getName(){ - return 'Paru Vendu Immobilier'.$this->request; + $request=''; + if(isset($this->getInput('minarea')) && + !empty($this->getInput('minarea')) + ){ + $request .= ' '.$this->getInput('minarea').' m2'; + } + if(isset($this->getInput('lo')) && + !empty($this->getInput('lo'))){ + $request .= ' In: '.$this->getInput('lo'); + } + return 'Paru Vendu Immobilier'.$request; } public function getCacheDuration(){ diff --git a/bridges/PickyWallpapersBridge.php b/bridges/PickyWallpapersBridge.php index b35c9c36..79cedf5c 100644 --- a/bridges/PickyWallpapersBridge.php +++ b/bridges/PickyWallpapersBridge.php @@ -5,43 +5,39 @@ class PickyWallpapersBridge extends BridgeAbstract { private $subcategory; private $resolution; - public function loadMetadatas() { + public $maintainer = "nel50n"; + public $name = "PickyWallpapers Bridge"; + public $uri = "http://www.pickywallpapers.com/"; + public $description = "Returns the latests wallpapers from PickyWallpapers"; - $this->maintainer = "nel50n"; - $this->name = "PickyWallpapers Bridge"; - $this->uri = "http://www.pickywallpapers.com/"; - $this->description = "Returns the latests wallpapers from PickyWallpapers"; - - $this->parameters[] = array( - 'c'=>array('name'=>'category'), - 's'=>array('name'=>'subcategory'), - 'm'=>array( + public $parameters = array( array( + 'c'=>array('name'=>'category'), + 's'=>array('name'=>'subcategory'), + 'm'=>array( 'name'=>'Max number of wallpapers', 'type'=>'number' - ), - 'r'=>array( + ), + 'r'=>array( 'name'=>'resolution', 'exampleValue'=>'1920x1200, 1680x1050,…', 'pattern'=>'[0-9]{3,4}x[0-9]{3,4}' - ) - ); + ) + )); - } public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; - if (!isset($param['c']['value'])) { + if (!isset($this->getInput('c'))) { $this->returnClientError('You must specify at least a category (?c=...).'); } else { $baseUri = 'http://www.pickywallpapers.com'; - $this->category = $param['c']['value']; - $this->subcategory = $param['s']['value'] ?: ''; - $this->resolution = $param['r']['value'] ?: '1920x1200'; // Wide wallpaper default + $this->category = $this->getInput('c'); + $this->subcategory = $this->getInput('s') ?: ''; + $this->resolution = $this->getInput('r') ?: '1920x1200'; // Wide wallpaper default $num = 0; - $max = $param['m']['value'] ?: 12; + $max = $this->getInput('m') ?: 12; $lastpage = 1; for ($page = 1; $page <= $lastpage; $page++) { diff --git a/bridges/PinterestBridge.php b/bridges/PinterestBridge.php index f82c7c71..91ff2b25 100644 --- a/bridges/PinterestBridge.php +++ b/bridges/PinterestBridge.php @@ -5,45 +5,42 @@ class PinterestBridge extends BridgeAbstract{ private $board; private $query; - public function loadMetadatas() { + public $maintainer = "pauder"; + public $name = "Pinterest Bridge"; + public $uri = "http://www.pinterest.com"; + public $description = "Returns the newest images on a board"; - $this->maintainer = "pauder"; - $this->name = "Pinterest Bridge"; - $this->uri = "http://www.pinterest.com"; - $this->description = "Returns the newest images on a board"; - - $this->parameters["By username and board"] = array( - 'u'=>array('name'=>'username'), - 'b'=>array('name'=>'board') - ); - - $this->parameters["From search"] = array( - 'q'=>array('name'=>'Keyword') - ); - } + public $parameters = array( + 'By username and board' => array( + 'u'=>array('name'=>'username'), + 'b'=>array('name'=>'board') + ), + 'From search' => array( + 'q'=>array('name'=>'Keyword') + ) + ); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; - if (isset($param['u']['value']) || isset($param['b']['value'])) { + if (isset($this->getInput('u')) || isset($this->getInput('b'))) { - if (empty($param['u']['value'])) + if (empty($this->getInput('u'))) { $this->returnClientError('You must specify a Pinterest username (?u=...).'); } - if (empty($param['b']['value'])) + if (empty($this->getInput('b'))) { $this->returnClientError('You must specify a Pinterest board for this username (?b=...).'); } - $this->username = $param['u']['value']; - $this->board = $param['b']['value']; + $this->username = $this->getInput('u'); + $this->board = $this->getInput('b'); $html = $this->getSimpleHTMLDOM($this->getURI().'/'.urlencode($this->username).'/'.urlencode($this->board)) or $this->returnServerError('Username and/or board not found'); - } else if (isset($param['q']['value'])) + } else if (isset($this->getInput('q'))) { - $this->query = $param['q']['value']; + $this->query = $this->getInput('q'); $html = $this->getSimpleHTMLDOM($this->getURI().'/search/?q='.urlencode($this->query)) or $this->returnServerError('Could not request Pinterest.'); } diff --git a/bridges/PlanetLibreBridge.php b/bridges/PlanetLibreBridge.php index 02e95355..bfafb48f 100644 --- a/bridges/PlanetLibreBridge.php +++ b/bridges/PlanetLibreBridge.php @@ -1,12 +1,10 @@ maintainer = "pit-fgfjiudghdf"; - $this->name = "PlanetLibre"; - $this->uri = "http://www.planet-libre.org"; - $this->description = "Returns the 5 newest posts from PlanetLibre (full text)"; - } + public $maintainer = "pit-fgfjiudghdf"; + public $name = "PlanetLibre"; + public $uri = "http://www.planet-libre.org"; + public $description = "Returns the 5 newest posts from PlanetLibre (full text)"; private function PlanetLibreExtractContent($url){ $html2 = $this->getSimpleHTMLDOM($url); diff --git a/bridges/ProjectMGameBridge.php b/bridges/ProjectMGameBridge.php index b6dacbd8..b7130a23 100644 --- a/bridges/ProjectMGameBridge.php +++ b/bridges/ProjectMGameBridge.php @@ -1,14 +1,10 @@ maintainer = "corenting"; - $this->name = "Project M Game Bridge"; - $this->uri = "http://projectmgame.com/en/"; - $this->description = "Returns the newest articles."; - - } + public $maintainer = "corenting"; + public $name = "Project M Game Bridge"; + public $uri = "http://projectmgame.com/en/"; + public $description = "Returns the newest articles."; public function collectData(){ diff --git a/bridges/RTBFBridge.php b/bridges/RTBFBridge.php index 561bcc56..2f02d4a8 100644 --- a/bridges/RTBFBridge.php +++ b/bridges/RTBFBridge.php @@ -1,28 +1,25 @@ name = "RTBF Bridge"; - $this->uri = "http://www.rtbf.be/auvio/emissions"; - $this->description = "Returns the newest RTBF videos by series ID"; - $this->maintainer = "Frenzie"; + public $name = "RTBF Bridge"; + public $uri = "http://www.rtbf.be/auvio/emissions"; + public $description = "Returns the newest RTBF videos by series ID"; + public $maintainer = "Frenzie"; - $this->parameters[] = array( - 'c'=>array( + public $parameters = array( array( + 'c'=>array( 'name'=>'series id', 'exampleValue'=>9500, 'required'=>true - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; $limit = 10; $count = 0; - if (isset($param['c']['value'])) { - $html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$param['c']['value']) or $this->returnServerError('Could not request RTBF.'); + if (isset($this->getInput('c'))) { + $html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$this->getInput('c')) or $this->returnServerError('Could not request RTBF.'); foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) { if($count < $limit) { diff --git a/bridges/Releases3DSBridge.php b/bridges/Releases3DSBridge.php index fb85fcb4..25ba50be 100644 --- a/bridges/Releases3DSBridge.php +++ b/bridges/Releases3DSBridge.php @@ -1,14 +1,10 @@ maintainer = "ORelio"; - $this->name = "3DS Scene Releases"; - $this->uri = "http://www.3dsdb.com/"; - $this->description = "Returns the newest scene releases."; - - } + public $maintainer = "ORelio"; + public $name = "3DS Scene Releases"; + public $uri = "http://www.3dsdb.com/"; + public $description = "Returns the newest scene releases."; public function collectData(){ diff --git a/bridges/ReporterreBridge.php b/bridges/ReporterreBridge.php index e3103443..8596942c 100644 --- a/bridges/ReporterreBridge.php +++ b/bridges/ReporterreBridge.php @@ -1,12 +1,10 @@ maintainer = "nyutag"; - $this->name = "Reporterre Bridge"; - $this->uri = "http://www.reporterre.net/"; - $this->description = "Returns the newest articles."; - } + public $maintainer = "nyutag"; + public $name = "Reporterre Bridge"; + public $uri = "http://www.reporterre.net/"; + public $description = "Returns the newest articles."; private function ExtractContentReporterre($url) { $html2 = $this->getSimpleHTMLDOM($url); diff --git a/bridges/Rue89Bridge.php b/bridges/Rue89Bridge.php index 39c6c4fc..978223fe 100644 --- a/bridges/Rue89Bridge.php +++ b/bridges/Rue89Bridge.php @@ -1,14 +1,10 @@ maintainer = "pit-fgfjiudghdf"; - $this->name = "Rue89"; - $this->uri = "http://rue89.nouvelobs.com/"; - $this->description = "Returns the 5 newest posts from Rue89 (full text)"; - - } + public $maintainer = "pit-fgfjiudghdf"; + public $name = "Rue89"; + public $uri = "http://rue89.nouvelobs.com/"; + public $description = "Returns the 5 newest posts from Rue89 (full text)"; private function rue89getDatas($url){ diff --git a/bridges/Rule34Bridge.php b/bridges/Rule34Bridge.php index 12c69259..6f72c230 100644 --- a/bridges/Rule34Bridge.php +++ b/bridges/Rule34Bridge.php @@ -1,33 +1,28 @@ maintainer = "mitsukarenai"; - $this->name = "Rule34"; - $this->uri = "http://rule34.xxx/"; - $this->description = "Returns images from given page"; - - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); $page = $page - 1; $page = $page * 50; } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://rule34.xxx/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Rule34.'); diff --git a/bridges/Rule34pahealBridge.php b/bridges/Rule34pahealBridge.php index 76605c66..2f24c8ad 100644 --- a/bridges/Rule34pahealBridge.php +++ b/bridges/Rule34pahealBridge.php @@ -1,31 +1,27 @@ maintainer = "mitsukarenai"; - $this->name = "Rule34paheal"; - $this->uri = "http://rule34.paheal.net/"; - $this->description = "Returns images from given page"; - - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://rule34.paheal.net/post/list/$tags/$page") or $this->returnServerError('Could not request Rule34paheal.'); diff --git a/bridges/SafebooruBridge.php b/bridges/SafebooruBridge.php index a6d98919..4fb147c0 100644 --- a/bridges/SafebooruBridge.php +++ b/bridges/SafebooruBridge.php @@ -1,33 +1,28 @@ maintainer = "mitsukarenai"; - $this->name = "Safebooru"; - $this->uri = "http://safebooru.org/"; - $this->description = "Returns images from given page"; - - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 0;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); $page = $page - 1; $page = $page * 40; } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://safebooru.org/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnServerError('Could not request Safebooru.'); diff --git a/bridges/SakugabooruBridge.php b/bridges/SakugabooruBridge.php index 2a386013..246b40af 100644 --- a/bridges/SakugabooruBridge.php +++ b/bridges/SakugabooruBridge.php @@ -1,31 +1,26 @@ maintainer = "mitsukarenai"; - $this->name = "Sakugabooru"; - $this->uri = "http://sakuga.yshi.org/"; - $this->description = "Returns images from given page"; - - $this->parameters[] = array( - 'p'=>array( + public $parameters = array( array( + 'p'=>array( 'name'=>'page', 'type'=>'number' - ), - 't'=>array('name'=>'tags') - ); - - } + ), + 't'=>array('name'=>'tags') + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $page = 1;$tags=''; - if (isset($param['p']['value'])) { - $page = (int)preg_replace("/[^0-9]/",'', $param['p']['value']); + if (isset($this->getInput('p'))) { + $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); } - if (isset($param['t']['value'])) { - $tags = urlencode($param['t']['value']); + if (isset($this->getInput('t'))) { + $tags = urlencode($this->getInput('t')); } $html = $this->getSimpleHTMLDOM("http://sakuga.yshi.org/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Sakugabooru.'); $input_json = explode('Post.register(', $html); diff --git a/bridges/ScmbBridge.php b/bridges/ScmbBridge.php index c1d6031b..9e5997e1 100644 --- a/bridges/ScmbBridge.php +++ b/bridges/ScmbBridge.php @@ -1,14 +1,10 @@ maintainer = "Astalaseven"; - $this->name = "Se Coucher Moins Bête Bridge"; - $this->uri = "http://secouchermoinsbete.fr/"; - $this->description = "Returns the newest anecdotes."; - - } + public $maintainer = "Astalaseven"; + public $name = "Se Coucher Moins Bête Bridge"; + public $uri = "http://secouchermoinsbete.fr/"; + public $description = "Returns the newest anecdotes."; public function collectData(){ $html = ''; diff --git a/bridges/ScoopItBridge.php b/bridges/ScoopItBridge.php index 6a233d44..32bdc471 100644 --- a/bridges/ScoopItBridge.php +++ b/bridges/ScoopItBridge.php @@ -1,27 +1,22 @@ maintainer = "Pitchoule"; - $this->name = "ScoopIt"; - $this->uri = "http://www.scoop.it"; - $this->description = "Returns most recent results from ScoopIt."; - - $this->parameters[] = array( - 'u'=>array( + public $parameters = array( array( + 'u'=>array( 'name'=>'keyword', 'required'=>true - ) - ); - - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; $html = ''; - if ($param['u']['value'] != '') { - $this->request = $param['u']['value']; + if ($this->getInput('u') != '') { + $this->request = $this->getInput('u'); $link = 'http://scoop.it/search?q=' .urlencode($this->request); $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request ScoopIt. for : ' . $link); diff --git a/bridges/SensCritiqueBridge.php b/bridges/SensCritiqueBridge.php index 0e44bdca..f877dcfe 100644 --- a/bridges/SensCritiqueBridge.php +++ b/bridges/SensCritiqueBridge.php @@ -1,55 +1,50 @@ maintainer = "kranack"; - $this->name = "Sens Critique"; - $this->uri = "http://www.senscritique.com"; - $this->description = "Sens Critique news"; - - $this->parameters[] = array( - 'm'=>array( + public $parameters = array( array( + 'm'=>array( 'name'=>'Movies', 'type'=>'checkbox' - ), - 's'=>array( + ), + 's'=>array( 'name'=>'Series', 'type'=>'checkbox' - ), - 'g'=>array( + ), + 'g'=>array( 'name'=>'Video Games', 'type'=>'checkbox' - ), - 'b'=>array( + ), + 'b'=>array( 'name'=>'Books', 'type'=>'checkbox' - ), - 'bd'=>array( + ), + 'bd'=>array( 'name'=>'BD', 'type'=>'checkbox' - ), - 'mu'=>array( + ), + 'mu'=>array( 'name'=>'Music', 'type'=>'checkbox' - ) - ); - } + ) + )); public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - if ((isset($param['m']['value']) && $param['m']['value'])) { + if ((isset($this->getInput('m')) && $this->getInput('m'))) { $this->collectMoviesData(); - } else if ((isset($param['s']['value']) && $param['s']['value'])) { + } else if ((isset($this->getInput('s')) && $this->getInput('s'))) { $this->collectSeriesData(); - } else if ((isset($param['g']['value']) && $param['g']['value'])) { + } else if ((isset($this->getInput('g')) && $this->getInput('g'))) { $this->collectGamesData(); - } else if ((isset($param['b']['value']) && $param['b']['value'])) { + } else if ((isset($this->getInput('b')) && $this->getInput('b'))) { $this->collectBooksData(); - } else if ((isset($param['bd']['value']) && $param['bd']['value'])) { + } else if ((isset($this->getInput('bd')) && $this->getInput('bd'))) { $this->collectBDsData(); - } else if ((isset($param['mu']['value']) && $param['mu']['value'])) { + } else if ((isset($this->getInput('mu')) && $this->getInput('mu'))) { $this->collectMusicsData(); } else { $this->returnClientError('You must choose a category'); diff --git a/bridges/Sexactu.php b/bridges/Sexactu.php index 839f6dd8..f6647b17 100644 --- a/bridges/Sexactu.php +++ b/bridges/Sexactu.php @@ -1,14 +1,10 @@ maintainer = "Riduidel"; - $this->name = "Sexactu"; - $this->uri = "http://www.gqmagazine.fr"; - $this->description = "Sexactu via rss-bridge"; - - } + public $maintainer = "Riduidel"; + public $name = "Sexactu"; + public $uri = "http://www.gqmagazine.fr"; + public $description = "Sexactu via rss-bridge"; public function collectData(){ $find = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'novembre', 'décembre'); diff --git a/bridges/ShanaprojectBridge.php b/bridges/ShanaprojectBridge.php index 5abc31f8..6c117e34 100644 --- a/bridges/ShanaprojectBridge.php +++ b/bridges/ShanaprojectBridge.php @@ -1,17 +1,15 @@ maintainer = 'logmanoriginal'; - $this->name = 'Shanaproject Bridge'; - $this->uri = 'http://www.shanaproject.com'; - $this->description = 'Returns a list of anime from the current Season Anime List'; - } + public $maintainer = 'logmanoriginal'; + public $name = 'Shanaproject Bridge'; + public $uri = 'http://www.shanaproject.com'; + public $description = 'Returns a list of anime from the current Season Anime List'; // Returns an html object for the Season Anime List (latest season) private function LoadSeasonAnimeList(){ // First we need to find the URI to the latest season from the 'seasons' page searching for 'Season Anime List' $html = $this->getSimpleHTMLDOM($this->getURI() . '/seasons'); - if(!$html) + if(!$html) $this->returnServerError('Could not load \'seasons\' page!'); $season = $html->find('div.follows_menu/a', 1); @@ -21,7 +19,7 @@ class ShanaprojectBridge extends BridgeAbstract { $html = $this->getSimpleHTMLDOM($this->getURI() . $season->href); if(!$html) $this->returnServerError('Could not load \'Season Anime List\' from \'' . $season->innertext . '\'!'); - + return $html; } @@ -72,7 +70,7 @@ class ShanaprojectBridge extends BridgeAbstract { if(preg_match("/url\(\/\/([^\)]+)\)/i", $anime->parent->style, $matches)) return $matches[1]; - + $this->returnServerError('Could not extract background image!'); } @@ -97,7 +95,7 @@ class ShanaprojectBridge extends BridgeAbstract { $animes = $html->find('div.header_display_box_info'); if(!$animes) $this->returnServerError('Could not find anime headers!'); - + foreach($animes as $anime){ $item = array(); $item['title'] = $this->ExtractAnimeTitle($anime); diff --git a/bridges/SiliconBridge.php b/bridges/SiliconBridge.php index be064688..f821bcf9 100644 --- a/bridges/SiliconBridge.php +++ b/bridges/SiliconBridge.php @@ -1,14 +1,10 @@ maintainer = "ORelio"; - $this->name = 'Silicon Bridge'; - $this->uri = 'http://www.silicon.fr/'; - $this->description = "Returns the newest articles."; - - } + public $maintainer = "ORelio"; + public $name = 'Silicon Bridge'; + public $uri = 'http://www.silicon.fr/'; + public $description = "Returns the newest articles."; public function collectData(){ diff --git a/bridges/SoundcloudBridge.php b/bridges/SoundcloudBridge.php index 407d6e4a..be22cd7c 100644 --- a/bridges/SoundcloudBridge.php +++ b/bridges/SoundcloudBridge.php @@ -1,55 +1,50 @@ maintainer = "kranack"; - $this->name = "Soundcloud Bridge"; - $this->uri = "http://www.soundcloud.com/"; - $this->description = "Returns 10 newest music from user profile"; - - $this->parameters[] = array( - 'u'=>array( + public $parameters = array( array( + 'u'=>array( 'name'=>'username', 'required'=>true - ) - ); - - } + ) + )); const CLIENT_ID = '0aca19eae3843844e4053c6d8fdb7875'; public function collectData(){ - $param=$this->parameters[$this->queriedContext]; - if (isset($param['u']['value']) && !empty($param['u']['value'])) - { - $this->request = $param['u']['value']; - - $res = json_decode($this->getContents('https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'. urlencode($this->request) .'&client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this query'); - $tracks = json_decode($this->getContents('https://api.soundcloud.com/users/'. urlencode($res->id) .'/tracks?client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this user'); - } - else - { - $this->returnClientError('You must specify username'); - } + $res = json_decode($this->getContents( + 'https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/' + . urlencode($this->getInput('u')) + .'&client_id=' . self::CLIENT_ID + )) or $this->returnServerError('No results for this query'); + $tracks = json_decode($this->getContents( + 'https://api.soundcloud.com/users/' + . urlencode($res->id) + .'/tracks?client_id=' . self::CLIENT_ID + )) or $this->returnServerError('No results for this user'); for ($i=0; $i < 10; $i++) { $item = array(); $item['author'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title; $item['title'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title; $item['content'] = '