Use gallery API endpoint for gallery urls

This commit is contained in:
jesopo 2018-10-31 17:44:21 +00:00
parent ff1d4da362
commit 04e369a92d

View file

@ -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)