af_redditimgur: support gyazo, properly check album domdocuments loading html
This commit is contained in:
parent
583f163f40
commit
58a44ecb3f
1 changed files with 16 additions and 4 deletions
20
plugins/af_redditimgur/init.php
Normal file → Executable file
20
plugins/af_redditimgur/init.php
Normal file → Executable file
|
@ -88,9 +88,8 @@ class Af_RedditImgur extends Plugin {
|
||||||
|
|
||||||
if ($tmp) {
|
if ($tmp) {
|
||||||
$tmpdoc = new DOMDocument();
|
$tmpdoc = new DOMDocument();
|
||||||
@$tmpdoc->loadHTML($tmp);
|
|
||||||
|
|
||||||
if ($tmpdoc) {
|
if (@$tmpdoc->loadHTML($tmp)) {
|
||||||
$tmpxpath = new DOMXPath($tmpdoc);
|
$tmpxpath = new DOMXPath($tmpdoc);
|
||||||
|
|
||||||
$source_meta = $tmpxpath->query("//meta[@name='twitter:player:stream' and contains(@content, '.mp4')]")->item(0);
|
$source_meta = $tmpxpath->query("//meta[@name='twitter:player:stream' and contains(@content, '.mp4')]")->item(0);
|
||||||
|
@ -177,9 +176,8 @@ class Af_RedditImgur extends Plugin {
|
||||||
|
|
||||||
if ($album_content) {
|
if ($album_content) {
|
||||||
$adoc = new DOMDocument();
|
$adoc = new DOMDocument();
|
||||||
@$adoc->loadHTML($album_content);
|
|
||||||
|
|
||||||
if ($adoc) {
|
if (@$adoc->loadHTML($album_content)) {
|
||||||
$axpath = new DOMXPath($adoc);
|
$axpath = new DOMXPath($adoc);
|
||||||
$aentries = $axpath->query("//meta[@property='og:image']");
|
$aentries = $axpath->query("//meta[@property='og:image']");
|
||||||
$urls = array();
|
$urls = array();
|
||||||
|
@ -208,6 +206,20 @@ class Af_RedditImgur extends Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wtf is this even
|
||||||
|
if (preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
|
||||||
|
$img_id = $matches[1];
|
||||||
|
|
||||||
|
$img = $doc->createElement('img');
|
||||||
|
$img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg");
|
||||||
|
|
||||||
|
$br = $doc->createElement('br');
|
||||||
|
$entry->parentNode->insertBefore($img, $entry);
|
||||||
|
$entry->parentNode->insertBefore($br, $entry);
|
||||||
|
|
||||||
|
$found = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove tiny thumbnails
|
// remove tiny thumbnails
|
||||||
|
|
Loading…
Reference in a new issue