diff options
Diffstat (limited to 'plugins/af_comics')
-rw-r--r-- | plugins/af_comics/filter_base.php | 22 | ||||
-rwxr-xr-x | plugins/af_comics/filters/af_comics_comicpress.php | 7 | ||||
-rw-r--r-- | plugins/af_comics/filters/af_comics_dilbert.php | 2 | ||||
-rw-r--r-- | plugins/af_comics/filters/af_comics_explosm.php | 2 | ||||
-rw-r--r-- | plugins/af_comics/filters/af_comics_gocomics.php | 1 | ||||
-rw-r--r-- | plugins/af_comics/filters/af_comics_gocomics_farside.php | 16 | ||||
-rw-r--r-- | plugins/af_comics/filters/af_comics_tfd.php | 2 | ||||
-rwxr-xr-x | plugins/af_comics/init.php | 6 |
8 files changed, 48 insertions, 10 deletions
diff --git a/plugins/af_comics/filter_base.php b/plugins/af_comics/filter_base.php index d6a697bb4..83bc48184 100644 --- a/plugins/af_comics/filter_base.php +++ b/plugins/af_comics/filter_base.php @@ -1,16 +1,38 @@ <?php abstract class Af_ComicFilter { + /** @return array<string> */ public abstract function supported(); + + /** + * @param array<string,mixed> $article + * @return bool + */ public abstract function process(&$article); + public function __construct(/*PluginHost $host*/) { + + } + + /** + * @param string $url + * @return string|false + */ public function on_subscribe($url) { return false; } + /** + * @param string $url + * @return array{"title": string, "site_url": string}|false + */ public function on_basic_info($url) { return false; } + /** + * @param string $url + * @return string|false + */ public function on_fetch($url) { return false; } diff --git a/plugins/af_comics/filters/af_comics_comicpress.php b/plugins/af_comics/filters/af_comics_comicpress.php index 741d59672..b963b2ae7 100755 --- a/plugins/af_comics/filters/af_comics_comicpress.php +++ b/plugins/af_comics/filters/af_comics_comicpress.php @@ -3,13 +3,16 @@ class Af_Comics_ComicPress extends Af_ComicFilter { function supported() { return array("Buni", "Buttersafe", "Happy Jar", "CSection", - "Extra Fabulous Comics", "Nedroid", "Stonetoss"); + "Extra Fabulous Comics", "Nedroid", "Stonetoss", + "Danby Draws", "Powerup Comics"); } function process(&$article) { if (strpos($article["guid"], "bunicomic.com") !== false || strpos($article["guid"], "buttersafe.com") !== false || strpos($article["guid"], "extrafabulouscomics.com") !== false || + strpos($article["guid"], "danbydraws.com") !== false || + strpos($article["guid"], "theduckwebcomics.com/Powerup_Comics") !== false || strpos($article["guid"], "happyjar.com") !== false || strpos($article["guid"], "nedroid.com") !== false || strpos($article["guid"], "stonetoss.com") !== false || @@ -32,7 +35,7 @@ class Af_Comics_ComicPress extends Af_ComicFilter { return true; } - // buni-specific + /** @var DOMElement|null $webtoon_link (buni specific) */ $webtoon_link = $xpath->query("//a[contains(@href,'www.webtoons.com')]")->item(0); if ($webtoon_link) { diff --git a/plugins/af_comics/filters/af_comics_dilbert.php b/plugins/af_comics/filters/af_comics_dilbert.php index 49fa54cfa..a1c59b94c 100644 --- a/plugins/af_comics/filters/af_comics_dilbert.php +++ b/plugins/af_comics/filters/af_comics_dilbert.php @@ -22,7 +22,7 @@ class Af_Comics_Dilbert extends Af_ComicFilter { if ($res && $doc->loadHTML($res)) { $xpath = new DOMXPath($doc); - // Get the image container + /** @var DOMElement|null $basenode (image container) */ $basenode = $xpath->query('(//div[@class="img-comic-container"]/a[@class="img-comic-link"])')->item(0); // Get the comic title diff --git a/plugins/af_comics/filters/af_comics_explosm.php b/plugins/af_comics/filters/af_comics_explosm.php index bfe38e53b..3f8b49726 100644 --- a/plugins/af_comics/filters/af_comics_explosm.php +++ b/plugins/af_comics/filters/af_comics_explosm.php @@ -13,7 +13,7 @@ class Af_Comics_Explosm extends Af_ComicFilter { if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) { $xpath = new DOMXPath($doc); - $basenode = $xpath->query('(//img[@id="main-comic"])')->item(0); + $basenode = $xpath->query('//div[contains(@class, "MainComic__ComicImage")]//img')->item(0); if ($basenode) { $article["content"] = $doc->saveHTML($basenode); diff --git a/plugins/af_comics/filters/af_comics_gocomics.php b/plugins/af_comics/filters/af_comics_gocomics.php index 71d387918..732f7d0b8 100644 --- a/plugins/af_comics/filters/af_comics_gocomics.php +++ b/plugins/af_comics/filters/af_comics_gocomics.php @@ -50,6 +50,7 @@ class Af_Comics_Gocomics extends Af_ComicFilter { if (@$doc->loadHTML($body)) { $xpath = new DOMXPath($doc); + /** @var DOMElement|null $node */ $node = $xpath->query('//picture[contains(@class, "item-comic-image")]/img')->item(0); if ($node) { diff --git a/plugins/af_comics/filters/af_comics_gocomics_farside.php b/plugins/af_comics/filters/af_comics_gocomics_farside.php index 0399015ab..e4e230516 100644 --- a/plugins/af_comics/filters/af_comics_gocomics_farside.php +++ b/plugins/af_comics/filters/af_comics_gocomics_farside.php @@ -50,8 +50,22 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter { if ($content_node) { $imgs = $xpath->query('//img[@data-src]', $content_node); + $cache = new DiskCache("images"); + foreach ($imgs as $img) { - $img->setAttribute('src', $img->getAttribute('data-src')); + $image_url = $img->getAttribute('data-src'); + $local_filename = sha1($image_url); + + if ($image_url) { + $img->setAttribute('src', $image_url); + + // try to cache image locally because they just 401 us otherwise + if (!$cache->exists($local_filename)) { + Debug::log("[Af_Comics_Gocomics_FarSide] caching: $image_url", Debug::LOG_VERBOSE); + $res = $cache->download($image_url, sha1($image_url), ["http_referrer" => $image_url]); + Debug::log("[Af_Comics_Gocomics_FarSide] cache result: $res", Debug::LOG_VERBOSE); + } + } } $junk_elems = $xpath->query("//*[@data-shareable-popover]"); diff --git a/plugins/af_comics/filters/af_comics_tfd.php b/plugins/af_comics/filters/af_comics_tfd.php index 19ca43a24..2010da37e 100644 --- a/plugins/af_comics/filters/af_comics_tfd.php +++ b/plugins/af_comics/filters/af_comics_tfd.php @@ -12,7 +12,7 @@ class Af_Comics_Tfd extends Af_ComicFilter { false, false, 0, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); - if (!$res) return $article; + if (!$res) return false; $doc = new DOMDocument(); diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php index 8aba1416b..a9a8f3faa 100755 --- a/plugins/af_comics/init.php +++ b/plugins/af_comics/init.php @@ -1,7 +1,7 @@ <?php class Af_Comics extends Plugin { - private $host; + /** @var array<object> $filters */ private $filters = array(); function about() { @@ -11,8 +11,6 @@ class Af_Comics extends Plugin { } function init($host) { - $this->host = $host; - $host->add_hook($host::HOOK_FETCH_FEED, $this); $host->add_hook($host::HOOK_FEED_BASIC_INFO, $this); $host->add_hook($host::HOOK_SUBSCRIBE_FEED, $this); @@ -34,7 +32,7 @@ class Af_Comics extends Plugin { array_push($names, $filter_name); - $filter = new $filter_name(); + $filter = new $filter_name($host); if (is_subclass_of($filter, "Af_ComicFilter")) { array_push($this->filters, $filter); |