|
@@ -3,7 +3,7 @@ class SensCritiqueBridge extends BridgeAbstract {
|
|
|
|
|
|
public $maintainer = "kranack";
|
|
|
public $name = "Sens Critique";
|
|
|
- public $uri = "http://www.senscritique.com";
|
|
|
+ public $uri = "http://www.senscritique.com/";
|
|
|
public $description = "Sens Critique news";
|
|
|
|
|
|
public $parameters = array( array(
|
|
@@ -34,71 +34,27 @@ class SensCritiqueBridge extends BridgeAbstract {
|
|
|
));
|
|
|
|
|
|
public function collectData(){
|
|
|
- if (($this->getInput('m') && $this->getInput('m'))) {
|
|
|
- $this->collectMoviesData();
|
|
|
- } else if (($this->getInput('s') && $this->getInput('s'))) {
|
|
|
- $this->collectSeriesData();
|
|
|
- } else if (($this->getInput('g') && $this->getInput('g'))) {
|
|
|
- $this->collectGamesData();
|
|
|
- } else if (($this->getInput('b') && $this->getInput('b'))) {
|
|
|
- $this->collectBooksData();
|
|
|
- } else if (($this->getInput('bd') && $this->getInput('bd'))) {
|
|
|
- $this->collectBDsData();
|
|
|
- } else if (($this->getInput('mu') && $this->getInput('mu'))) {
|
|
|
- $this->collectMusicsData();
|
|
|
- } else {
|
|
|
- $this->returnClientError('You must choose a category');
|
|
|
- }
|
|
|
+ $categories=array();
|
|
|
+ foreach($this->parameters[$this->queriedContext] as $category=>$properties){
|
|
|
+ if($this->getInput($category)){
|
|
|
+ $uri=$this->uri;
|
|
|
+ switch($category){
|
|
|
+ case 'm': $uri.='films/cette-semaine'; break;
|
|
|
+ case 's': $uri.='series/actualite'; break;
|
|
|
+ case 'g': $uri.='jeuxvideo/actualite'; break;
|
|
|
+ case 'b': $uri.='livres/actualite'; break;
|
|
|
+ case 'bd': $uri.='bd/actualite'; break;
|
|
|
+ case 'mu': $uri.='musique/actualite'; break;
|
|
|
+ }
|
|
|
+ $html = $this->getSimpleHTMLDOM($uri)
|
|
|
+ or $this->returnServerError('No results for this query.');
|
|
|
+ $list = $html->find('ul.elpr-list', 0);
|
|
|
+
|
|
|
+ $this->extractDataFromList($list);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private function collectMoviesData() {
|
|
|
- $html = '';
|
|
|
- $html = $this->getSimpleHTMLDOM('http://www.senscritique.com/films/cette-semaine') or $this->returnServerError('No results for this query.');
|
|
|
- $list = $html->find('ul.elpr-list', 0);
|
|
|
-
|
|
|
- $this->extractDataFromList($list);
|
|
|
- }
|
|
|
-
|
|
|
- private function collectSeriesData() {
|
|
|
- $html = '';
|
|
|
- $html = $this->getSimpleHTMLDOM('http://www.senscritique.com/series/actualite') or $this->returnServerError('No results for this query.');
|
|
|
- $list = $html->find('ul.elpr-list', 0);
|
|
|
-
|
|
|
- $this->extractDataFromList($list);
|
|
|
- }
|
|
|
-
|
|
|
- private function collectGamesData() {
|
|
|
- $html = '';
|
|
|
- $html = $this->getSimpleHTMLDOM('http://www.senscritique.com/jeuxvideo/actualite') or $this->returnServerError('No results for this query.');
|
|
|
- $list = $html->find('ul.elpr-list', 0);
|
|
|
-
|
|
|
- $this->extractDataFromList($list);
|
|
|
- }
|
|
|
-
|
|
|
- private function collectBooksData() {
|
|
|
- $html = '';
|
|
|
- $html = $this->getSimpleHTMLDOM('http://www.senscritique.com/livres/actualite') or $this->returnServerError('No results for this query.');
|
|
|
- $list = $html->find('ul.elpr-list', 0);
|
|
|
-
|
|
|
- $this->extractDataFromList($list);
|
|
|
- }
|
|
|
-
|
|
|
- private function collectBDsData() {
|
|
|
- $html = '';
|
|
|
- $html = $this->getSimpleHTMLDOM('http://www.senscritique.com/bd/actualite') or $this->returnServerError('No results for this query.');
|
|
|
- $list = $html->find('ul.elpr-list', 0);
|
|
|
-
|
|
|
- $this->extractDataFromList($list);
|
|
|
- }
|
|
|
-
|
|
|
- private function collectMusicsData() {
|
|
|
- $html = '';
|
|
|
- $html = $this->getSimpleHTMLDOM('http://www.senscritique.com/musique/actualite') or $this->returnServerError('No results for this query.');
|
|
|
- $list = $html->find('ul.elpr-list', 0);
|
|
|
-
|
|
|
- $this->extractDataFromList($list);
|
|
|
- }
|
|
|
-
|
|
|
private function extractDataFromList($list) {
|
|
|
if ($list === null) {
|
|
|
$this->returnClientError('Cannot extract data from list');
|