]> git.wh0rd.org Git - tt-rss.git/commitdiff
af_redditimgur: some additional .gif -> mp4 rewriting
authorAndrew Dolgov <noreply@fakecake.org>
Fri, 10 Jul 2015 23:08:53 +0000 (02:08 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Fri, 10 Jul 2015 23:08:53 +0000 (02:08 +0300)
plugins/af_redditimgur/init.php

index c4ec265d32d4cf87b18c9bc252cde79ab554a8de..fd75022034d91742aa98c11fc8c4ec0af78bc636 100644 (file)
@@ -80,6 +80,10 @@ class Af_RedditImgur extends Plugin {
 
                                $matches = array();
 
+                               if (preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
+                                       $entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]);
+                               }
+
                                if (preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
 
                                        $tmp = fetch_file_contents($entry->getAttribute("href"));
@@ -112,6 +116,12 @@ class Af_RedditImgur extends Plugin {
 
                                }
 
+                               // imgur .gif -> .gifv
+                               if (preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
+                                       $entry->setAttribute("href",
+                                               str_replace(".gif", ".gifv", $entry->getAttribute("href")));
+                               }
+
                                if (preg_match("/\.(gifv)$/i", $entry->getAttribute("href"))) {
 
                                        $source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));