af_redditimgur: rework gfycat pages

This commit is contained in:
Andrew Dolgov 2016-08-02 17:01:53 +03:00
parent 8c395462be
commit 46506d3fd6
1 changed files with 7 additions and 14 deletions

View File

@ -138,17 +138,12 @@ class Af_RedditImgur extends Plugin {
if (@$tmpdoc->loadHTML($tmp)) { 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_node = $tmpxpath->query("//video[contains(@class,'share-video')]//source[contains(@src, '.mp4')]")->item(0);
$poster_meta = $tmpxpath->query("//meta[@property='og:image' and contains(@content,'thumbs.gfycat.com')]")->item(0); $poster_node = $tmpxpath->query("//video[contains(@class,'share-video') and @poster]")->item(0);
if ($source_meta) { if ($source_node && $poster_node) {
$source_stream = $source_meta->getAttribute("content"); $source_stream = $source_node->getAttribute("src");
$poster_url = false; $poster_url = $poster_node->getAttribute("poster");
if ($source_stream) {
if ($poster_meta)
$poster_url = $poster_meta->getAttribute("content");
$this->handle_as_video($doc, $entry, $source_stream, $poster_url); $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
$found = 1; $found = 1;
@ -157,8 +152,6 @@ class Af_RedditImgur extends Plugin {
} }
} }
}
// imgur .gif -> .gifv // imgur .gif -> .gifv
if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) { if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
_debug("Handling as imgur gif (->gifv)", $debug); _debug("Handling as imgur gif (->gifv)", $debug);