Skip to content

Instantly share code, notes, and snippets.

@emilyst
Last active December 29, 2015 14:19
Show Gist options
  • Save emilyst/7683017 to your computer and use it in GitHub Desktop.
Save emilyst/7683017 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python3
# save to: ~/Library/Application\ Scripts/com.codeux.irc.textual/gif.py
# use as '/gif searchterm'
# prints a link to the first GIF to match the term to the current window
import sys
import random
search_term = sys.argv[2]
from giphypop import Giphy
g = Giphy()
results = [ x for x in g.search(search_term) ]
chosen = random.choice(results)
print("Random GIF tagged with '" + search_term + "': " + chosen.media_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment