2016-07-30 17:16:02 +03:00
|
|
|
<?php
|
|
|
|
class SensCritiqueBridge extends BridgeAbstract {
|
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
const MAINTAINER = 'kranack';
|
|
|
|
const NAME = 'Sens Critique';
|
2020-05-20 22:52:37 +03:00
|
|
|
const URI = 'https://www.senscritique.com/';
|
2016-09-25 18:04:28 +03:00
|
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
2017-02-11 18:16:56 +03:00
|
|
|
const DESCRIPTION = 'Sens Critique news';
|
2016-07-30 17:16:02 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
const PARAMETERS = array( array(
|
|
|
|
's' => array(
|
|
|
|
'name' => 'Series',
|
|
|
|
'type' => 'checkbox'
|
|
|
|
),
|
|
|
|
'g' => array(
|
|
|
|
'name' => 'Video Games',
|
|
|
|
'type' => 'checkbox'
|
|
|
|
),
|
|
|
|
'b' => array(
|
|
|
|
'name' => 'Books',
|
|
|
|
'type' => 'checkbox'
|
|
|
|
),
|
|
|
|
'bd' => array(
|
|
|
|
'name' => 'BD',
|
|
|
|
'type' => 'checkbox'
|
|
|
|
),
|
|
|
|
'mu' => array(
|
|
|
|
'name' => 'Music',
|
|
|
|
'type' => 'checkbox'
|
|
|
|
)
|
|
|
|
));
|
2016-07-30 17:16:02 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2017-02-11 18:16:56 +03:00
|
|
|
$categories = array();
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach(self::PARAMETERS[$this->queriedContext] as $category => $properties) {
|
|
|
|
if($this->getInput($category)) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$uri = self::URI;
|
2017-07-29 20:28:00 +03:00
|
|
|
switch($category) {
|
2017-02-11 18:16:56 +03:00
|
|
|
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;
|
|
|
|
}
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOM($uri);
|
2017-02-11 18:16:56 +03:00
|
|
|
$list = $html->find('ul.elpr-list', 0);
|
2016-08-29 23:53:38 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
$this->extractDataFromList($list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-30 17:16:02 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
private function extractDataFromList($list){
|
2017-07-29 20:28:00 +03:00
|
|
|
if($list === null) {
|
2016-09-26 00:22:33 +03:00
|
|
|
returnClientError('Cannot extract data from list');
|
2016-07-30 17:16:02 +03:00
|
|
|
}
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($list->find('li') as $movie) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$item = array();
|
|
|
|
$item['author'] = htmlspecialchars_decode($movie->find('.elco-title a', 0)->plaintext, ENT_QUOTES)
|
|
|
|
. ' '
|
|
|
|
. $movie->find('.elco-date', 0)->plaintext;
|
|
|
|
|
|
|
|
$item['title'] = $movie->find('.elco-title a', 0)->plaintext
|
|
|
|
. ' '
|
|
|
|
. $movie->find('.elco-date', 0)->plaintext;
|
|
|
|
|
2020-05-20 22:52:37 +03:00
|
|
|
$item['content'] = '';
|
|
|
|
$originalTitle = $movie->find('.elco-original-title', 0);
|
|
|
|
$description = $movie->find('.elco-description', 0);
|
|
|
|
|
|
|
|
if ($originalTitle) {
|
|
|
|
$item['content'] = '<em>' . $originalTitle->plaintext . '</em><br><br>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$item['content'] .= $movie->find('.elco-baseline', 0)->plaintext
|
2017-02-11 18:16:56 +03:00
|
|
|
. '<br>'
|
|
|
|
. $movie->find('.elco-baseline', 1)->plaintext
|
|
|
|
. '<br><br>'
|
2020-05-20 22:52:37 +03:00
|
|
|
. ($description ? $description->plaintext : '')
|
2017-02-11 18:16:56 +03:00
|
|
|
. '<br><br>'
|
|
|
|
. trim($movie->find('.erra-ratings .erra-global', 0)->plaintext)
|
|
|
|
. ' / 10';
|
|
|
|
|
2020-05-20 22:52:37 +03:00
|
|
|
$item['id'] = $this->getURI() . ltrim($movie->find('.elco-title a', 0)->href, '/');
|
|
|
|
$item['uri'] = $this->getURI() . ltrim($movie->find('.elco-title a', 0)->href, '/');
|
2017-02-11 18:16:56 +03:00
|
|
|
$this->items[] = $item;
|
2016-07-30 17:16:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|