Skip to content

Instantly share code, notes, and snippets.

@scottames
Last active December 18, 2016 00:59
Show Gist options
  • Save scottames/99f2cdff6f1d3c95967453fc52e031b3 to your computer and use it in GitHub Desktop.
Save scottames/99f2cdff6f1d3c95967453fc52e031b3 to your computer and use it in GitHub Desktop.
Get Some Emojis
# -*- mode: ruby -*-
# vi: set ft=ruby :
## download emojis
## - supports emojipacks (https://github.com/lambtron/emojipacks/tree/master/packs)
## usage
## ruby get_some_emojis.rb emojipack.yaml
## download all emojis in emojipack.yaml to emojipack/
## (creates a new folder if one doesn't exist)
require 'yaml'
require 'net/http'
require 'uri'
require 'fileutils'
ARGV.each do |arg|
es = YAML.load_file(arg)
folder = File.basename(arg, ".*")
emojis = es["emojis"]
emojis.each do |emoji|
uri = URI.parse(emoji["src"])
response = Net::HTTP.get_response(uri)
filename = emoji["name"] + File.extname(emoji["src"])
Dir.mkdir(folder) unless File.exists?(folder)
puts folder + "/" + filename
File.write(folder + "/" + filename, response.body)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment