2014-03-26 16:22:31 +01:00
|
|
|
<?php
|
2016-08-24 19:06:07 +02:00
|
|
|
class WorldOfTanksBridge extends HttpCachingBridgeAbstract{
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-27 21:03:26 +02:00
|
|
|
public $maintainer = "mitsukarenai";
|
|
|
|
public $name = "World of Tanks";
|
|
|
|
public $uri = "http://worldoftanks.eu/";
|
|
|
|
public $description = "News about the tank slaughter game.";
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-27 21:03:26 +02:00
|
|
|
public $parameters = array( array(
|
|
|
|
'category'=>array(
|
|
|
|
// TODO: should be a list
|
|
|
|
'name'=>'nom de la catégorie'
|
|
|
|
),
|
|
|
|
'lang'=>array(
|
2016-08-22 01:25:56 +02:00
|
|
|
'name'=>'Langue',
|
|
|
|
'type'=>'list',
|
|
|
|
'values'=>array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'Français'=>'fr',
|
|
|
|
'English'=>'en',
|
|
|
|
'Español'=>'es',
|
|
|
|
'Deutsch'=>'de',
|
|
|
|
'Čeština'=>'cs',
|
|
|
|
'Polski'=>'pl',
|
|
|
|
'Türkçe'=>'tr'
|
2016-08-22 01:25:56 +02:00
|
|
|
)
|
2016-08-27 21:03:26 +02:00
|
|
|
)
|
|
|
|
));
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-25 17:15:52 +02:00
|
|
|
function getURI(){
|
|
|
|
$lang='fr';
|
2016-08-28 01:25:33 +02:00
|
|
|
if (!empty($this->getInput('lang'))) {
|
|
|
|
$lang = $this->getInput('lang');
|
2014-03-26 16:22:31 +01:00
|
|
|
}
|
2016-08-25 17:15:52 +02:00
|
|
|
|
|
|
|
$uri = $this->uri.$lang.'/news/';
|
2016-08-28 01:25:33 +02:00
|
|
|
if(!empty($this->getInput('category'))) {
|
|
|
|
$uri .= 'pc-browser/'.$this->getInput('category')."/";
|
2014-03-26 16:22:31 +01:00
|
|
|
}
|
2016-08-25 17:15:52 +02:00
|
|
|
return $uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData(){
|
2016-07-08 19:06:35 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request '.$this->getURI());
|
2016-08-24 20:19:30 +02:00
|
|
|
$this->debugMessage("loaded HTML from ".$this->getURI());
|
2016-07-08 19:06:35 +02:00
|
|
|
// customize name
|
2014-03-26 16:22:31 +01:00
|
|
|
$this->name = $html->find('title', 0)->innertext;
|
|
|
|
foreach($html->find('.b-imgblock_ico') as $infoLink) {
|
|
|
|
$this->parseLine($infoLink);
|
|
|
|
}
|
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-06 16:00:56 +02:00
|
|
|
private function parseLine($infoLink) {
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-08-25 17:15:52 +02:00
|
|
|
$item['uri'] = $this->uri.$infoLink->href;
|
2014-03-26 16:22:31 +01:00
|
|
|
// now load that uri from cache
|
2016-08-24 20:19:30 +02:00
|
|
|
$this->debugMessage("loading page ".$item['uri']);
|
2016-08-22 18:55:59 +02:00
|
|
|
$articlePage = str_get_html($this->get_cached($item['uri']));
|
2014-03-26 16:22:31 +01:00
|
|
|
$content = $articlePage->find('.l-content', 0);
|
2016-08-25 17:15:52 +02:00
|
|
|
HTMLSanitizer::defaultImageSrcTo($content, $this->uri);
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['title'] = $content->find('h1', 0)->innertext;
|
|
|
|
$item['content'] = $content->find('.b-content', 0)->innertext;
|
|
|
|
$item['timestamp'] = $content->find('.b-statistic_time', 0)->getAttribute("data-timestamp");
|
2014-03-26 16:22:31 +01:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|