1
0
Fork 0
forked from blallo/rss-bridge
This commit is contained in:
Mitsukarenai 2014-07-08 17:06:49 +02:00
parent b6602fc8e3
commit d4de199501

View file

@ -1,79 +1,46 @@
<?php <?php
/** /**
* *
* @name Tuxboard * @name Tuxboard
* @homepage http://www.tuxboard.com/ * @homepage http://www.tuxboard.com/
* @description Tuxboard * @description Tuxboard
* @update 15/01/2014 * @update 2014-07-08
* initial maintainer: superbaillot.net * initial maintainer: superbaillot.net
*/ */
class TuxboardBridge extends BridgeAbstract{ class TuxboardBridge extends BridgeAbstract{
public function collectData(array $param){ public function collectData(array $param){
$html = file_get_html('http://www.tuxboard.com') or $this->returnError('Could not request Tuxboard.', 404);
foreach($html->find('div.posts') as $element) { function StripCDATA($string) {
$a = $element->find("h2 a", 0); $string = str_replace('<![CDATA[', '', $string);
$category = $element->find("div#category", 0); $string = str_replace(']]>', '', $string);
$catTxt = $category->innertext; return $string;
$posFinDate = strpos(" -", $catTxt); }
$list = explode(" ", trim(substr($catTxt, $posFinDate)));
$jour = $list[0];
$mois = 1;
$annee = $list[2];
switch (strtolower($list[1])) function ExtractContent($url) {
{ $html2 = file_get_html($url);
case "janvier" : $text = $html2->find('article#page', 0)->innertext;
$mois = 1; $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
break; return $text;
case "février" : }
case "fevrier" :
$mois = 2;
break;
case "mars" :
$mois = 3;
break;
case "avril" :
$mois = 4;
break;
case "mai" :
$mois = 5;
break;
case "juin" :
$mois = 6;
break;
case "juillet" :
$mois = 7;
break;
case "aout" :
case "août" :
$mois = 8;
break;
case "septembre" :
$mois = 9;
break;
case "octobre" :
$mois = 10;
break;
case "novembre" :
$mois = 11;
break;
case "decembre" :
case "décembre" :
$mois = 12;
break;
}
$item = new Item(); $html = file_get_html('http://www.tuxboard.com/feed/atom/') or $this->returnError('Could not request Tuxboard.', 404);
$limit = 0;
$item->uri = $a->href; foreach($html->find('entry') as $element) {
$item->title = $a->innertext; if($limit < 10) {
$item->content = trim($element->find("div.clear", 0)->innertext); $item = new \Item();
$item->timestamp = mktime(0, 0, 0, $mois, $jour, $annee); $item->title = StripCDATA($element->find('title', 0)->innertext);
$item->uri = $element->find('link', 0)->href;
$this->items[] = $item; $item->timestamp = strtotime($element->find('published', 0)->plaintext);
} $item->content = ExtractContent($item->uri);
$this->items[] = $item;
$limit++;
}
}
} }
public function getName(){ public function getName(){
@ -89,7 +56,7 @@ class TuxboardBridge extends BridgeAbstract{
} }
public function getCacheDuration(){ public function getCacheDuration(){
return 14600; // 4 hours return 3600; // 1 hour
} }
} }
?> ?>