2014-05-31 18:58:56 +02:00
|
|
|
<?php
|
2016-08-02 15:40:07 +02:00
|
|
|
class DauphineLibereBridge extends BridgeAbstract {
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-02 15:40:07 +02:00
|
|
|
public function loadMetadatas() {
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-02 15:40:07 +02:00
|
|
|
$this->maintainer = "qwertygc";
|
|
|
|
$this->name = "DauphineLibereBridge Bridge";
|
|
|
|
$this->uri = "http://www.ledauphine.com/";
|
|
|
|
$this->description = "Returns the newest articles.";
|
|
|
|
$this->update = "2016-08-02";
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-02 15:40:07 +02:00
|
|
|
$this->parameters[] =
|
|
|
|
'[
|
|
|
|
{
|
|
|
|
"name" : "Catégorie de l\'article",
|
|
|
|
"identifier" : "u",
|
|
|
|
"type" : "list",
|
|
|
|
"values" : [
|
|
|
|
{
|
|
|
|
"name" : "À la une",
|
|
|
|
"value" : ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "France Monde",
|
|
|
|
"value" : "france-monde"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Faits Divers",
|
|
|
|
"value" : "faits-divers"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Économie et Finance",
|
|
|
|
"value" : "economie-et-finance"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Politique",
|
|
|
|
"value" : "politique"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Sport",
|
|
|
|
"value" : "sport"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Ain",
|
|
|
|
"value" : "ain"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Alpes-de-Haute-Provence",
|
|
|
|
"value" : "haute-provence"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Hautes-Alpes",
|
|
|
|
"value" : "hautes-alpes"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Ardèche",
|
|
|
|
"value" : "ardeche"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Drôme",
|
|
|
|
"value" : "drome"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Isère Sud",
|
|
|
|
"value" : "isere-sud"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Savoie",
|
|
|
|
"value" : "savoie"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Haute-Savoie",
|
|
|
|
"value" : "haute-savoie"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "Vaucluse",
|
|
|
|
"value" : "vaucluse"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]';
|
|
|
|
}
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-02 15:40:07 +02:00
|
|
|
function ExtractContent($url) {
|
2016-06-25 23:17:42 +02:00
|
|
|
$html2 = $this->file_get_html($url);
|
2014-05-31 18:58:56 +02:00
|
|
|
$text = $html2->find('div.column', 0)->innertext;
|
|
|
|
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
|
|
|
|
return $text;
|
2016-08-02 15:40:07 +02:00
|
|
|
}
|
2016-08-02 15:31:55 +02:00
|
|
|
|
2016-08-02 15:40:07 +02:00
|
|
|
public function collectData(array $param){
|
2016-08-02 15:31:55 +02:00
|
|
|
|
2014-05-31 18:58:56 +02:00
|
|
|
if (isset($param['u'])) { /* user timeline mode */
|
|
|
|
$this->request = $param['u'];
|
2016-06-25 23:17:42 +02:00
|
|
|
$html = $this->file_get_html('http://www.ledauphine.com/'.$this->request.'/rss') or $this->returnError('Could not request DauphineLibere.', 404);
|
2014-05-31 18:58:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2016-06-25 23:17:42 +02:00
|
|
|
$html = $this->file_get_html('http://www.ledauphine.com/rss') or $this->returnError('Could not request DauphineLibere.', 404);
|
2014-05-31 18:58:56 +02:00
|
|
|
}
|
|
|
|
$limit = 0;
|
|
|
|
|
|
|
|
foreach($html->find('item') as $element) {
|
2016-08-02 15:40:07 +02:00
|
|
|
if($limit < 10) {
|
|
|
|
$item = new \Item();
|
|
|
|
$item->title = $element->find('title', 0)->innertext;
|
|
|
|
$item->uri = $element->find('guid', 0)->plaintext;
|
|
|
|
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
|
|
|
|
$item->content = $this->ExtractContent($item->uri);
|
|
|
|
$this->items[] = $item;
|
|
|
|
$limit++;
|
|
|
|
}
|
2014-05-31 18:58:56 +02:00
|
|
|
}
|
2016-08-02 15:40:07 +02:00
|
|
|
}
|
2014-05-31 18:58:56 +02:00
|
|
|
|
2016-08-02 15:40:07 +02:00
|
|
|
public function getName(){
|
|
|
|
return 'Dauphine Bridge';
|
|
|
|
}
|
2014-05-31 18:58:56 +02:00
|
|
|
|
2016-08-02 15:40:07 +02:00
|
|
|
public function getURI(){
|
|
|
|
return 'http://ledauphine.com/';
|
|
|
|
}
|
2014-05-31 18:58:56 +02:00
|
|
|
|
2016-08-02 15:40:07 +02:00
|
|
|
public function getCacheDuration(){
|
|
|
|
return 3600*2; // 2 hours
|
|
|
|
}
|
2014-05-31 18:58:56 +02:00
|
|
|
}
|
2016-08-02 15:40:07 +02:00
|
|
|
?>
|