]> git.wh0rd.org - tt-rss.git/commitdiff
af_redditimgur: add basic support for v.redd.it videos
authorAndrew Dolgov <noreply@fakecake.org>
Sat, 16 Sep 2017 07:08:30 +0000 (10:08 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Sat, 16 Sep 2017 07:08:30 +0000 (10:08 +0300)
plugins/af_redditimgur/init.php

index ac23a4fa34685f0338e94dceb754a45af5f99e7f..c872b429a927af76792be100ccac9a2e5a527693 100755 (executable)
@@ -79,6 +79,7 @@ class Af_RedditImgur extends Plugin {
        private function inline_stuff($article, &$doc, $xpath, $debug = false) {
 
                $entries = $xpath->query('(//a[@href]|//img[@src])');
+               $img_entries = $xpath->query("(//img[@src])");
 
                $found = false;
 
@@ -146,6 +147,24 @@ class Af_RedditImgur extends Plugin {
                                        }
                                }
 
+                               if (!$found && preg_match("/https?:\/\/v\.redd\.it\/(.*)$/i", $entry->getAttribute("href"), $matches)) {
+
+                                       _debug("Handling as reddit inline video", $debug);
+
+                                       $img = $img_entries->item(0);
+
+                                       if ($img) {
+                                               $poster_url = $img->getAttribute("src");
+                                       } else {
+                                               $poster_url = false;
+                                       }
+
+                                       $source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K";
+
+                                       $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
+                                       $found = 1;
+                               }
+
                                if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) {
 
                                        _debug("Handling as Streamable", $debug);