]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_comics/filters/af_comics_gocomics.php
2 class Af_Comics_GoComics
extends Af_ComicFilter
{
5 return array("GoComics");
8 function process(&$article) {
9 $owner_uid = $article["owner_uid"];
11 if (strpos($article["guid"], "gocomics.com") !== FALSE) {
12 if (strpos($article["plugin_data"], "af_comics,$owner_uid:") === FALSE) {
13 $doc = new DOMDocument();
14 @$doc->loadHTML(fetch_file_contents($article["link"]));
19 $xpath = new DOMXPath($doc);
20 $entries = $xpath->query("(//img[@class='strip'])");
24 if ($entries->length
> 1) { // if we have more than one match, then get the zoomed one, which is the second for gocomics
25 $entry = $entries->item(1); // get the second element (items start at 0)
26 if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
27 $entry->setAttribute("src", $matches[0]);
33 // fallback on the smaller version
34 foreach ($entries as $entry) {
36 if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) {
38 $entry->setAttribute("src", $matches[0]);
46 $article["content"] = $doc->saveXML($basenode);
47 $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"];
50 } else if (isset($article["stored"]["content"])) {
51 $article["content"] = $article["stored"]["content"];