2014-05-26 00:30:46 +02:00
|
|
|
<?php
|
|
|
|
class AllocineFRBridge extends BridgeAbstract{
|
|
|
|
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = "superbaillot.net";
|
|
|
|
const NAME = "Allo Cine Bridge";
|
2016-09-25 17:04:28 +02:00
|
|
|
const CACHE_TIMEOUT = 25200; // 7h
|
2016-09-25 12:31:58 +02:00
|
|
|
const URI = "http://www.allocine.fr/";
|
2016-08-30 11:23:55 +02:00
|
|
|
const DESCRIPTION = "Bridge for allocine.fr";
|
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'category'=>array(
|
2016-08-22 01:25:56 +02:00
|
|
|
'name'=>'category',
|
|
|
|
'type'=>'list',
|
|
|
|
'required'=>true,
|
|
|
|
'exampleValue'=>'Faux Raccord',
|
|
|
|
'title'=>'Select your category',
|
|
|
|
'values'=>array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'Faux Raccord'=>'faux-raccord',
|
|
|
|
'Top 5'=>'top-5',
|
2016-08-28 01:38:43 +02:00
|
|
|
'Tueurs en Séries'=>'tueurs-en-serie'
|
2016-08-22 01:25:56 +02:00
|
|
|
)
|
2016-08-27 21:03:26 +02:00
|
|
|
)
|
|
|
|
));
|
2016-08-10 11:41:35 +02:00
|
|
|
|
2016-08-28 01:38:43 +02:00
|
|
|
public function getURI(){
|
2016-08-28 01:25:33 +02:00
|
|
|
switch($this->getInput('category')){
|
2016-08-28 01:38:43 +02:00
|
|
|
case 'faux-raccord':
|
2016-09-25 12:28:01 +02:00
|
|
|
$uri = static::URI.'video/programme-12284/saison-27129/';
|
2016-08-28 01:38:43 +02:00
|
|
|
break;
|
|
|
|
case 'top-5':
|
2016-09-25 12:28:01 +02:00
|
|
|
$uri = static::URI.'video/programme-12299/saison-29561/';
|
2016-08-28 01:38:43 +02:00
|
|
|
break;
|
|
|
|
case 'tueurs-en-serie':
|
2016-09-01 23:52:54 +02:00
|
|
|
$uri = static::URI.'video/programme-12286/saison-22938/';
|
2016-08-28 01:38:43 +02:00
|
|
|
break;
|
2016-08-10 11:41:35 +02:00
|
|
|
}
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-28 01:38:43 +02:00
|
|
|
return $uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
2016-08-30 11:23:55 +02:00
|
|
|
return self::NAME.' : '
|
2016-08-28 01:38:43 +02:00
|
|
|
.array_search(
|
|
|
|
$this->getInput('category'),
|
2016-08-30 11:23:55 +02:00
|
|
|
self::PARAMETERS[$this->queriedContext]['category']['values']
|
2016-08-28 01:38:43 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData(){
|
|
|
|
|
2016-09-25 23:22:33 +02:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI())
|
|
|
|
or returnServerError("Could not request ".$this->getURI()." !");
|
2016-08-28 01:38:43 +02:00
|
|
|
|
|
|
|
$category=array_search(
|
|
|
|
$this->getInput('category'),
|
2016-08-30 11:23:55 +02:00
|
|
|
self::PARAMETERS[$this->queriedContext]['category']['values']
|
2016-08-28 01:38:43 +02:00
|
|
|
);
|
2016-08-10 11:41:35 +02:00
|
|
|
|
2014-05-26 00:30:46 +02:00
|
|
|
|
|
|
|
foreach($html->find('figure.media-meta-fig') as $element)
|
|
|
|
{
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-10 11:41:35 +02:00
|
|
|
$title = $element->find('div.titlebar h3.title a', 0);
|
2014-05-26 00:30:46 +02:00
|
|
|
$content = trim($element->innertext);
|
2016-08-10 11:41:35 +02:00
|
|
|
$figCaption = strpos($content, $category);
|
|
|
|
|
2014-05-26 00:30:46 +02:00
|
|
|
if($figCaption !== false)
|
|
|
|
{
|
2016-09-01 23:52:54 +02:00
|
|
|
$content = str_replace('src="/', 'src="'.static::URI, $content);
|
|
|
|
$content = str_replace('href="/', 'href="'.static::URI, $content);
|
|
|
|
$content = str_replace('src=\'/', 'src=\''.static::URI, $content);
|
|
|
|
$content = str_replace('href=\'/', 'href=\''.static::URI, $content);
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['content'] = $content;
|
|
|
|
$item['title'] = trim($title->innertext);
|
2016-09-01 23:52:54 +02:00
|
|
|
$item['uri'] = static::URI . $title->href;
|
2014-05-26 00:30:46 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|