]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_gocomics/init.php
2 class Af_GoComics
extends Plugin
{
7 "Strip unnecessary stuff from gocomics feeds",
11 function init($host) {
14 $host->add_hook($host::HOOK_ARTICLE_FILTER
, $this);
17 function hook_article_filter($article) {
18 $owner_uid = $article["owner_uid"];
20 if (strpos($article["guid"], "gocomics.com") !== FALSE) {
21 if (strpos($article["plugin_data"], "gocomics,$owner_uid:") === FALSE) {
22 $doc = new DOMDocument();
23 @$doc->loadHTML(fetch_file_contents($article["link"]));
28 $xpath = new DOMXPath($doc);
29 $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
33 foreach ($entries as $entry) {
35 if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
37 $entry->setAttribute("src", $matches[0]);
44 $article["content"] = $doc->saveXML($basenode);
45 $article["plugin_data"] = "gocomics,$owner_uid:" . $article["plugin_data"];
48 } else if (isset($article["stored"]["content"])) {
49 $article["content"] = $article["stored"]["content"];