mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-04-05 09:44:13 +03:00
Update file.size to reflect the size of the largest thumbnail
This way we avoid relying on the order of the thumbnails, and just pick the largest.
This commit is contained in:
parent
b102f1f345
commit
ff3c21c805
|
@ -120,9 +120,11 @@ class File:
|
|||
def size(self):
|
||||
"""
|
||||
The size in bytes of this file.
|
||||
|
||||
For photos, this is the heaviest thumbnail, as it often repressents the largest dimensions.
|
||||
"""
|
||||
if isinstance(self.media, types.Photo):
|
||||
return utils._photo_size_byte_count(self.media.sizes[-1])
|
||||
return max(filter(None, map(utils._photo_size_byte_count, self.media.sizes)), default=None)
|
||||
elif isinstance(self.media, types.Document):
|
||||
return self.media.size
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user