]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_explosm/init.php
2 class Af_Explosm
extends Plugin
{
8 "Strip unnecessary stuff from Cyanide and Happiness feeds",
12 function init($host) {
15 $host->add_hook($host::HOOK_ARTICLE_FILTER
, $this);
18 function hook_article_filter($article) {
19 $owner_uid = $article["owner_uid"];
21 if (strpos($article["link"], "explosm.net/comics") !== FALSE) {
22 if (strpos($article["plugin_data"], "explosm,$owner_uid:") === FALSE) {
24 $doc = new DOMDocument();
25 @$doc->loadHTML(fetch_file_contents($article["link"]));
30 $xpath = new DOMXPath($doc);
31 $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
35 foreach ($entries as $entry) {
37 if (preg_match("/(http:\/\/.*\/db\/files\/Comics\/.*)/i", $entry->getAttribute("src"), $matches)) {
45 $article["content"] = $doc->saveXML($basenode);
46 $article["plugin_data"] = "explosm,$owner_uid:" . $article["plugin_data"];
49 } else if (isset($article["stored"]["content"])) {
50 $article["content"] = $article["stored"]["content"];