]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_pennyarcade/init.php
d897d85ca363edad823cde1d12517b408a3ad1c7
2 class Af_PennyArcade
extends Plugin
{
8 "Strip unnecessary stuff from PA 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"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
22 if (strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
25 _debug("af_pennyarcade: Processing comic");
28 $doc = new DOMDocument();
29 $doc->loadHTML(fetch_file_contents($article["link"]));
34 $xpath = new DOMXPath($doc);
35 $entries = $xpath->query('(//div[@class="post comic"])');
37 foreach ($entries as $entry) {
42 $article["content"] = $doc->saveXML($basenode);
43 $article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"];
46 } else if (isset($article["stored"]["content"])) {
47 $article["content"] = $article["stored"]["content"];
51 if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) {
52 if (strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
54 _debug("af_pennyarcade: Processing news post");
56 $doc = new DOMDocument();
57 $doc->loadHTML(fetch_file_contents($article["link"]));
60 $xpath = new DOMXPath($doc);
61 $entries = $xpath->query('(//div[@class="post"])');
65 foreach ($entries as $entry) {
69 $uninteresting = $xpath->query('(//div[@class="heading"])');
70 foreach ($uninteresting as $i) {
71 $i->parentNode
->removeChild($i);
75 $article["content"] = $doc->saveXML($basenode);
76 $article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"];
79 } else if (isset($article["stored"]["content"])) {
80 $article["content"] = $article["stored"]["content"];