add plugin for bunicomic.com
This commit is contained in:
parent
b5a9ef5ebc
commit
edcbb8c997
1 changed files with 62 additions and 0 deletions
62
plugins/af_buni/init.php
Normal file
62
plugins/af_buni/init.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
class Af_Buni extends Plugin {
|
||||
|
||||
private $host;
|
||||
|
||||
function about() {
|
||||
return array(1.0,
|
||||
"Fix Buni rss feed",
|
||||
"fox");
|
||||
}
|
||||
|
||||
function init($host) {
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue