]> git.wh0rd.org - tt-rss.git/blame - plugins/af_comics/filters/af_comics_gocomics.php
plugins: remove obsolete plugin_data/stored stuff
[tt-rss.git] / plugins / af_comics / filters / af_comics_gocomics.php
CommitLineData
901dd67a
AD
1<?php
2class Af_Comics_GoComics extends Af_ComicFilter {
3
4 function supported() {
5 return array("GoComics");
6 }
7
8 function process(&$article) {
9 $owner_uid = $article["owner_uid"];
10
11 if (strpos($article["guid"], "gocomics.com") !== FALSE) {
901dd67a
AD
12 $doc = new DOMDocument();
13 @$doc->loadHTML(fetch_file_contents($article["link"]));
14
15 $basenode = false;
16
17 if ($doc) {
18 $xpath = new DOMXPath($doc);
d35bd9a2 19 $entries = $xpath->query("(//img[@class='strip'])");
901dd67a
AD
20
21 $matches = array();
22
d35bd9a2 23 if ($entries->length > 1) { // if we have more than one match, then get the zoomed one, which is the second for gocomics
24 $entry = $entries->item(1); // get the second element (items start at 0)
25 if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
901dd67a
AD
26 $entry->setAttribute("src", $matches[0]);
27 $basenode = $entry;
901dd67a
AD
28 }
29 }
30
9203929c
AD
31 if (!$basenode) {
32 // fallback on the smaller version
33 foreach ($entries as $entry) {
34 if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
35 $entry->setAttribute("src", $matches[0]);
36 $basenode = $entry;
37 break;
38 }
39 }
40 }
901dd67a
AD
41
42 if ($basenode) {
43 $article["content"] = $doc->saveXML($basenode);
901dd67a
AD
44 }
45 }
901dd67a
AD
46
47 return true;
48 }
49
50 return false;
51 }
52}
53?>