]> git.wh0rd.org Git - tt-rss.git/blob - plugins/af_comics/filters/af_comics_darklegacy.php
add af_comics_darklegacy
[tt-rss.git] / plugins / af_comics / filters / af_comics_darklegacy.php
1 <?php
2 class Af_Comics_DarkLegacy extends Af_ComicFilter {
3
4         function supported() {
5                 return array("Dark Legacy Comics");
6         }
7
8         function process(&$article) {
9                 $owner_uid = $article["owner_uid"];
10
11                 if (strpos($article["guid"], "darklegacycomics.com") !== FALSE) {
12                          if (strpos($article["plugin_data"], "af_comics,$owner_uid:") === FALSE) {
13
14                                  print "DLC!" . $article["link"] . "\n";
15
16                                 $res = fetch_file_contents($article["link"], false, false, false,
17                                          false, false, 0,
18                                          "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
19
20                                 global $fetch_last_error_content;
21
22                                 if (!$res && $fetch_last_error_content)
23                                         $res = $fetch_last_error_content;
24
25                                 $doc = new DOMDocument();
26                                 @$doc->loadHTML($res);
27
28                                 $basenode = false;
29
30                                 if ($doc) {
31                                         $xpath = new DOMXPath($doc);
32                                         $basenode = $xpath->query('//div[@class="comic"]')->item(0);
33
34                                         if ($basenode) {
35
36                                                 $article["content"] = $doc->saveXML($basenode);
37                                                 $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"];
38                                         }
39                                 }
40                         } else if (isset($article["stored"]["content"])) {
41                                 $article["content"] = $article["stored"]["content"];
42                         }
43
44                          return true;
45                 }
46
47                 return false;
48         }
49 }
50 ?>