added support for more sizes + smoother gifs

This commit is contained in:
Juan 2023-07-25 21:31:20 -04:00
parent ce79e80f2a
commit 8e7789d4b5
2 changed files with 33 additions and 49 deletions

View file

@ -3,25 +3,28 @@ import requests
def get_webp_url(url):
emote_id = url[23:]
api_call = ('https://7tv.io/v3/emotes/' + emote_id)
api_call = "https://7tv.io/v3/emotes/" + emote_id
response = requests.get(api_call).json()
image_url = response["host"]["url"]
max_name = ""
max_size = 262144
image_url = response['host']['url']
for file in response['host']['files']:
if file['width'] == 128 and file['name'][3:] == 'webp':
return ('https:' + image_url + '/' + file['name'])
for file in response["host"]["files"]:
if (
file["width"] <= 128 and file["height"] <= 128 and file["size"] <= max_size
) and file["name"][3:] == "webp":
max_name = file["name"]
print(max_size)
return "https:" + image_url + "/" + max_name
return ('No 128x128 file detected')
def get_emote_name(url):
emote_id = url[23:]
api_call = ('https://7tv.io/v3/emotes/' + emote_id)
api_call = "https://7tv.io/v3/emotes/" + emote_id
response = requests.get(api_call).json()
emote_name = response['name']
emote_name = response["name"]
return emote_name