-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Added giphy.py to fetch gifs on a given topic #5378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
web_programming/giphy.py
Outdated
# Can be fetched from https://developers.giphy.com/dashboard/ | ||
|
||
|
||
def getgif(query: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file web_programming/giphy.py
, please provide doctest for the function getgif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding doctest will not be helpful in this scenario because the output(url of gif) is chosen at random.
[*]Added doctest [*]Formatted with black
web_programming/giphy.py
Outdated
Total urls received: 50 | ||
https://giphy.com/gifs/startrekfleetcommand-BPVIRni1Z70QO2nJMX | ||
""" | ||
qu: str = '+'.join(query.split(" ")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qu: str = '+'.join(query.split(" ")) | |
query = '+'.join(query.split(" ")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍🏻
@cclauss Made the changes. |
web_programming/giphy.py
Outdated
data = requests.get(url).json() | ||
url_data = [i["url"] for i in data["data"]] | ||
|
||
return url_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data = requests.get(url).json() | |
url_data = [i["url"] for i in data["data"]] | |
return url_data | |
return = [gif["url"] for gif in requests.get(url).json()["data"]] |
Co-authored-by: Christian Clauss <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
# Can be fetched from https://developers.giphy.com/dashboard/ | ||
|
||
|
||
def get_gifs(query: str, api_key: str = giphy_api_key) -> list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file web_programming/giphy.py
, please provide doctest for the function get_gifs
Thanks. Just 10 mins. I should probably add some |
It is OK. Not all errors need to be caught. This is relatively simple code so the errors should only be for:
|
Ohk. Thanks |
* Added giphy.py to fetch gifs on a given topic * Modified code [*]Added doctest [*]Formatted with black * Minor change * Minor refactoring to avoid name clash * Made necessary changes as per review * Update web_programming/giphy.py Co-authored-by: Christian Clauss <[email protected]> * Apply suggestions from code review * Final cleanup * Placate psf/black Co-authored-by: Christian Clauss <[email protected]>
Describe your change:
Added
giphy.py
script which can fetch a GIF from giphy on any given topicalgorithmscript?Checklist:
Fixes: #{$ISSUE_NO}
.