2021-01-31 16:59:15 +00:00
|
|
|
class Picture:
|
2021-04-10 09:53:52 +00:00
|
|
|
def __init__(self, md5="", pic_type="", url=None):
|
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
|
|
|
self.staticUrl = url
|
2021-01-31 16:59:15 +00:00
|
|
|
|
2021-04-10 09:53:52 +00:00
|
|
|
def generatePictureURL(self, size, pic_format):
|
2021-03-13 10:54:01 +00:00
|
|
|
if self.staticUrl: return self.staticUrl
|
|
|
|
|
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'
|