From b22766fcdd8d440d6f570ae4d00da52e7c45ee10 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Jun 2018 15:56:08 +0300 Subject: [PATCH] Af_RedditImgur: update to use readability-php --- plugins/af_redditimgur/init.php | 41 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 4079a5b3..8a662de2 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -1,4 +1,7 @@ init()) { + try { + if ($r->parse($tmp)) { - $tmpxpath = new DOMXPath($r->dom); + $tmpxpath = new DOMXPath($r->getDOMDocument()); - $entries = $tmpxpath->query('(//a[@href]|//img[@src])'); + $entries = $tmpxpath->query('(//a[@href]|//img[@src])'); - foreach ($entries as $entry) { - if ($entry->hasAttribute("href")) { - $entry->setAttribute("href", - rewrite_relative_url($url, $entry->getAttribute("href"))); + foreach ($entries as $entry) { + if ($entry->hasAttribute("href")) { + $entry->setAttribute("href", + rewrite_relative_url($url, $entry->getAttribute("href"))); - } + } - if ($entry->hasAttribute("src")) { - $entry->setAttribute("src", - rewrite_relative_url($url, $entry->getAttribute("src"))); + if ($entry->hasAttribute("src")) { + $entry->setAttribute("src", + rewrite_relative_url($url, $entry->getAttribute("src"))); + + } } + $article["content"] = $r->getContent() . "
" . $article["content"]; } - - $article["content"] = $r->articleContent->innerHTML . "
" . $article["content"]; + } catch (ParseException $e) { + // } } } -- 2.39.2