]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_natgeo/init.php
2 class Af_NatGeo
extends Plugin
{
8 "Fetch content of National Geographic 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["link"], "nationalgeographic.com") !== FALSE) {
22 if (strpos($article["plugin_data"], "natgeo,$owner_uid:") === FALSE) {
24 $doc = new DOMDocument();
25 @$doc->loadHTML(fetch_file_contents($article["link"]));
30 $xpath = new DOMXPath($doc);
32 $basenode = $doc->getElementById("content_mainA");
34 $trash = $xpath->query("//*[@class='aside' or @id='livefyre' or @id='powered_by_livefyre' or @class='social_buttons']");
36 foreach ($trash as $t) {
37 $t->parentNode
->removeChild($t);
41 $article["content"] = $doc->saveXML($basenode);
42 $article["plugin_data"] = "natgeo,$owner_uid:" . $article["plugin_data"];
45 } else if (isset($article["stored"]["content"])) {
46 $article["content"] = $article["stored"]["content"];
53 function api_version() {