From 633327ce4bb9a3f858f16d517c0ff9f865efea23 Mon Sep 17 00:00:00 2001 From: Jaydeep Das Date: Sun, 17 Oct 2021 20:32:19 +0530 Subject: [PATCH 1/9] Added giphy.py to fetch gifs on a given topic --- web_programming/giphy.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 web_programming/giphy.py diff --git a/web_programming/giphy.py b/web_programming/giphy.py new file mode 100644 index 000000000000..fe231f96a9ad --- /dev/null +++ b/web_programming/giphy.py @@ -0,0 +1,29 @@ +#!/bin/python +import random +import json +import requests + + +api_key = "YOUR GIPHY API KEY" +# Can be fetched from https://developers.giphy.com/dashboard/ + + +def getgif(query: str) -> str: + """ + Get 1 URL of GIF on a given `query` + + ❯ python giphy.py + Topic: space+ship + Total urls received: 50 + https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX + """ + qu: str = '+'.join(query.split(" ")) + print("Topic: ", qu) + url: str = f"http://api.giphy.com/v1/gifs/search?q={qu}&api_key={api_key}" + jsdata = requests.get(url) + data: dict = json.loads(jsdata.content) + print("Total urls received: ", len(data['data'])) + return data['data'][random.randint(0, 49)]['url'] + + +print(getgif("space ship")) From 6f619cbf3d3a22c6045dc02d7a36ee64111b3282 Mon Sep 17 00:00:00 2001 From: Jaydeep Das Date: Sun, 17 Oct 2021 20:51:21 +0530 Subject: [PATCH 2/9] Modified code [*]Added doctest [*]Formatted with black --- web_programming/giphy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web_programming/giphy.py b/web_programming/giphy.py index fe231f96a9ad..26adf8c5318b 100644 --- a/web_programming/giphy.py +++ b/web_programming/giphy.py @@ -12,18 +12,18 @@ def getgif(query: str) -> str: """ Get 1 URL of GIF on a given `query` - ❯ python giphy.py + >>> getgif("space ship") Topic: space+ship Total urls received: 50 https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX """ - qu: str = '+'.join(query.split(" ")) + qu: str = "+".join(query.split(" ")) print("Topic: ", qu) url: str = f"http://api.giphy.com/v1/gifs/search?q={qu}&api_key={api_key}" jsdata = requests.get(url) data: dict = json.loads(jsdata.content) - print("Total urls received: ", len(data['data'])) - return data['data'][random.randint(0, 49)]['url'] + print("Total urls received: ", len(data["data"])) + return data["data"][random.randint(0, 49)]["url"] print(getgif("space ship")) From e43618af6d74ca39b40aa6732c6c9955c5bebf66 Mon Sep 17 00:00:00 2001 From: Jaydeep Das Date: Sun, 17 Oct 2021 20:53:55 +0530 Subject: [PATCH 3/9] Minor change --- web_programming/giphy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_programming/giphy.py b/web_programming/giphy.py index 26adf8c5318b..7350c52f9101 100644 --- a/web_programming/giphy.py +++ b/web_programming/giphy.py @@ -17,9 +17,9 @@ def getgif(query: str) -> str: Total urls received: 50 https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX """ - qu: str = "+".join(query.split(" ")) - print("Topic: ", qu) - url: str = f"http://api.giphy.com/v1/gifs/search?q={qu}&api_key={api_key}" + query: str = "+".join(query.split(" ")) + print("Topic: ", query) + url: str = f"http://api.giphy.com/v1/gifs/search?q={query}&api_key={api_key}" jsdata = requests.get(url) data: dict = json.loads(jsdata.content) print("Total urls received: ", len(data["data"])) From 25c9d3b398449464b3140834ceece64294393d80 Mon Sep 17 00:00:00 2001 From: Jaydeep Das Date: Sun, 17 Oct 2021 20:59:06 +0530 Subject: [PATCH 4/9] Minor refactoring to avoid name clash --- web_programming/giphy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_programming/giphy.py b/web_programming/giphy.py index 7350c52f9101..add1ea8a6baa 100644 --- a/web_programming/giphy.py +++ b/web_programming/giphy.py @@ -17,9 +17,9 @@ def getgif(query: str) -> str: Total urls received: 50 https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX """ - query: str = "+".join(query.split(" ")) - print("Topic: ", query) - url: str = f"http://api.giphy.com/v1/gifs/search?q={query}&api_key={api_key}" + formatted_query: str = "+".join(query.split(" ")) + print("Topic: ", formatted_query) + url: str = f"http://api.giphy.com/v1/gifs/search?q={formatted_query}&api_key={api_key}" jsdata = requests.get(url) data: dict = json.loads(jsdata.content) print("Total urls received: ", len(data["data"])) From 20467530c9d08f311a57eca8786fef66349edc5f Mon Sep 17 00:00:00 2001 From: Jaydeep Das Date: Mon, 18 Oct 2021 08:16:03 +0530 Subject: [PATCH 5/9] Made necessary changes as per review --- web_programming/giphy.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/web_programming/giphy.py b/web_programming/giphy.py index add1ea8a6baa..6fc00c45d30d 100644 --- a/web_programming/giphy.py +++ b/web_programming/giphy.py @@ -1,29 +1,25 @@ #!/bin/python -import random -import json import requests -api_key = "YOUR GIPHY API KEY" +api_key = "YOUR API KEY" # Can be fetched from https://developers.giphy.com/dashboard/ -def getgif(query: str) -> str: +def getgif(query: str) -> list: """ - Get 1 URL of GIF on a given `query` + Get a list of URLs of GIF on a given `query` - >>> getgif("space ship") - Topic: space+ship - Total urls received: 50 - https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX + >>> getgif("space ship") + ['https://giphy.com/gifs/studiosoriginals-3ov9jPghXAsbvLmcjm', 'https://giphy.com/gifs/primevideo-the-expanse-theexpanse-2daHMQ9QPwmoSsRYWZ', 'https://giphy.com/gifs/newyorker-space-rocket-bkgsATGfFyrKUf1IsO', 'https://giphy.com/gifs/CBSAllAccess-star-trek-startrek-discovery-pI9dBz15pbGJg03LnE', 'https://giphy.com/gifs/nowthis-aliens-ufo-unidentified-flying-object-TZnOtiTDAnsQUwLs3j', 'https://giphy.com/gifs/DrSquatchSoapCo-mars-bar-marsbar-bars-H1k0w5P3beQHf8OIrr', 'https://giphy.com/gifs/heyduggee-hey-duggee-thespacebadge-XaMTNZkRahZ7ysPMci', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-series-12-PkS3n3TERbjIntnx9E', 'https://giphy.com/gifs/startrekfleetcommand-H03zikfKQPxzuS4ZcE', 'https://giphy.com/gifs/startrekfleetcommand-htJzM2rN0DgbS8g8nC', 'https://giphy.com/gifs/animation-space-weird-RIUZHIBmReqsnztdW2', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-series-12-Vi0EFzgMLWhMOo76SE', 'https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX', 'https://giphy.com/gifs/lego-star-wars-space-SiEz6hxdcJuOf2n3TE', 'https://giphy.com/gifs/nickelodeon-space-astronauts-life-in-krr7nv4iK6Hw2vK5S6', 'https://giphy.com/gifs/rocket-space-ship-X0oEvTEdLj2YU', 'https://giphy.com/gifs/southparkgifs-l2Sqed5gI8GMP09So', 'https://giphy.com/gifs/S3bZdGN7y2MQyNgPF1', 'https://giphy.com/gifs/heyduggee-hey-duggee-thespacebadge-MB0tFoeiKyrdhWAXPM', 'https://giphy.com/gifs/star-wars-teddy-bear-tie-fighter-EpGU43iHxzKrZe3yVv', 'https://giphy.com/gifs/thesims-the-sims-thesimsxstarwars-thesims4starwarsjourneytobatuu-THCL5K4oXsF90sps16', 'https://giphy.com/gifs/time-regret-machine-73h4dfm9DaTRrhFko9', 'https://giphy.com/gifs/space-universe-rocket-l41m6oJBtKRm1NseA', 'https://giphy.com/gifs/thesims-ts-sims-the-Xy21pj6ClKwkz2KsQC', 'https://giphy.com/gifs/CBeebiesHQ-cbeebies-button-clangers-ZEr5tiKWdvpfYa2L9V', 'https://giphy.com/gifs/doctorwho-doctor-who-dalek-daleks-a5EPJWqRznZw6SVXzG', 'https://giphy.com/gifs/peanuts-snoopy-woodstock-in-space-X1gjuOGjIZioNcqKCG', 'https://giphy.com/gifs/funny-weird-aliens-26xBQ7d3MeECbUpCU', 'https://giphy.com/gifs/CBSAllAccess-star-trek-discovery-BHJ8BRu1CgTjoDfvoo', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-doctors-wife-L1Phzvvp8Zjfvgr2uy', 'https://giphy.com/gifs/startrekfleetcommand-NRfbanUlUPvdqLzd8O', 'https://giphy.com/gifs/CBeebiesHQ-space-wow-fCUBPlsv3FTkDqtgYG', 'https://giphy.com/gifs/startrekfleetcommand-4v1pOaMg4Z1pOUFK5K', 'https://giphy.com/gifs/animation-happy-K4HqMo1UoOjew', 'https://giphy.com/gifs/ralph-stairs-space-ship-flight-of-the-navigator-jsqUVil8tURoyQ9t1C', 'https://giphy.com/gifs/shocked-surprised-cow-jrht6TXUa0SYlVZFnQ', 'https://giphy.com/gifs/PERQDOTCOM-perq-bot-perqbot-fJ5veFeMaJd3UXGfc3', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-322VVjQkldB9IvPmbX', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-fires-of-pompeii-jsl7zjaaK6IlSdbWeb', 'https://giphy.com/gifs/usnationalarchives-launch-apollo-11-blast-off-l3vR6QzrzOvAD8I7K', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-22OMufnulfcTGUErzG', 'https://giphy.com/gifs/doctor-who-pretty-time-kxAX99ncvbPk4', 'https://giphy.com/gifs/rocket-launch-spaceship-TRdADd4gJOQteAeY0z', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-doctors-wife-YOGLP2Z7eaMRDsPwmD', 'https://giphy.com/gifs/rocket-austin-powers-UtymVt10zlXPCo6FL3', 'https://giphy.com/gifs/AdVentureCapitalistHH-capitalism-adcap-adventure-capitalist-4EJXnSY3oPsQ4xvpfa', 'https://giphy.com/gifs/ralph-scifi-space-ship-xT1Ra1Nu4MaJqHIBgY', 'https://giphy.com/gifs/world-spacex-grasshopper-huvlSnGxC0rT2', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-7TiefcAB5P4nlV1Ok5', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-8vLnUghW4aamUxtTy2'] """ - formatted_query: str = "+".join(query.split(" ")) - print("Topic: ", formatted_query) - url: str = f"http://api.giphy.com/v1/gifs/search?q={formatted_query}&api_key={api_key}" - jsdata = requests.get(url) - data: dict = json.loads(jsdata.content) - print("Total urls received: ", len(data["data"])) - return data["data"][random.randint(0, 49)]["url"] + formatted_query = "+".join(query.split(" ")) + url = f"http://api.giphy.com/v1/gifs/search?q={formatted_query}&api_key={api_key}" + data = requests.get(url).json() + url_data = [i["url"] for i in data["data"]] + return url_data -print(getgif("space ship")) + +if __name__ == "__main__": + print(getgif("space ship")) From 157e0f6ebd93c9890f0755cb86ec535147de9bd2 Mon Sep 17 00:00:00 2001 From: Jaydeep Das Date: Mon, 18 Oct 2021 12:30:43 +0530 Subject: [PATCH 6/9] Update web_programming/giphy.py Co-authored-by: Christian Clauss --- web_programming/giphy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/giphy.py b/web_programming/giphy.py index 6fc00c45d30d..e81f7681a368 100644 --- a/web_programming/giphy.py +++ b/web_programming/giphy.py @@ -1,4 +1,4 @@ -#!/bin/python +#!/usr/bin/env python3 import requests From c44299c3a36611847718a9e7f441a74ae4e51a4a Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 18 Oct 2021 09:03:29 +0200 Subject: [PATCH 7/9] Apply suggestions from code review --- web_programming/giphy.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/web_programming/giphy.py b/web_programming/giphy.py index e81f7681a368..8f4bc118b972 100644 --- a/web_programming/giphy.py +++ b/web_programming/giphy.py @@ -2,24 +2,22 @@ import requests -api_key = "YOUR API KEY" +giphy_api_key = "YOUR API KEY" # Can be fetched from https://developers.giphy.com/dashboard/ -def getgif(query: str) -> list: +def get_gifs(query: str, api_key : str = giphy_api_key) -> list: """ Get a list of URLs of GIF on a given `query` >>> getgif("space ship") ['https://giphy.com/gifs/studiosoriginals-3ov9jPghXAsbvLmcjm', 'https://giphy.com/gifs/primevideo-the-expanse-theexpanse-2daHMQ9QPwmoSsRYWZ', 'https://giphy.com/gifs/newyorker-space-rocket-bkgsATGfFyrKUf1IsO', 'https://giphy.com/gifs/CBSAllAccess-star-trek-startrek-discovery-pI9dBz15pbGJg03LnE', 'https://giphy.com/gifs/nowthis-aliens-ufo-unidentified-flying-object-TZnOtiTDAnsQUwLs3j', 'https://giphy.com/gifs/DrSquatchSoapCo-mars-bar-marsbar-bars-H1k0w5P3beQHf8OIrr', 'https://giphy.com/gifs/heyduggee-hey-duggee-thespacebadge-XaMTNZkRahZ7ysPMci', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-series-12-PkS3n3TERbjIntnx9E', 'https://giphy.com/gifs/startrekfleetcommand-H03zikfKQPxzuS4ZcE', 'https://giphy.com/gifs/startrekfleetcommand-htJzM2rN0DgbS8g8nC', 'https://giphy.com/gifs/animation-space-weird-RIUZHIBmReqsnztdW2', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-series-12-Vi0EFzgMLWhMOo76SE', 'https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX', 'https://giphy.com/gifs/lego-star-wars-space-SiEz6hxdcJuOf2n3TE', 'https://giphy.com/gifs/nickelodeon-space-astronauts-life-in-krr7nv4iK6Hw2vK5S6', 'https://giphy.com/gifs/rocket-space-ship-X0oEvTEdLj2YU', 'https://giphy.com/gifs/southparkgifs-l2Sqed5gI8GMP09So', 'https://giphy.com/gifs/S3bZdGN7y2MQyNgPF1', 'https://giphy.com/gifs/heyduggee-hey-duggee-thespacebadge-MB0tFoeiKyrdhWAXPM', 'https://giphy.com/gifs/star-wars-teddy-bear-tie-fighter-EpGU43iHxzKrZe3yVv', 'https://giphy.com/gifs/thesims-the-sims-thesimsxstarwars-thesims4starwarsjourneytobatuu-THCL5K4oXsF90sps16', 'https://giphy.com/gifs/time-regret-machine-73h4dfm9DaTRrhFko9', 'https://giphy.com/gifs/space-universe-rocket-l41m6oJBtKRm1NseA', 'https://giphy.com/gifs/thesims-ts-sims-the-Xy21pj6ClKwkz2KsQC', 'https://giphy.com/gifs/CBeebiesHQ-cbeebies-button-clangers-ZEr5tiKWdvpfYa2L9V', 'https://giphy.com/gifs/doctorwho-doctor-who-dalek-daleks-a5EPJWqRznZw6SVXzG', 'https://giphy.com/gifs/peanuts-snoopy-woodstock-in-space-X1gjuOGjIZioNcqKCG', 'https://giphy.com/gifs/funny-weird-aliens-26xBQ7d3MeECbUpCU', 'https://giphy.com/gifs/CBSAllAccess-star-trek-discovery-BHJ8BRu1CgTjoDfvoo', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-doctors-wife-L1Phzvvp8Zjfvgr2uy', 'https://giphy.com/gifs/startrekfleetcommand-NRfbanUlUPvdqLzd8O', 'https://giphy.com/gifs/CBeebiesHQ-space-wow-fCUBPlsv3FTkDqtgYG', 'https://giphy.com/gifs/startrekfleetcommand-4v1pOaMg4Z1pOUFK5K', 'https://giphy.com/gifs/animation-happy-K4HqMo1UoOjew', 'https://giphy.com/gifs/ralph-stairs-space-ship-flight-of-the-navigator-jsqUVil8tURoyQ9t1C', 'https://giphy.com/gifs/shocked-surprised-cow-jrht6TXUa0SYlVZFnQ', 'https://giphy.com/gifs/PERQDOTCOM-perq-bot-perqbot-fJ5veFeMaJd3UXGfc3', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-322VVjQkldB9IvPmbX', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-fires-of-pompeii-jsl7zjaaK6IlSdbWeb', 'https://giphy.com/gifs/usnationalarchives-launch-apollo-11-blast-off-l3vR6QzrzOvAD8I7K', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-22OMufnulfcTGUErzG', 'https://giphy.com/gifs/doctor-who-pretty-time-kxAX99ncvbPk4', 'https://giphy.com/gifs/rocket-launch-spaceship-TRdADd4gJOQteAeY0z', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-doctors-wife-YOGLP2Z7eaMRDsPwmD', 'https://giphy.com/gifs/rocket-austin-powers-UtymVt10zlXPCo6FL3', 'https://giphy.com/gifs/AdVentureCapitalistHH-capitalism-adcap-adventure-capitalist-4EJXnSY3oPsQ4xvpfa', 'https://giphy.com/gifs/ralph-scifi-space-ship-xT1Ra1Nu4MaJqHIBgY', 'https://giphy.com/gifs/world-spacex-grasshopper-huvlSnGxC0rT2', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-7TiefcAB5P4nlV1Ok5', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-8vLnUghW4aamUxtTy2'] """ - formatted_query = "+".join(query.split(" ")) + formatted_query = "+".join(query.split()) url = f"http://api.giphy.com/v1/gifs/search?q={formatted_query}&api_key={api_key}" - data = requests.get(url).json() - url_data = [i["url"] for i in data["data"]] - - return url_data + gifs = requests.get(url).json()["data"] + return [gif["url"] for gif in gifs] if __name__ == "__main__": - print(getgif("space ship")) + print("\n".join(get_gifs("space ship"))) From 6dd357a16b30fc06f9c5cb3873bec55133a7b652 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 18 Oct 2021 09:06:58 +0200 Subject: [PATCH 8/9] Final cleanup --- web_programming/giphy.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/web_programming/giphy.py b/web_programming/giphy.py index 8f4bc118b972..3cb08341adf1 100644 --- a/web_programming/giphy.py +++ b/web_programming/giphy.py @@ -1,17 +1,13 @@ #!/usr/bin/env python3 import requests - giphy_api_key = "YOUR API KEY" # Can be fetched from https://developers.giphy.com/dashboard/ def get_gifs(query: str, api_key : str = giphy_api_key) -> list: """ - Get a list of URLs of GIF on a given `query` - - >>> getgif("space ship") - ['https://giphy.com/gifs/studiosoriginals-3ov9jPghXAsbvLmcjm', 'https://giphy.com/gifs/primevideo-the-expanse-theexpanse-2daHMQ9QPwmoSsRYWZ', 'https://giphy.com/gifs/newyorker-space-rocket-bkgsATGfFyrKUf1IsO', 'https://giphy.com/gifs/CBSAllAccess-star-trek-startrek-discovery-pI9dBz15pbGJg03LnE', 'https://giphy.com/gifs/nowthis-aliens-ufo-unidentified-flying-object-TZnOtiTDAnsQUwLs3j', 'https://giphy.com/gifs/DrSquatchSoapCo-mars-bar-marsbar-bars-H1k0w5P3beQHf8OIrr', 'https://giphy.com/gifs/heyduggee-hey-duggee-thespacebadge-XaMTNZkRahZ7ysPMci', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-series-12-PkS3n3TERbjIntnx9E', 'https://giphy.com/gifs/startrekfleetcommand-H03zikfKQPxzuS4ZcE', 'https://giphy.com/gifs/startrekfleetcommand-htJzM2rN0DgbS8g8nC', 'https://giphy.com/gifs/animation-space-weird-RIUZHIBmReqsnztdW2', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-series-12-Vi0EFzgMLWhMOo76SE', 'https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX', 'https://giphy.com/gifs/lego-star-wars-space-SiEz6hxdcJuOf2n3TE', 'https://giphy.com/gifs/nickelodeon-space-astronauts-life-in-krr7nv4iK6Hw2vK5S6', 'https://giphy.com/gifs/rocket-space-ship-X0oEvTEdLj2YU', 'https://giphy.com/gifs/southparkgifs-l2Sqed5gI8GMP09So', 'https://giphy.com/gifs/S3bZdGN7y2MQyNgPF1', 'https://giphy.com/gifs/heyduggee-hey-duggee-thespacebadge-MB0tFoeiKyrdhWAXPM', 'https://giphy.com/gifs/star-wars-teddy-bear-tie-fighter-EpGU43iHxzKrZe3yVv', 'https://giphy.com/gifs/thesims-the-sims-thesimsxstarwars-thesims4starwarsjourneytobatuu-THCL5K4oXsF90sps16', 'https://giphy.com/gifs/time-regret-machine-73h4dfm9DaTRrhFko9', 'https://giphy.com/gifs/space-universe-rocket-l41m6oJBtKRm1NseA', 'https://giphy.com/gifs/thesims-ts-sims-the-Xy21pj6ClKwkz2KsQC', 'https://giphy.com/gifs/CBeebiesHQ-cbeebies-button-clangers-ZEr5tiKWdvpfYa2L9V', 'https://giphy.com/gifs/doctorwho-doctor-who-dalek-daleks-a5EPJWqRznZw6SVXzG', 'https://giphy.com/gifs/peanuts-snoopy-woodstock-in-space-X1gjuOGjIZioNcqKCG', 'https://giphy.com/gifs/funny-weird-aliens-26xBQ7d3MeECbUpCU', 'https://giphy.com/gifs/CBSAllAccess-star-trek-discovery-BHJ8BRu1CgTjoDfvoo', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-doctors-wife-L1Phzvvp8Zjfvgr2uy', 'https://giphy.com/gifs/startrekfleetcommand-NRfbanUlUPvdqLzd8O', 'https://giphy.com/gifs/CBeebiesHQ-space-wow-fCUBPlsv3FTkDqtgYG', 'https://giphy.com/gifs/startrekfleetcommand-4v1pOaMg4Z1pOUFK5K', 'https://giphy.com/gifs/animation-happy-K4HqMo1UoOjew', 'https://giphy.com/gifs/ralph-stairs-space-ship-flight-of-the-navigator-jsqUVil8tURoyQ9t1C', 'https://giphy.com/gifs/shocked-surprised-cow-jrht6TXUa0SYlVZFnQ', 'https://giphy.com/gifs/PERQDOTCOM-perq-bot-perqbot-fJ5veFeMaJd3UXGfc3', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-322VVjQkldB9IvPmbX', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-fires-of-pompeii-jsl7zjaaK6IlSdbWeb', 'https://giphy.com/gifs/usnationalarchives-launch-apollo-11-blast-off-l3vR6QzrzOvAD8I7K', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-22OMufnulfcTGUErzG', 'https://giphy.com/gifs/doctor-who-pretty-time-kxAX99ncvbPk4', 'https://giphy.com/gifs/rocket-launch-spaceship-TRdADd4gJOQteAeY0z', 'https://giphy.com/gifs/doctorwho-doctor-who-dr-the-doctors-wife-YOGLP2Z7eaMRDsPwmD', 'https://giphy.com/gifs/rocket-austin-powers-UtymVt10zlXPCo6FL3', 'https://giphy.com/gifs/AdVentureCapitalistHH-capitalism-adcap-adventure-capitalist-4EJXnSY3oPsQ4xvpfa', 'https://giphy.com/gifs/ralph-scifi-space-ship-xT1Ra1Nu4MaJqHIBgY', 'https://giphy.com/gifs/world-spacex-grasshopper-huvlSnGxC0rT2', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-7TiefcAB5P4nlV1Ok5', 'https://giphy.com/gifs/SignatureEntertainmentUK-wesley-snipes-the-recall-final-8vLnUghW4aamUxtTy2'] + Get a list of URLs of GIFs based on a given query.. """ formatted_query = "+".join(query.split()) url = f"http://api.giphy.com/v1/gifs/search?q={formatted_query}&api_key={api_key}" From 8eb25e746dc80ed85658b8fec0ee07d637e6e5a4 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 18 Oct 2021 09:12:33 +0200 Subject: [PATCH 9/9] Placate psf/black --- web_programming/giphy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/giphy.py b/web_programming/giphy.py index 3cb08341adf1..dc8c6be08caa 100644 --- a/web_programming/giphy.py +++ b/web_programming/giphy.py @@ -5,7 +5,7 @@ # Can be fetched from https://developers.giphy.com/dashboard/ -def get_gifs(query: str, api_key : str = giphy_api_key) -> list: +def get_gifs(query: str, api_key: str = giphy_api_key) -> list: """ Get a list of URLs of GIFs based on a given query.. """