Skip to content

Instantly share code, notes, and snippets.

@Red5d
Created July 14, 2015 21:41
Show Gist options
  • Save Red5d/95e6009708f60d2a1b40 to your computer and use it in GitHub Desktop.
Save Red5d/95e6009708f60d2a1b40 to your computer and use it in GitHub Desktop.
CLI python tool for using the http://memegen.link/ meme generator service.
#! /usr/bin/env python
# Author: Red5d
# Client tool for the http://memegen.link/ service.
# Run with no parameters for help.
import json, sys, urllib
if len(sys.argv) < 2:
r = urllib.urlopen("http://memegen.link/templates")
templates = json.loads(r.readlines()[0])
print "Usage: memegen <template> <toptext> <bottomtext>"
print "Templates:"
for item in templates.keys():
print "\t"+templates[item].split("templates/")[1].ljust(20)+item
else:
r = urllib.urlopen("http://memegen.link/"+sys.argv[1]+"/"+sys.argv[2].replace(" ", "-")+"/"+sys.argv[3].replace(" ", "-"))
print json.loads(r.readlines()[0])['direct']['masked']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment