]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_pennyarcade/init.php
06c1230a6f718ccdc845c98a00677576d37a46a4
2 class Af_PennyArcade
extends Plugin
{
9 "Strip unnecessary stuff from PA feeds",
13 function init($host) {
14 $this->link
= $host->get_link();
17 $host->add_hook($host::HOOK_ARTICLE_FILTER
, $this);
20 function hook_article_filter($article) {
21 $owner_uid = $article["owner_uid"];
23 if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
24 if (strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
27 _debug("af_pennyarcade: Processing comic");
30 $doc = new DOMDocument();
31 $doc->loadHTML(fetch_file_contents($article["link"]));
36 $xpath = new DOMXPath($doc);
37 $entries = $xpath->query('(//div[@class="post comic"])');
39 foreach ($entries as $entry) {
44 $article["content"] = $doc->saveXML($basenode);
45 $article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"];
48 } else if (isset($article["stored"]["content"])) {
49 $article["content"] = $article["stored"]["content"];
53 if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) {
54 if (strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
56 _debug("af_pennyarcade: Processing news post");
58 $doc = new DOMDocument();
59 $doc->loadHTML(fetch_file_contents($article["link"]));
62 $xpath = new DOMXPath($doc);
63 $entries = $xpath->query('(//div[@class="post"])');
67 foreach ($entries as $entry) {
71 $uninteresting = $xpath->query('(//div[@class="heading"])');
72 foreach ($uninteresting as $i) {
73 $i->parentNode
->removeChild($i);
77 $article["content"] = $doc->saveXML($basenode);
78 $article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"];
81 } else if (isset($article["stored"]["content"])) {
82 $article["content"] = $article["stored"]["content"];