]> git.wh0rd.org Git - tt-rss.git/commitdiff
af_redditimgur: inline streamable.com videos
authorAndrew Dolgov <noreply@fakecake.org>
Sun, 29 Jan 2017 11:36:37 +0000 (14:36 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Sun, 29 Jan 2017 11:36:37 +0000 (14:36 +0300)
plugins/af_redditimgur/init.php

index 7ab07b9003b372ac623129ddc1cff88188dd21d9..29ea329ad13ca9f7edf3b056b4ad2bf9ce0675c5 100755 (executable)
@@ -152,6 +152,32 @@ class Af_RedditImgur extends Plugin {
                                        }
                                }
 
+                               if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) {
+
+                                       _debug("Handling as Streamable", $debug);
+
+                                       $tmp = fetch_file_contents($entry->getAttribute("href"));
+
+                                       if ($tmp) {
+                                               $tmpdoc = new DOMDocument();
+
+                                               if (@$tmpdoc->loadHTML($tmp)) {
+                                                       $tmpxpath = new DOMXPath($tmpdoc);
+
+                                                       $source_node = $tmpxpath->query("//video[contains(@class,'video-player-tag')]//source[contains(@src, '.mp4')]")->item(0);
+                                                       $poster_node = $tmpxpath->query("//video[contains(@class,'video-player-tag') and @poster]")->item(0);
+
+                                                       if ($source_node && $poster_node) {
+                                                               $source_stream = $source_node->getAttribute("src");
+                                                               $poster_url = $poster_node->getAttribute("poster");
+
+                                                               $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
+                                                               $found = 1;
+                                                       }
+                                               }
+                                       }
+                               }
+
                                // imgur .gif -> .gifv
                                if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
                                        _debug("Handling as imgur gif (->gifv)", $debug);