summaryrefslogtreecommitdiff
path: root/plugins/af_comics
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-11-18 19:00:08 +0300
committerAndrew Dolgov <[email protected]>2019-11-18 19:00:08 +0300
commitffa3f9309f9f87b63dae58235597dbad467ba37d (patch)
treec5cae4ade24b3812846f409c3e35de11947d49fd /plugins/af_comics
parent8c3efd51ecd76f4e9ffeb111bbbe2c5862aa3bed (diff)
af_comics: support buni webtoon episodes
Diffstat (limited to 'plugins/af_comics')
-rwxr-xr-xplugins/af_comics/filters/af_comics_comicpress.php33
1 files changed, 28 insertions, 5 deletions
diff --git a/plugins/af_comics/filters/af_comics_comicpress.php b/plugins/af_comics/filters/af_comics_comicpress.php
index 19c335660..7755bcb1a 100755
--- a/plugins/af_comics/filters/af_comics_comicpress.php
+++ b/plugins/af_comics/filters/af_comics_comicpress.php
@@ -18,9 +18,8 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
// lol at people who block clients by user agent
// oh noes my ad revenue Q_Q
- $res = fetch_file_contents($article["link"], false, false, false,
- false, false, 0,
- "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
+ $res = fetch_file_contents(["url" => $article["link"],
+ "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
$doc = new DOMDocument();
@@ -30,10 +29,34 @@ class Af_Comics_ComicPress extends Af_ComicFilter {
if ($basenode) {
$article["content"] = $doc->saveHTML($basenode);
+ return true;
}
- }
- return true;
+ // buni-specific
+ $webtoon_link = $xpath->query("//a[contains(@href,'www.webtoons.com')]")->item(0);
+
+ if ($webtoon_link) {
+
+ $res = fetch_file_contents(["url" => $webtoon_link->getAttribute("href"),
+ "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]);
+
+ if (@$doc->loadHTML($res)) {
+ $xpath = new DOMXPath($doc);
+ $basenode = $xpath->query('//div[@id="_viewerBox"]')->item(0);
+
+ if ($basenode) {
+ $imgs = $xpath->query("//img[@data-url]", $basenode);
+
+ foreach ($imgs as $img) {
+ $img->setAttribute("src", $img->getAttribute("data-url"));
+ }
+
+ $article["content"] = $doc->saveHTML($basenode);
+ return true;
+ }
+ }
+ }
+ }
}
return false;