mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 14:18:35 +01:00
[AllocineFRBridge] Automatically find the last season for every show (#2709)
The bridge now finds the last season URI by itself, and don't rely on static URL stored in the bridge itself.
This commit is contained in:
parent
fb2ed95368
commit
51f0d046d0
@ -4,7 +4,7 @@ class AllocineFRBridge extends BridgeAbstract {
|
|||||||
const MAINTAINER = 'superbaillot.net';
|
const MAINTAINER = 'superbaillot.net';
|
||||||
const NAME = 'Allo Cine Bridge';
|
const NAME = 'Allo Cine Bridge';
|
||||||
const CACHE_TIMEOUT = 25200; // 7h
|
const CACHE_TIMEOUT = 25200; // 7h
|
||||||
const URI = 'https://www.allocine.fr/';
|
const URI = 'https://www.allocine.fr';
|
||||||
const DESCRIPTION = 'Bridge for allocine.fr';
|
const DESCRIPTION = 'Bridge for allocine.fr';
|
||||||
const PARAMETERS = array( array(
|
const PARAMETERS = array( array(
|
||||||
'category' => array(
|
'category' => array(
|
||||||
@ -35,26 +35,26 @@ class AllocineFRBridge extends BridgeAbstract {
|
|||||||
if(!is_null($this->getInput('category'))) {
|
if(!is_null($this->getInput('category'))) {
|
||||||
|
|
||||||
$categories = array(
|
$categories = array(
|
||||||
'faux-raccord' => 'video/programme-12284/saison-37054/',
|
'faux-raccord' => '/video/programme-12284/',
|
||||||
'fanzone' => 'video/programme-12298/saison-37059/',
|
'fanzone' => '/video/programme-12298/',
|
||||||
'game-in-cine' => 'video/programme-12288/saison-22971/',
|
'game-in-cine' => '/video/programme-12288/',
|
||||||
'pour-la-faire-courte' => 'video/programme-20960/saison-29678/',
|
'pour-la-faire-courte' => '/video/programme-20960/',
|
||||||
'home-cinema' => 'video/programme-12287/saison-34703/',
|
'home-cinema' => '/video/programme-12287/',
|
||||||
'pils-par-ici-les-sorties' => 'video/programme-25789/saison-37253/',
|
'pils-par-ici-les-sorties' => '/video/programme-25789/',
|
||||||
'allocine-lemission-sur-lestream' => 'video/programme-25123/saison-36067/',
|
'allocine-lemission-sur-lestream' => '/video/programme-25123/',
|
||||||
'give-me-five' => 'video/programme-21919/saison-34518/',
|
'give-me-five' => '/video/programme-21919/saison-34518/',
|
||||||
'aviez-vous-remarque' => 'video/programme-19518/saison-37084/',
|
'aviez-vous-remarque' => '/video/programme-19518/',
|
||||||
'et-paf-il-est-mort' => 'video/programme-25113/saison-36657/',
|
'et-paf-il-est-mort' => '/video/programme-25113/',
|
||||||
'the-big-fan-theory' => 'video/programme-20403/saison-37419/',
|
'the-big-fan-theory' => '/video/programme-20403/',
|
||||||
'cliches' => 'video/programme-24834/saison-35591/',
|
'cliches' => '/video/programme-24834/',
|
||||||
'completement' => 'video/programme-23859/saison-34102/',
|
'completement' => '/video/programme-23859/',
|
||||||
'fun-facts' => 'video/programme-23040/saison-32686/',
|
'fun-facts' => '/video/programme-23040/',
|
||||||
'origin-story' => 'video/programme-25667/saison-37041/'
|
'origin-story' => '/video/programme-25667/'
|
||||||
);
|
);
|
||||||
|
|
||||||
$category = $this->getInput('category');
|
$category = $this->getInput('category');
|
||||||
if(array_key_exists($category, $categories)) {
|
if(array_key_exists($category, $categories)) {
|
||||||
return static::URI . $categories[$category];
|
return static::URI . $this->getLastSeasonURI($categories[$category]);
|
||||||
} else {
|
} else {
|
||||||
returnClientError('Emission inconnue');
|
returnClientError('Emission inconnue');
|
||||||
}
|
}
|
||||||
@ -63,6 +63,14 @@ class AllocineFRBridge extends BridgeAbstract {
|
|||||||
return parent::getURI();
|
return parent::getURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getLastSeasonURI($category)
|
||||||
|
{
|
||||||
|
$html = getSimpleHTMLDOMCached(static::URI . $category, 86400);
|
||||||
|
$seasonLink = $html->find('section[class=section-wrap section]', 0)->find('div[class=cf]', 0)->find('a', 0);
|
||||||
|
$URI = $seasonLink->href;
|
||||||
|
return $URI;
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
if(!is_null($this->getInput('category'))) {
|
if(!is_null($this->getInput('category'))) {
|
||||||
return self::NAME . ' : '
|
return self::NAME . ' : '
|
||||||
@ -83,12 +91,11 @@ class AllocineFRBridge extends BridgeAbstract {
|
|||||||
$this->getInput('category'),
|
$this->getInput('category'),
|
||||||
self::PARAMETERS[$this->queriedContext]['category']['values']
|
self::PARAMETERS[$this->queriedContext]['category']['values']
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($html->find('div[class=gd-col-left]', 0)->find('div[class*=video-card]') as $element) {
|
foreach($html->find('div[class=gd-col-left]', 0)->find('div[class*=video-card]') as $element) {
|
||||||
$item = array();
|
$item = array();
|
||||||
|
|
||||||
$title = $element->find('a[class*=meta-title-link]', 0);
|
$title = $element->find('a[class*=meta-title-link]', 0);
|
||||||
$content = trim($element->outertext);
|
$content = trim(defaultLinkTo($element->outertext, static::URI));
|
||||||
|
|
||||||
// Replace image 'src' with the one in 'data-src'
|
// 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('@src="data:image/gif;base64,[A-Za-z0-9+\/]*"@', '', $content);
|
||||||
@ -99,7 +106,7 @@ class AllocineFRBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
$item['content'] = $content;
|
$item['content'] = $content;
|
||||||
$item['title'] = trim($title->innertext);
|
$item['title'] = trim($title->innertext);
|
||||||
$item['uri'] = static::URI . substr($title->href, 1);
|
$item['uri'] = static::URI . '/' . substr($title->href, 1);
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user