From 4a896eb7e00bcdc078997a07c83b874bc90696ae Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Wed, 18 Oct 2017 21:41:19 -0400 Subject: [PATCH 1/3] Added giphy scipt --- giphy/.DS_Store | Bin 0 -> 6148 bytes giphy/README.md | 6 ++++++ giphy/main.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 giphy/.DS_Store create mode 100644 giphy/README.md create mode 100644 giphy/main.py diff --git a/giphy/.DS_Store b/giphy/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c2b6f423b228eabab336257b1c66676f86c8db55 GIT binary patch literal 6148 zcmeHK&2G~`5Z+A#IPJvnO>5kkn`B)ubqFNE-*gpC%O-w5@S zUXX_KYyc&VahU7pNv;#z(||1N&j77mQ%prB3Nig<{l1{@7PN7GZYHvdOJ?QBt@F2J zl&iApbiT^QM)T6;D_(1Ji!T4_=F@1XXHgYbld>0&pO`z9W{I==aW!1pkF?HLcAOlk zY&P((@9Uz9RgsN}z zVQtZD9cWAm0Bpi-1h)D02L|K-h7N0s@Ia(Z1=>{UN(|{L2WivMAG-M3qD>dlJQ?G- zCrekMNLP5sz=R7KTI7})UfNDR8Pv`%GKiB^zh#O{r8TdaLkj;bWpoh7+v-QF( v>8uT)&!8j}S6f`Az%WNKV(BQ}h8lrCAOjdWtS!O=;U57*12@dTUuEDs)FNvK literal 0 HcmV?d00001 diff --git a/giphy/README.md b/giphy/README.md new file mode 100644 index 0000000..8c04289 --- /dev/null +++ b/giphy/README.md @@ -0,0 +1,6 @@ +# Giphy +Simple command line program that searches giphy for a gif matching terms input by the user. Upon entering search terms, the program will open the browser to a gif hosted on giphy.com + +# To Use +- `source venv/bin/activate` +- `python main.py` \ No newline at end of file diff --git a/giphy/main.py b/giphy/main.py new file mode 100644 index 0000000..1f36327 --- /dev/null +++ b/giphy/main.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +import requests +import json +import os, platform + +HOST = "http://api.giphy.com/v1/gifs/search" +PUBLIC_KEY = "dc6zaTOxFJmzC" + +query = raw_input("Search giphy: ") + +payload = {'q': query, + 'rating': 'r', + 'api_key': PUBLIC_KEY, + 'limit': 1 +} + +res = requests.get(HOST, params=payload) +res = res.json() + +for k, v in res.items(): + if k == "data": + data = v[0] + for i, j in data.items(): + if i == "url": + url = j +#url = res['data']['url'] + +if platform.system() == "Darwin": + os.system("open %s" % url) +elif platform.system() == "Linux": + os.system("xdg-open %s" % url) +else: + print("u fukin pleb...jk") + try: + os.system("start %s" % url) + except OSError as e: + print("You done goofed: {0}".format(e)) + From 437fa83728b8bd810a6a1ae197bfd3fd0542829b Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Wed, 18 Oct 2017 21:45:40 -0400 Subject: [PATCH 2/3] Add gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file From 64a327833fa638ec5b08c51b985000fa9d4f7db0 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Wed, 18 Oct 2017 21:47:06 -0400 Subject: [PATCH 3/3] removed DS_Store file --- giphy/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 giphy/.DS_Store diff --git a/giphy/.DS_Store b/giphy/.DS_Store deleted file mode 100644 index c2b6f423b228eabab336257b1c66676f86c8db55..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK&2G~`5Z+A#IPJvnO>5kkn`B)ubqFNE-*gpC%O-w5@S zUXX_KYyc&VahU7pNv;#z(||1N&j77mQ%prB3Nig<{l1{@7PN7GZYHvdOJ?QBt@F2J zl&iApbiT^QM)T6;D_(1Ji!T4_=F@1XXHgYbld>0&pO`z9W{I==aW!1pkF?HLcAOlk zY&P((@9Uz9RgsN}z zVQtZD9cWAm0Bpi-1h)D02L|K-h7N0s@Ia(Z1=>{UN(|{L2WivMAG-M3qD>dlJQ?G- zCrekMNLP5sz=R7KTI7})UfNDR8Pv`%GKiB^zh#O{r8TdaLkj;bWpoh7+v-QF( v>8uT)&!8j}S6f`Az%WNKV(BQ}h8lrCAOjdWtS!O=;U57*12@dTUuEDs)FNvK