]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_gocomics/init.php
466ec9687a34f525ffa8fa8081dad2df54b8351b
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) {
24 if (strpos($article["plugin_data"], "gocomics,$owner_uid:") === FALSE) {
25 $doc = new DOMDocument();
26 @$doc->loadHTML(fetch_file_contents($article["link"]));
31 $xpath = new DOMXPath($doc);
32 $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
36 foreach ($entries as $entry) {
38 if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
40 $entry->setAttribute("src", $matches[0]);
47 $article["content"] = $doc->saveXML($basenode);
48 $article["plugin_data"] = "gocomics,$owner_uid:" . $article["plugin_data"];
51 } else if (isset($article["stored"]["content"])) {
52 $article["content"] = $article["stored"]["content"];