deemix-py/deemix/types/Picture.py

30 lines
777 B
Python
Raw Normal View History

2021-01-31 16:59:15 +00:00
class Picture:
def __init__(self, md5="", pic_type=""):
2021-01-31 16:59:15 +00:00
self.md5 = md5
self.type = pic_type
2021-01-31 16:59:15 +00:00
def getURL(self, size, pic_format):
url = "https://e-cdns-images.dzcdn.net/images/{}/{}/{size}x{size}".format(
self.type,
self.md5,
size=size
)
if pic_format.startswith("jpg"):
quality = 80
if '-' in pic_format:
quality = pic_format[4:]
pic_format = 'jpg'
return url + f'-000000-{quality}-0-0.jpg'
if pic_format == 'png':
return url + '-none-100-0-0.png'
return url+'.jpg'
class StaticPicture:
def __init__(self, url):
self.staticURL = url
def getURL(self):
return self.staticURL