summaryrefslogtreecommitdiff
path: root/plugins/af_comics
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/af_comics')
-rwxr-xr-xplugins/af_comics/filters/af_comics_comicpress.php33
-rwxr-xr-xplugins/af_comics/init.php23
2 files changed, 41 insertions, 15 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;
diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php
index d24287c74..c0e97297d 100755
--- a/plugins/af_comics/init.php
+++ b/plugins/af_comics/init.php
@@ -114,9 +114,6 @@ class Af_Comics extends Plugin {
$tpl->setVariable('FEED_URL', htmlspecialchars($fetch_url), true);
$tpl->setVariable('SELF_URL', $site_url, true);
- $tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c'), true);
- $tpl->setVariable('ARTICLE_UPDATED_RFC822', date(DATE_RFC822), true);
-
if ($body) {
$doc = new DOMDocument();
@@ -126,13 +123,22 @@ class Af_Comics extends Plugin {
$node = $xpath->query('//picture[contains(@class, "item-comic-image")]/img')->item(0);
if ($node) {
- $node->removeAttribute("width");
- $node->removeAttribute("data-srcset");
- $node->removeAttribute("srcset");
+ $title = $xpath->query('//h1')->item(0);
+
+ if ($title) {
+ $title = clean(trim($title->nodeValue));
+ } else {
+ $title = date('l, F d, Y');
+ }
+
+ foreach (['srcset', 'sizes', 'data-srcset', 'width'] as $attr ) {
+ $node->removeAttribute($attr);
+ }
$tpl->setVariable('ARTICLE_ID', $article_link, true);
$tpl->setVariable('ARTICLE_LINK', $article_link, true);
- $tpl->setVariable('ARTICLE_TITLE', date('l, F d, Y'), true);
+ $tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c', mktime(11, 0, 0)), true);
+ $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($title), true);
$tpl->setVariable('ARTICLE_EXCERPT', '', true);
$tpl->setVariable('ARTICLE_CONTENT', $doc->saveHTML($node), true);
@@ -141,15 +147,12 @@ class Af_Comics extends Plugin {
$tpl->setVariable('ARTICLE_SOURCE_TITLE', $feed_title, true);
$tpl->addBlock('entry');
-
}
}
}
$tpl->addBlock('feed');
- $tmp_data = '';
-
if ($tpl->generateOutputToString($tmp_data))
$feed_data = $tmp_data;
}