]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_buttersafe/init.php
2 class Af_Buttersafe
extends Plugin
{
8 "Strip unnecessary stuff from Buttersafe 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["guid"], "buttersafe.com") !== FALSE) {
22 if (strpos($article["plugin_data"], "buttersafe,$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])');
35 foreach ($entries as $entry) {
37 if (preg_match("/(http:\/\/buttersafe.com\/comics\/\d{4}.*)/i", $entry->getAttribute("src"), $matches)) {
45 $article["content"] = $doc->saveXML($basenode);
46 $article["plugin_data"] = "buttersafe,$owner_uid:" . $article["plugin_data"];
49 } else if (isset($article["stored"]["content"])) {
50 $article["content"] = $article["stored"]["content"];