mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 01:46:35 +03:00
Support both str and VideoSize as thumb on download_media
This commit is contained in:
parent
3c56a6db4d
commit
0cefc73448
|
@ -634,8 +634,10 @@ class DownloadMethods:
|
||||||
return thumbs[-1]
|
return thumbs[-1]
|
||||||
elif isinstance(thumb, int):
|
elif isinstance(thumb, int):
|
||||||
return thumbs[thumb]
|
return thumbs[thumb]
|
||||||
|
elif isinstance(thumb, str):
|
||||||
|
return next((t for t in thumbs if t.type == thumb), None)
|
||||||
elif isinstance(thumb, (types.PhotoSize, types.PhotoCachedSize,
|
elif isinstance(thumb, (types.PhotoSize, types.PhotoCachedSize,
|
||||||
types.PhotoStrippedSize)):
|
types.PhotoStrippedSize, types.VideoSize)):
|
||||||
return thumb
|
return thumb
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
@ -670,11 +672,16 @@ class DownloadMethods:
|
||||||
if not isinstance(photo, types.Photo):
|
if not isinstance(photo, types.Photo):
|
||||||
return
|
return
|
||||||
|
|
||||||
size = self._get_thumb(photo.sizes, thumb)
|
# Include video sizes here (but they may be None so provide an empty list)
|
||||||
|
size = self._get_thumb(photo.sizes + (photo.video_sizes or []), thumb)
|
||||||
if not size or isinstance(size, types.PhotoSizeEmpty):
|
if not size or isinstance(size, types.PhotoSizeEmpty):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if isinstance(size, types.VideoSize):
|
||||||
|
file = self._get_proper_filename(file, 'video', '.mp4', date=date)
|
||||||
|
else:
|
||||||
file = self._get_proper_filename(file, 'photo', '.jpg', date=date)
|
file = self._get_proper_filename(file, 'photo', '.jpg', date=date)
|
||||||
|
|
||||||
if isinstance(size, (types.PhotoCachedSize, types.PhotoStrippedSize)):
|
if isinstance(size, (types.PhotoCachedSize, types.PhotoStrippedSize)):
|
||||||
return self._download_cached_photo_size(size, file)
|
return self._download_cached_photo_size(size, file)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user