From 5f297a5c111e3abecd143b6412a753ea870e4f20 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 11 Jul 2015 02:08:53 +0300 Subject: [PATCH] af_redditimgur: some additional .gif -> mp4 rewriting --- plugins/af_redditimgur/init.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index c4ec265d3..fd7502203 100644 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -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"));