Created
November 8, 2012 21:46
-
-
Save pjaspers/4041893 to your computer and use it in GitHub Desktop.
Quickly take a maxgif url to boom.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# | |
# Takes an URL from http://maxgif.com and copies the url of the shown gif | |
# | |
unless ARGV[0] | |
banner = <<BANNER | |
Takes a http://maxfig.com url and copies the direct link to the GIF. If | |
supplied a second argument, it is used as the name in `boom`. | |
mx <maxgif url> <optional name> | |
BANNER | |
abort banner | |
end | |
unless ARGV[0] =~ /maxgif.com/ | |
puts "Not a maxgif.com url, YMMV" | |
end | |
require 'open-uri' | |
require 'cgi' | |
url = ARGV[0] | |
name = ARGV[1] | |
source = `curl -sL #{url} | grep "og:image"` | |
gif = CGI.unescapeHTML(source.match(/content="(.+)(" property)/)[1]) | |
system("printf '%s' '#{gif.strip}' | pbcopy") | |
if name | |
system("boom gifs #{name} #{gif}") | |
else | |
puts "Copied #{gif}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment