af_redditimgur: some additional .gif -> mp4 rewriting

This commit is contained in:
Andrew Dolgov 2015-07-11 02:08:53 +03:00
parent d4ac4fc6fd
commit 5f297a5c11
1 changed files with 10 additions and 0 deletions

View 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"));