Skip to content

Commit

Permalink
Remove redgifs transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
aledeg committed Sep 6, 2022
1 parent ae1c643 commit cb828a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions Transformer/InsertTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@ public function transform($entry) {
Minz_Log::error("GFYCAT API ERROR - {$href}");
}
} elseif (preg_match('#(?P<redgifs>redgifs.com/)(.*/)*(?P<token>[^/\-.]*)#', $href, $matches)) {
try {
$jsonResponse = file_get_contents("https://api.redgifs.com/v1/gfycats/{$matches['token']}");
$arrayResponse = json_decode($jsonResponse, true);

if (JSON_ERROR_NONE !== json_last_error()) {
throw new Exception();
}

$dom = $this->generateDom('Redgifs with token', [new Video('video/mp4', $arrayResponse['gfyItem']['mp4Url'])]);
$entry->_content("{$dom->saveHTML()}{$content->getRaw()}");
} catch (Exception $e) {
Minz_Log::error("REDGIFS API ERROR - {$href}");
}
// API has changed and this code does not work anymore.
// try {
// $jsonResponse = file_get_contents("https://api.redgifs.com/v1/gfycats/{$matches['token']}");
// $arrayResponse = json_decode($jsonResponse, true);

// if (JSON_ERROR_NONE !== json_last_error()) {
// throw new Exception();
// }

// $dom = $this->generateDom('Redgifs with token', [new Video('video/mp4', $arrayResponse['gfyItem']['mp4Url'])]);
// $entry->_content("{$dom->saveHTML()}{$content->getRaw()}");
// } catch (Exception $e) {
// Minz_Log::error("REDGIFS API ERROR - {$href}");
// }
} elseif (preg_match('#v.redd.it#', $href)) {
try {
$jsonResponse = file_get_contents("{$content->getCommentsLink()}.json");
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Reddit Image",
"author": "Alexis Degrugillier",
"description": "Modify reddit entries by displaying known medias and easing access to the linked resource",
"version": "0.11.1",
"version": "0.12.1",
"entrypoint": "RedditImage",
"type": "user"
}

0 comments on commit cb828a7

Please sign in to comment.