From: Andrew Dolgov Date: Thu, 13 Jun 2013 08:41:13 +0000 (+0400) Subject: add plugin for bunicomic.com X-Git-Tag: 1.9~112 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=edcbb8c9976faffd9899f16cb4e99a439508d602;p=tt-rss.git add plugin for bunicomic.com --- diff --git a/plugins/af_buni/init.php b/plugins/af_buni/init.php new file mode 100644 index 00000000..50166e32 --- /dev/null +++ b/plugins/af_buni/init.php @@ -0,0 +1,62 @@ +host = $host; + + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); + } + + function hook_article_filter($article) { + $owner_uid = $article["owner_uid"]; + + if (strpos($article["guid"], "bunicomic.com") !== FALSE) { + if (strpos($article["plugin_data"], "buni,$owner_uid:") === FALSE) { + + $doc = new DOMDocument(); + @$doc->loadHTML(fetch_file_contents($article["link"])); + + $basenode = false; + + if ($doc) { + $xpath = new DOMXPath($doc); + $entries = $xpath->query('(//img[@src])'); + + $matches = array(); + + foreach ($entries as $entry) { + + if (preg_match("/(http:\/\/www.bunicomic.com\/comics\/\d{4}.*)/i", $entry->getAttribute("src"), $matches)) { + + $basenode = $entry; + break; + } + } + + if ($basenode) { + $article["content"] = $doc->saveXML($basenode); + $article["plugin_data"] = "buni,$owner_uid:" . $article["plugin_data"]; + } + } + } else if (isset($article["stored"]["content"])) { + $article["content"] = $article["stored"]["content"]; + } + } + + return $article; + } + + function api_version() { + return 2; + } + +} +?>