[TheOatMeal] Use core parser functions
This commit is contained in:
parent
0770ca1ad1
commit
1de148bf5d
1 changed files with 7 additions and 34 deletions
|
@ -10,44 +10,17 @@ class TheOatmealBridge extends RssExpander{
|
||||||
$this->collectExpandableDatas('http://feeds.feedburner.com/oatmealfeed');
|
$this->collectExpandableDatas('http://feeds.feedburner.com/oatmealfeed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Since the oatmeal produces a weird RSS feed, I have to fix it by loading the items separatly from the feed infos
|
|
||||||
*/
|
|
||||||
protected function collect_RSS_2_0_data($rssContent) {
|
|
||||||
$rssContent->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/");
|
|
||||||
$rssHeaderContent = $rssContent->channel[0];
|
|
||||||
$this->debugMessage("RSS content is ===========\n".var_export($rssHeaderContent, true)."===========");
|
|
||||||
$this->load_RSS_2_0_feed_data($rssHeaderContent);
|
|
||||||
foreach($rssContent->item as $item) {
|
|
||||||
$this->debugMessage("parsing item ".var_export($item, true));
|
|
||||||
$this->items[] = $this->parseRSSItem($item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function parseRSSItem($newsItem) {
|
protected function parseRSSItem($newsItem) {
|
||||||
$namespaces = $newsItem->getNameSpaces(true);
|
$item = $this->parseRSS_1_0_Item($newsItem);
|
||||||
$dc = $newsItem->children($namespaces['dc']);
|
|
||||||
$rdf = $newsItem->children($namespaces['rdf']);
|
|
||||||
$item = array();
|
|
||||||
$item['title'] = trim($newsItem->title);
|
|
||||||
$this->debugMessage("browsing Oatmeal item ".var_export($newsItem, true));
|
|
||||||
$item['uri']=(string) $newsItem->attributes($namespaces['rdf'])->about;
|
|
||||||
// now load that uri from cache
|
|
||||||
$this->debugMessage("now loading page ".$item['uri']);
|
|
||||||
$articlePage = $this->get_cached($item['uri']);
|
$articlePage = $this->get_cached($item['uri']);
|
||||||
|
|
||||||
$content = $articlePage->find('#comic', 0);
|
$content = $articlePage->find('#comic', 0);
|
||||||
if($content==null) {
|
if(is_null($content)) // load alternative
|
||||||
$content = $articlePage->find('#blog');
|
$content = $articlePage->find('#blog', 0);
|
||||||
}
|
|
||||||
$item['content'] = $content->innertext;
|
if(!is_null($content))
|
||||||
|
$item['content'] = $content->innertext;
|
||||||
|
|
||||||
$this->debugMessage("dc content is ".var_export($dc, true));
|
|
||||||
$item['author'] = (string) $dc->creator;
|
|
||||||
$item['timestamp'] = DateTime::createFromFormat(DateTime::ISO8601, $dc->date)->getTimestamp();
|
|
||||||
$this->debugMessage("writtem by ".$item['author']." on ".$item['timestamp']);
|
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue