diff options
| author | 2019-11-25 18:17:30 +0000 | |
|---|---|---|
| committer | 2019-11-25 18:17:30 +0000 | |
| commit | 6a6e789ec9e3c6dd365922ac630a405b830e8c1a (patch) | |
| tree | 7e2e1675d7d1fab7d4240da83c0179076f89c938 /modules/imgur.py | |
| parent | include <title> with !google/!g output (diff) | |
add `cookies` and `.json()` to utils.http.Response objects
Diffstat (limited to 'modules/imgur.py')
| -rw-r--r-- | modules/imgur.py | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/modules/imgur.py b/modules/imgur.py index 30208c36..35bb6329 100644 --- a/modules/imgur.py +++ b/modules/imgur.py @@ -48,11 +48,10 @@ class Module(ModuleManager.BaseModule): def _parse_gallery(self, hash): api_key = self.bot.config["imgur-api-key"] result = utils.http.request(URL_GALLERY % hash, - headers={"Authorization": "Client-ID %s" % api_key}, - json=True) + headers={"Authorization": "Client-ID %s" % api_key}).json() - if result and result.data["success"]: - data = result.data["data"] + if result and result["success"]: + data = result["data"] text = "" nsfw = utils.irc.bold(NSFW_TEXT) + " " if data["nsfw"] else "" @@ -75,11 +74,10 @@ class Module(ModuleManager.BaseModule): def _parse_image(self, hash): api_key = self.bot.config["imgur-api-key"] result = utils.http.request(URL_IMAGE % hash, - headers={"Authorization": "Client-ID %s" % api_key}, - json=True) + headers={"Authorization": "Client-ID %s" % api_key}).json() - if result and result.data["success"]: - data = result.data["data"] + if result and result["success"]: + data = result["data"] text = "" nsfw = utils.irc.bold(NSFW_TEXT) + " " if data["nsfw"] else "" @@ -102,11 +100,10 @@ class Module(ModuleManager.BaseModule): def _image_info(self, hash): api_key = self.bot.config["imgur-api-key"] result = utils.http.request(URL_IMAGE % hash, - headers={"Authorization": "Client-ID %s" % api_key}, - json=True) + headers={"Authorization": "Client-ID %s" % api_key}).json() - if result and result.data["success"]: - data = result.data["data"] + if result and result["success"]: + data = result["data"] text = self._prefix(data) text += "(%s %dx%d, %d views)" % (data["type"], data["width"], @@ -120,11 +117,10 @@ class Module(ModuleManager.BaseModule): def _gallery_info(self, hash): api_key = self.bot.config["imgur-api-key"] result = utils.http.request(URL_GALLERY % hash, - headers={"Authorization": "Client-ID %s" % api_key}, - json=True) + headers={"Authorization": "Client-ID %s" % api_key}).json() - if result and result.data["success"]: - data = result.data["data"] + if result and result["success"]: + data = result["data"] text = self._prefix(data) text += "(%d views, %d▲▼%d)" % (data["views"], data["ups"], data["downs"]) |
