af_comics: support buni webtoon episodes

This commit is contained in:
Andrew Dolgov 2019-11-18 19:00:08 +03:00
parent 8c3efd51ec
commit ffa3f9309f
1 changed files with 28 additions and 5 deletions

View File

@ -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;
}
// 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 true;
}
return false;