1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-26 01:34:03 +02:00

[bridges] Change to extend from FeedExpander

This commit is contained in:
logmanoriginal
2016-09-05 18:43:56 +02:00
parent 11be7ccb60
commit 179e73fb80
12 changed files with 262 additions and 437 deletions

View File

@@ -1,11 +1,21 @@
<?php
class DeveloppezDotComBridge extends BridgeAbstract{
class DeveloppezDotComBridge extends FeedExpander {
const MAINTAINER = "polopollo";
const NAME = "Developpez.com Actus (FR)";
const URI = "http://www.developpez.com/";
const DESCRIPTION = "Returns the 15 newest posts from DeveloppezDotCom (full text).";
public function collectData(){
$this->collectExpandableDatas(self::URI . 'index/rss');
}
protected function parseItem($newsItem){
$item = $this->parseRSS_2_0_Item($newsItem);
$item['content'] = $this->DeveloppezDotComExtractContent($item['uri']);
return $item;
}
private function DeveloppezDotComStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string);
@@ -32,31 +42,12 @@ class DeveloppezDotComBridge extends BridgeAbstract{
}
private function DeveloppezDotComExtractContent($url) {
$articleHTMLContent = $this->getSimpleHTMLDOM($url);
$articleHTMLContent = $this->get_cached($url);
$text = $this->convert_smart_quotes($articleHTMLContent->find('div.content', 0)->innertext);
$text = utf8_encode($text);
return trim($text);
}
public function collectData(){
$rssFeed = $this->getSimpleHTMLDOM(self::URI.'index/rss')
or $this->returnServerError('Could not request '.self::URI.'index/rss');
$limit = 0;
foreach($rssFeed->find('item') as $element) {
if($limit < 10) {
$item = array();
$item['title'] = $this->DeveloppezDotComStripCDATA($element->find('title', 0)->innertext);
$item['uri'] = $this->DeveloppezDotComStripCDATA($element->find('guid', 0)->plaintext);
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
$content = $this->DeveloppezDotComExtractContent($item['uri']);
$item['content'] = strlen($content) ? $content : $element->description; //In case of it is a tutorial, we just keep the original description
$this->items[] = $item;
$limit++;
}
}
}
public function getCacheDuration(){
return 1800; // 30min
}