plugin XEP-0264: updated size to get values closest to standard one:

- sizes used for thumbnails are now matching common resolutions.
- added BIG and FULL_SCREEN sizes
- sort thumbnails by sizes when parsing them.
This commit is contained in:
Goffi 2020-08-13 23:45:59 +02:00
commit 7e404b9f98

View file

@ -70,8 +70,11 @@ PLUGIN_INFO = {
class XEP_0264(object):
SIZE_SMALL = (250, 250)
SIZE_MEDIUM = (1024, 1024)
SIZE_SMALL = (320, 320)
SIZE_MEDIUM = (640, 640)
SIZE_BIG = (1280, 1280)
SIZE_FULL_SCREEN = (2560, 2560)
SIZES = (SIZE_SMALL, SIZE_MEDIUM, SIZE_FULL_SCREEN)
def __init__(self, host):
log.info(_("Plugin XEP_0264 initialization"))
@ -108,7 +111,7 @@ class XEP_0264(object):
height = thumbnail_elt.getAttribute("height")
if width and height:
try:
thumbnail["size"] = int(width), int(height)
thumbnail["size"] = (int(width), int(height))
except ValueError:
pass
try:
@ -118,6 +121,8 @@ class XEP_0264(object):
thumbnails.append(thumbnail)
if thumbnails:
# we want thumbnails ordered from smallest to biggest
thumbnails.sort(key=lambda t: t.get('size', (0, 0)))
file_data.setdefault("extra", {})[C.KEY_THUMBNAILS] = thumbnails
return True