]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_gocomics/init.php
2 class Af_GoComics
extends Plugin
{
9 "Strip unnecessary stuff from gocomics 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["guid"], "gocomics.com") !== FALSE && strpos($article["guid"], "gocomics,$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:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
39 $entry->setAttribute("src", $matches[0]);
46 $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG
);
48 // we need to update guid with owner_uid because our local article is different from the one
49 // other users with this plugin disabled might get
50 $article["guid"] = "gocomics,$owner_uid:" . $article["guid"];