2021-01-31 16:59:15 +00:00
|
|
|
class Picture:
|
2021-06-07 18:25:51 +00:00
|
|
|
def __init__(self, md5="", pic_type=""):
|
2021-01-31 16:59:15 +00:00
|
|
|
self.md5 = md5
|
2021-04-10 09:53:52 +00:00
|
|
|
self.type = pic_type
|
2021-03-13 10:54:01 +00:00
|
|
|
|
2021-06-07 18:25:51 +00:00
|
|
|
def getURL(self, size, pic_format):
|
2021-04-10 09:53:52 +00:00
|
|
|
url = "https://e-cdns-images.dzcdn.net/images/{}/{}/{size}x{size}".format(
|
2021-03-13 10:54:01 +00:00
|
|
|
self.type,
|
|
|
|
self.md5,
|
2021-04-10 09:53:52 +00:00
|
|
|
size=size
|
2021-03-13 10:54:01 +00:00
|
|
|
)
|
|
|
|
|
2021-04-10 09:53:52 +00:00
|
|
|
if pic_format.startswith("jpg"):
|
2021-03-24 16:41:03 +00:00
|
|
|
quality = 80
|
2021-04-10 09:53:52 +00:00
|
|
|
if '-' in pic_format:
|
|
|
|
quality = pic_format[4:]
|
|
|
|
pic_format = 'jpg'
|
2021-03-13 10:54:01 +00:00
|
|
|
return url + f'-000000-{quality}-0-0.jpg'
|
2021-04-10 09:53:52 +00:00
|
|
|
if pic_format == 'png':
|
2021-03-13 10:54:01 +00:00
|
|
|
return url + '-none-100-0-0.png'
|
|
|
|
|
|
|
|
return url+'.jpg'
|
2021-06-07 18:25:51 +00:00
|
|
|
|
|
|
|
class StaticPicture:
|
|
|
|
def __init__(self, url):
|
|
|
|
self.staticURL = url
|
|
|
|
|
|
|
|
def getURL(self):
|
|
|
|
return self.staticURL
|