2014-05-26 02:30:46 +04:00
|
|
|
<?php
|
2017-02-11 18:16:56 +03:00
|
|
|
class AllocineFRBridge extends BridgeAbstract {
|
|
|
|
|
|
|
|
const MAINTAINER = 'superbaillot.net';
|
|
|
|
const NAME = 'Allo Cine Bridge';
|
|
|
|
const CACHE_TIMEOUT = 25200; // 7h
|
|
|
|
const URI = 'http://www.allocine.fr/';
|
|
|
|
const DESCRIPTION = 'Bridge for allocine.fr';
|
|
|
|
const PARAMETERS = array( array(
|
|
|
|
'category' => array(
|
2020-02-27 00:12:25 +03:00
|
|
|
'name' => 'Emission',
|
2017-02-11 18:16:56 +03:00
|
|
|
'type' => 'list',
|
2020-02-27 00:12:25 +03:00
|
|
|
'title' => 'Sélectionner l\'emission',
|
2017-02-11 18:16:56 +03:00
|
|
|
'values' => array(
|
|
|
|
'Faux Raccord' => 'faux-raccord',
|
2020-02-27 00:12:25 +03:00
|
|
|
'Fanzone' => 'fanzone',
|
|
|
|
'Game In Ciné' => 'game-in-cine',
|
|
|
|
'Pour la faire courte' => 'pour-la-faire-courte',
|
|
|
|
'Home Cinéma' => 'home-cinema',
|
|
|
|
'PILS - Par Ici Les Sorties' => 'pils-par-ici-les-sorties',
|
|
|
|
'AlloCiné : l\'émission, sur LeStream' => 'allocine-lemission-sur-lestream',
|
|
|
|
'Give Me Five' => 'give-me-five',
|
|
|
|
'Aviez-vous remarqué ?' => 'aviez-vous-remarque',
|
|
|
|
'Et paf, il est mort' => 'et-paf-il-est-mort',
|
|
|
|
'The Big Fan Theory' => 'the-big-fan-theory',
|
|
|
|
'Clichés' => 'cliches',
|
|
|
|
'Complètement...' => 'completement',
|
|
|
|
'#Fun Facts' => 'fun-facts',
|
|
|
|
'Origin Story' => 'origin-story',
|
2017-02-11 18:16:56 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
public function getURI(){
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!is_null($this->getInput('category'))) {
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2020-02-27 00:12:25 +03:00
|
|
|
$categories = array(
|
|
|
|
'faux-raccord' => 'video/programme-12284/saison-37054/',
|
|
|
|
'fanzone' => 'video/programme-12298/saison-37059/',
|
|
|
|
'game-in-cine' => 'video/programme-12288/saison-22971/',
|
|
|
|
'pour-la-faire-courte' => 'video/programme-20960/saison-29678/',
|
|
|
|
'home-cinema' => 'video/programme-12287/saison-34703/',
|
|
|
|
'pils-par-ici-les-sorties' => 'video/programme-25789/saison-37253/',
|
|
|
|
'allocine-lemission-sur-lestream' => 'video/programme-25123/saison-36067/',
|
|
|
|
'give-me-five' => 'video/programme-21919/saison-34518/',
|
|
|
|
'aviez-vous-remarque' => 'video/programme-19518/saison-37084/',
|
|
|
|
'et-paf-il-est-mort' => 'video/programme-25113/saison-36657/',
|
|
|
|
'the-big-fan-theory' => 'video/programme-20403/saison-37419/',
|
|
|
|
'cliches' => 'video/programme-24834/saison-35591/',
|
|
|
|
'completement' => 'video/programme-23859/saison-34102/',
|
|
|
|
'fun-facts' => 'video/programme-23040/saison-32686/',
|
|
|
|
'origin-story' => 'video/programme-25667/saison-37041/'
|
|
|
|
);
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2020-02-27 00:12:25 +03:00
|
|
|
$category = $this->getInput('category');
|
|
|
|
if(array_key_exists($category, $categories)) {
|
|
|
|
return static::URI . $categories[$category];
|
|
|
|
} else {
|
|
|
|
returnClientError('Emission inconnue');
|
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getURI();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!is_null($this->getInput('category'))) {
|
2017-02-15 00:20:55 +03:00
|
|
|
return self::NAME . ' : '
|
2018-11-05 14:55:58 +03:00
|
|
|
. array_search(
|
2017-02-15 00:20:55 +03:00
|
|
|
$this->getInput('category'),
|
|
|
|
self::PARAMETERS[$this->queriedContext]['category']['values']
|
|
|
|
);
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData(){
|
|
|
|
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI());
|
2017-02-11 18:16:56 +03:00
|
|
|
|
|
|
|
$category = array_search(
|
|
|
|
$this->getInput('category'),
|
|
|
|
self::PARAMETERS[$this->queriedContext]['category']['values']
|
|
|
|
);
|
|
|
|
|
2020-09-08 08:55:21 +03:00
|
|
|
foreach($html->find('div[class=gd-col-left]', 0)->find('div[class*=video-card]') as $element) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$item = array();
|
|
|
|
|
2020-02-27 00:12:25 +03:00
|
|
|
$title = $element->find('a[class*=meta-title-link]', 0);
|
|
|
|
$content = trim($element->outertext);
|
2017-02-11 18:16:56 +03:00
|
|
|
|
2020-02-27 00:12:25 +03:00
|
|
|
// Replace image 'src' with the one in 'data-src'
|
|
|
|
$content = preg_replace('@src="data:image/gif;base64,[A-Za-z0-9+\/]*"@', '', $content);
|
|
|
|
$content = preg_replace('@data-src=@', 'src=', $content);
|
|
|
|
|
|
|
|
// Remove date in the content to prevent content update while the video is getting older
|
|
|
|
$content = preg_replace('@<div class="meta-sub light">.*<span>[^<]*</span>[^<]*</div>@', '', $content);
|
|
|
|
|
|
|
|
$item['content'] = $content;
|
|
|
|
$item['title'] = trim($title->innertext);
|
|
|
|
$item['uri'] = static::URI . substr($title->href, 1);
|
|
|
|
$this->items[] = $item;
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
|
|
|
}
|
2014-05-26 02:30:46 +04:00
|
|
|
}
|