]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_explosm/init.php
2 class Af_Explosm
extends Plugin
{
9 "Strip unnecessary stuff from Cyanide and Happiness feeds",
13 function init($host) {
14 $this->link
= $host->get_link();
17 $host->add_hook($host::HOOK_ARTICLE_FILTER
, $this);
20 function hook_article_filter($article) {
21 $owner_uid = $article["owner_uid"];
23 if (strpos($article["link"], "explosm.net/comics") !== FALSE &&
24 strpos($article["guid"], "explosm,$owner_uid:") === FALSE) {
26 $doc = new DOMDocument();
27 @$doc->loadHTML(fetch_file_contents($article["link"]));
32 $xpath = new DOMXPath($doc);
33 $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
37 foreach ($entries as $entry) {
39 if (preg_match("/(http:\/\/.*\/db\/files\/Comics\/.*)/i", $entry->getAttribute("src"), $matches)) {
47 $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG
);
51 $article["guid"] = "explosm,$owner_uid:" . $article["guid"];