]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_explosm/init.php
2a8fab491416bd43c308ec76c2d63f7623c190d7
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 if (strpos($article["plugin_data"], "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);
48 $article["plugin_data"] = "explosm,$owner_uid:" . $article["plugin_data"];
51 } else if (isset($article["stored"]["content"])) {
52 $article["content"] = $article["stored"]["content"];