Use gallery API endpoint for gallery urls
This commit is contained in:
parent
ff1d4da362
commit
04e369a92d
1 changed files with 3 additions and 1 deletions
|
@ -5,7 +5,9 @@ from src import ModuleManager, utils
|
||||||
|
|
||||||
REGEX_IMAGE = re.compile("https?://(?:i\.)?imgur.com/(\w+)")
|
REGEX_IMAGE = re.compile("https?://(?:i\.)?imgur.com/(\w+)")
|
||||||
REGEX_GALLERY = re.compile("https?://imgur.com/gallery/(\w+)")
|
REGEX_GALLERY = re.compile("https?://imgur.com/gallery/(\w+)")
|
||||||
|
|
||||||
URL_IMAGE = "https://api.imgur.com/3/image/%s"
|
URL_IMAGE = "https://api.imgur.com/3/image/%s"
|
||||||
|
URL_GALLERY = "https://api.imgur.com/3/gallery/%s"
|
||||||
|
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
def _prefix(self, data):
|
def _prefix(self, data):
|
||||||
|
@ -35,7 +37,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
|
|
||||||
def _gallery_info(self, hash):
|
def _gallery_info(self, hash):
|
||||||
api_key = self.bot.config["imgur-api-key"]
|
api_key = self.bot.config["imgur-api-key"]
|
||||||
result = utils.http.get_url(URL_IMAGE % hash,
|
result = utils.http.get_url(URL_GALLERY % hash,
|
||||||
headers={"Authorization": "Client-ID %s" % api_key},
|
headers={"Authorization": "Client-ID %s" % api_key},
|
||||||
json=True)
|
json=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue