]> git.wh0rd.org Git - tt-rss.git/commitdiff
af_redditimgur: support video elements in imgur albums
authorAndrew Dolgov <noreply@fakecake.org>
Tue, 26 Jul 2016 13:29:17 +0000 (16:29 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Tue, 26 Jul 2016 13:29:17 +0000 (16:29 +0300)
plugins/af_redditimgur/init.php

index 1068ec54870e94cb822549194fe79c62fc52eebd..af58197cde09b53f8ae17a8bb523c5b5907b5e09 100755 (executable)
@@ -239,7 +239,7 @@ class Af_RedditImgur extends Plugin {
 
                                                        //if ($debug) print_r($album_content);
 
-                                                       $aentries = $axpath->query("(//div[@class='post-image']/img[@src] | //a[@class='zoom']/img[@src])");
+                                                       $aentries = $axpath->query("(//div[@class='post-image']/img[@src] | //a[@class='zoom']/img[@src] | //div[@class='video-elements']/source)");
                                                        $urls = [];
 
                                                        foreach ($aentries as $aentry) {
@@ -247,14 +247,27 @@ class Af_RedditImgur extends Plugin {
                                                                $url = $aentry->getAttribute("src");
 
                                                                if (!in_array($url, $urls)) {
-                                                                       $img = $doc->createElement('img');
-                                                                       $img->setAttribute("src", $url);
-                                                                       $entry->parentNode->insertBefore($doc->createElement('br'), $entry);
 
-                                                                       $br = $doc->createElement('br');
+                                                                       if ($aentry->tagName == "img") {
 
-                                                                       $entry->parentNode->insertBefore($img, $entry);
-                                                                       $entry->parentNode->insertBefore($br, $entry);
+                                                                               $img = $doc->createElement('img');
+                                                                               $img->setAttribute("src", $url);
+                                                                               $entry->parentNode->insertBefore($doc->createElement('br'), $entry);
+
+                                                                               $br = $doc->createElement('br');
+
+                                                                               $entry->parentNode->insertBefore($img, $entry);
+                                                                               $entry->parentNode->insertBefore($br, $entry);
+                                                                       } else if ($aentry->tagName == "source") {
+
+                                                                               if (strpos($url, "i.imgur.com") !== FALSE)
+                                                                                       $poster_url = str_replace(".mp4", "h.jpg", $url);
+                                                                               else
+                                                                                       $poster_url = "";
+
+                                                                               $this->handle_as_video($doc, $entry, $url, $poster_url);
+
+                                                                       }
 
                                                                        array_push($urls, $url);