mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 21:38:04 +00:00
Update all media types' thumbnails
They are now a List of Thumbnail objects
This commit is contained in:
parent
b217bf3784
commit
3208b22849
@ -26,11 +26,12 @@ from .message import Message
|
|||||||
from .message_entity import MessageEntity
|
from .message_entity import MessageEntity
|
||||||
from .messages import Messages
|
from .messages import Messages
|
||||||
from .photo import Photo
|
from .photo import Photo
|
||||||
from .photo_size import PhotoSize
|
|
||||||
from .poll import Poll
|
from .poll import Poll
|
||||||
from .poll_option import PollOption
|
from .poll_option import PollOption
|
||||||
from .sticker import Sticker
|
from .sticker import Sticker
|
||||||
from .user_profile_photos import UserProfilePhotos
|
from .stripped_thumbnail import StrippedThumbnail
|
||||||
|
from .thumbnail import Thumbnail
|
||||||
|
from .photos import Photos
|
||||||
from .venue import Venue
|
from .venue import Venue
|
||||||
from .video import Video
|
from .video import Video
|
||||||
from .video_note import VideoNote
|
from .video_note import VideoNote
|
||||||
@ -38,5 +39,5 @@ from .voice import Voice
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Messages", "Photo",
|
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Messages", "Photo",
|
||||||
"PhotoSize", "Poll", "PollOption", "Sticker", "UserProfilePhotos", "Venue", "Video", "VideoNote", "Voice"
|
"Thumbnail", "StrippedThumbnail", "Poll", "PollOption", "Sticker", "Photos", "Venue", "Video", "VideoNote", "Voice"
|
||||||
]
|
]
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .thumbnail import Thumbnail
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
|
|
||||||
@ -41,9 +42,6 @@ class Animation(PyrogramType):
|
|||||||
duration (``int``):
|
duration (``int``):
|
||||||
Duration of the animation in seconds as defined by sender.
|
Duration of the animation in seconds as defined by sender.
|
||||||
|
|
||||||
thumb (:obj:`PhotoSize <pyrogram.PhotoSize>`, *optional*):
|
|
||||||
Animation thumbnail.
|
|
||||||
|
|
||||||
file_name (``str``, *optional*):
|
file_name (``str``, *optional*):
|
||||||
Animation file name.
|
Animation file name.
|
||||||
|
|
||||||
@ -55,9 +53,12 @@ class Animation(PyrogramType):
|
|||||||
|
|
||||||
date (``int``, *optional*):
|
date (``int``, *optional*):
|
||||||
Date the animation was sent in Unix time.
|
Date the animation was sent in Unix time.
|
||||||
|
|
||||||
|
thumbnails (List of :obj:`Thumbnail`, *optional*):
|
||||||
|
Animation thumbnails.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "width", "height", "duration"]
|
__slots__ = ["file_id", "file_name", "mime_type", "file_size", "date", "width", "height", "duration", "thumbnails"]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -67,16 +68,15 @@ class Animation(PyrogramType):
|
|||||||
width: int,
|
width: int,
|
||||||
height: int,
|
height: int,
|
||||||
duration: int,
|
duration: int,
|
||||||
thumb: PhotoSize = None,
|
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
date: int = None
|
date: int = None,
|
||||||
|
thumbnails: List[Thumbnail] = None,
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.file_id = file_id
|
self.file_id = file_id
|
||||||
self.thumb = thumb
|
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
self.mime_type = mime_type
|
self.mime_type = mime_type
|
||||||
self.file_size = file_size
|
self.file_size = file_size
|
||||||
@ -84,10 +84,15 @@ class Animation(PyrogramType):
|
|||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
|
self.thumbnails = thumbnails
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, animation: types.Document, video_attributes: types.DocumentAttributeVideo,
|
def _parse(
|
||||||
file_name: str) -> "Animation":
|
client,
|
||||||
|
animation: types.Document,
|
||||||
|
video_attributes: types.DocumentAttributeVideo,
|
||||||
|
file_name: str
|
||||||
|
) -> "Animation":
|
||||||
return Animation(
|
return Animation(
|
||||||
file_id=encode(
|
file_id=encode(
|
||||||
pack(
|
pack(
|
||||||
@ -101,10 +106,10 @@ class Animation(PyrogramType):
|
|||||||
width=getattr(video_attributes, "w", 0),
|
width=getattr(video_attributes, "w", 0),
|
||||||
height=getattr(video_attributes, "h", 0),
|
height=getattr(video_attributes, "h", 0),
|
||||||
duration=getattr(video_attributes, "duration", 0),
|
duration=getattr(video_attributes, "duration", 0),
|
||||||
thumb=PhotoSize._parse(client, animation.thumbs),
|
|
||||||
mime_type=animation.mime_type,
|
mime_type=animation.mime_type,
|
||||||
file_size=animation.size,
|
file_size=animation.size,
|
||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
date=animation.date,
|
date=animation.date,
|
||||||
|
thumbnails=Thumbnail._parse(client, animation),
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .thumbnail import Thumbnail
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
|
|
||||||
@ -35,9 +36,6 @@ class Audio(PyrogramType):
|
|||||||
duration (``int``):
|
duration (``int``):
|
||||||
Duration of the audio in seconds as defined by sender.
|
Duration of the audio in seconds as defined by sender.
|
||||||
|
|
||||||
thumb (:obj:`PhotoSize`, *optional*):
|
|
||||||
Thumbnail of the music file album cover.
|
|
||||||
|
|
||||||
file_name (``str``, *optional*):
|
file_name (``str``, *optional*):
|
||||||
Audio file name.
|
Audio file name.
|
||||||
|
|
||||||
@ -55,9 +53,14 @@ class Audio(PyrogramType):
|
|||||||
|
|
||||||
title (``str``, *optional*):
|
title (``str``, *optional*):
|
||||||
Title of the audio as defined by sender or by audio tags.
|
Title of the audio as defined by sender or by audio tags.
|
||||||
|
|
||||||
|
thumbnails (List of :obj:`Thumbnail`, *optional*):
|
||||||
|
Thumbnails of the music file album cover.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "duration", "performer", "title"]
|
__slots__ = [
|
||||||
|
"file_id", "file_name", "mime_type", "file_size", "date", "duration", "performer", "title", "thumbnails"
|
||||||
|
]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -65,18 +68,17 @@ class Audio(PyrogramType):
|
|||||||
client: "pyrogram.BaseClient" = None,
|
client: "pyrogram.BaseClient" = None,
|
||||||
file_id: str,
|
file_id: str,
|
||||||
duration: int,
|
duration: int,
|
||||||
thumb: PhotoSize = None,
|
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
date: int = None,
|
date: int = None,
|
||||||
performer: str = None,
|
performer: str = None,
|
||||||
title: str = None
|
title: str = None,
|
||||||
|
thumbnails: List[Thumbnail] = None,
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.file_id = file_id
|
self.file_id = file_id
|
||||||
self.thumb = thumb
|
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
self.mime_type = mime_type
|
self.mime_type = mime_type
|
||||||
self.file_size = file_size
|
self.file_size = file_size
|
||||||
@ -84,10 +86,15 @@ class Audio(PyrogramType):
|
|||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.performer = performer
|
self.performer = performer
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.thumbnails = thumbnails
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio,
|
def _parse(
|
||||||
file_name: str) -> "Audio":
|
client,
|
||||||
|
audio: types.Document,
|
||||||
|
audio_attributes: types.DocumentAttributeAudio,
|
||||||
|
file_name: str
|
||||||
|
) -> "Audio":
|
||||||
return Audio(
|
return Audio(
|
||||||
file_id=encode(
|
file_id=encode(
|
||||||
pack(
|
pack(
|
||||||
@ -103,8 +110,8 @@ class Audio(PyrogramType):
|
|||||||
title=audio_attributes.title,
|
title=audio_attributes.title,
|
||||||
mime_type=audio.mime_type,
|
mime_type=audio.mime_type,
|
||||||
file_size=audio.size,
|
file_size=audio.size,
|
||||||
thumb=PhotoSize._parse(client, audio.thumbs),
|
|
||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
date=audio.date,
|
date=audio.date,
|
||||||
|
thumbnails=Thumbnail._parse(client, audio),
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .thumbnail import Thumbnail
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
|
|
||||||
@ -32,9 +33,6 @@ class Document(PyrogramType):
|
|||||||
file_id (``str``):
|
file_id (``str``):
|
||||||
Unique file identifier.
|
Unique file identifier.
|
||||||
|
|
||||||
thumb (:obj:`PhotoSize`, *optional*):
|
|
||||||
Document thumbnail as defined by sender.
|
|
||||||
|
|
||||||
file_name (``str``, *optional*):
|
file_name (``str``, *optional*):
|
||||||
Original filename as defined by sender.
|
Original filename as defined by sender.
|
||||||
|
|
||||||
@ -46,29 +44,32 @@ class Document(PyrogramType):
|
|||||||
|
|
||||||
date (``int``, *optional*):
|
date (``int``, *optional*):
|
||||||
Date the document was sent in Unix time.
|
Date the document was sent in Unix time.
|
||||||
|
|
||||||
|
thumbnails (List of :obj:`Thumbnail`, *optional*):
|
||||||
|
Document thumbnails as defined by sender.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date"]
|
__slots__ = ["file_id", "file_name", "mime_type", "file_size", "date", "thumbnails"]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
client: "pyrogram.BaseClient" = None,
|
client: "pyrogram.BaseClient" = None,
|
||||||
file_id: str,
|
file_id: str,
|
||||||
thumb: PhotoSize = None,
|
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
date: int = None
|
date: int = None,
|
||||||
|
thumbnails: List[Thumbnail] = None,
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.file_id = file_id
|
self.file_id = file_id
|
||||||
self.thumb = thumb
|
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
self.mime_type = mime_type
|
self.mime_type = mime_type
|
||||||
self.file_size = file_size
|
self.file_size = file_size
|
||||||
self.date = date
|
self.date = date,
|
||||||
|
self.thumbnails = thumbnails
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, document: types.Document, file_name: str) -> "Document":
|
def _parse(client, document: types.Document, file_name: str) -> "Document":
|
||||||
@ -82,10 +83,10 @@ class Document(PyrogramType):
|
|||||||
document.access_hash
|
document.access_hash
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
thumb=PhotoSize._parse(client, document.thumbs),
|
|
||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
mime_type=document.mime_type,
|
mime_type=document.mime_type,
|
||||||
file_size=document.size,
|
file_size=document.size,
|
||||||
date=document.date,
|
date=document.date,
|
||||||
|
thumbnails=Thumbnail._parse(client, document),
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
@ -16,13 +16,12 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from base64 import b64encode
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .thumbnail import Thumbnail
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
|
|
||||||
@ -31,74 +30,65 @@ class Photo(PyrogramType):
|
|||||||
"""A Photo.
|
"""A Photo.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
id (``str``):
|
file_id (``str``):
|
||||||
Unique identifier for this photo.
|
Unique identifier for this photo.
|
||||||
|
|
||||||
|
width (``int``):
|
||||||
|
Photo width.
|
||||||
|
|
||||||
|
height (``int``):
|
||||||
|
Photo height.
|
||||||
|
|
||||||
|
file_size (``int``):
|
||||||
|
File size.
|
||||||
|
|
||||||
date (``int``):
|
date (``int``):
|
||||||
Date the photo was sent in Unix time.
|
Date the photo was sent in Unix time.
|
||||||
|
|
||||||
sizes (List of :obj:`PhotoSize`):
|
thumbnails (List of :obj:`Thumbnail`):
|
||||||
Available sizes of this photo.
|
Available sizes of this photo.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ["id", "date", "sizes"]
|
__slots__ = ["file_id", "width", "height", "file_size", "date", "thumbnails"]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
client: "pyrogram.BaseClient" = None,
|
client: "pyrogram.BaseClient" = None,
|
||||||
id: str,
|
file_id: str,
|
||||||
|
width: int,
|
||||||
|
height: int,
|
||||||
|
file_size: int,
|
||||||
date: int,
|
date: int,
|
||||||
sizes: List[PhotoSize]
|
thumbnails: List[Thumbnail]
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.id = id
|
self.file_id = file_id
|
||||||
|
self.width = width
|
||||||
|
self.height = height
|
||||||
|
self.file_size = file_size
|
||||||
self.date = date
|
self.date = date
|
||||||
self.sizes = sizes
|
self.thumbnails = thumbnails
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, photo: types.Photo):
|
def _parse(client, photo: types.Photo) -> "Photo":
|
||||||
if isinstance(photo, types.Photo):
|
if isinstance(photo, types.Photo):
|
||||||
raw_sizes = photo.sizes
|
big = photo.sizes[-1]
|
||||||
sizes = []
|
|
||||||
|
|
||||||
for raw_size in raw_sizes:
|
|
||||||
if isinstance(raw_size, (types.PhotoSize, types.PhotoCachedSize)):
|
|
||||||
if isinstance(raw_size, types.PhotoSize):
|
|
||||||
file_size = raw_size.size
|
|
||||||
elif isinstance(raw_size, types.PhotoCachedSize):
|
|
||||||
file_size = len(raw_size.bytes)
|
|
||||||
else:
|
|
||||||
file_size = 0
|
|
||||||
|
|
||||||
loc = raw_size.location
|
|
||||||
|
|
||||||
if isinstance(loc, types.FileLocation):
|
|
||||||
size = PhotoSize(
|
|
||||||
file_id=encode(
|
|
||||||
pack(
|
|
||||||
"<iiqqqqi",
|
|
||||||
2, loc.dc_id, photo.id, photo.access_hash,
|
|
||||||
loc.volume_id, loc.secret, loc.local_id)),
|
|
||||||
width=raw_size.w,
|
|
||||||
height=raw_size.h,
|
|
||||||
file_size=file_size,
|
|
||||||
client=client
|
|
||||||
)
|
|
||||||
|
|
||||||
sizes.append(size)
|
|
||||||
|
|
||||||
return Photo(
|
return Photo(
|
||||||
id=b64encode(
|
file_id=encode(
|
||||||
pack(
|
pack(
|
||||||
"<qq",
|
"<iiqqc",
|
||||||
photo.id,
|
2, photo.dc_id,
|
||||||
photo.access_hash
|
photo.id, photo.access_hash,
|
||||||
|
big.type.encode()
|
||||||
|
)
|
||||||
),
|
),
|
||||||
b"-_"
|
width=big.w,
|
||||||
).decode().rstrip("="),
|
height=big.h,
|
||||||
|
file_size=big.size,
|
||||||
date=photo.date,
|
date=photo.date,
|
||||||
sizes=sizes,
|
thumbnails=Thumbnail._parse(client, photo),
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
@ -18,11 +18,12 @@
|
|||||||
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types, functions
|
from pyrogram.api import types, functions
|
||||||
from pyrogram.errors import StickersetInvalid
|
from pyrogram.errors import StickersetInvalid
|
||||||
from .photo_size import PhotoSize
|
from .thumbnail import Thumbnail
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
|
|
||||||
@ -40,9 +41,6 @@ class Sticker(PyrogramType):
|
|||||||
height (``int``):
|
height (``int``):
|
||||||
Sticker height.
|
Sticker height.
|
||||||
|
|
||||||
thumb (:obj:`PhotoSize`, *optional*):
|
|
||||||
Sticker thumbnail in the .webp or .jpg format.
|
|
||||||
|
|
||||||
file_name (``str``, *optional*):
|
file_name (``str``, *optional*):
|
||||||
Sticker file name.
|
Sticker file name.
|
||||||
|
|
||||||
@ -60,12 +58,15 @@ class Sticker(PyrogramType):
|
|||||||
|
|
||||||
set_name (``str``, *optional*):
|
set_name (``str``, *optional*):
|
||||||
Name of the sticker set to which the sticker belongs.
|
Name of the sticker set to which the sticker belongs.
|
||||||
|
|
||||||
|
thumbnails (List of :obj:`Thumbnail`, *optional*):
|
||||||
|
Sticker thumbnails in the .webp or .jpg format.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: Add mask position
|
# TODO: Add mask position
|
||||||
|
|
||||||
__slots__ = [
|
__slots__ = [
|
||||||
"file_id", "thumb", "file_name", "mime_type", "file_size", "date", "width", "height", "emoji", "set_name"
|
"file_id", "file_name", "mime_type", "file_size", "date", "width", "height", "emoji", "set_name", "thumbnails"
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -75,18 +76,17 @@ class Sticker(PyrogramType):
|
|||||||
file_id: str,
|
file_id: str,
|
||||||
width: int,
|
width: int,
|
||||||
height: int,
|
height: int,
|
||||||
thumb: PhotoSize = None,
|
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
date: int = None,
|
date: int = None,
|
||||||
emoji: str = None,
|
emoji: str = None,
|
||||||
set_name: str = None
|
set_name: str = None,
|
||||||
|
thumbnails: List[Thumbnail] = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.file_id = file_id
|
self.file_id = file_id
|
||||||
self.thumb = thumb
|
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
self.mime_type = mime_type
|
self.mime_type = mime_type
|
||||||
self.file_size = file_size
|
self.file_size = file_size
|
||||||
@ -94,7 +94,8 @@ class Sticker(PyrogramType):
|
|||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
self.emoji = emoji
|
self.emoji = emoji
|
||||||
self.set_name = set_name
|
self.set_name = set_name,
|
||||||
|
self.thumbnails = thumbnails
|
||||||
# self.mask_position = mask_position
|
# self.mask_position = mask_position
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -135,7 +136,6 @@ class Sticker(PyrogramType):
|
|||||||
),
|
),
|
||||||
width=image_size_attributes.w if image_size_attributes else 0,
|
width=image_size_attributes.w if image_size_attributes else 0,
|
||||||
height=image_size_attributes.h if image_size_attributes else 0,
|
height=image_size_attributes.h if image_size_attributes else 0,
|
||||||
thumb=PhotoSize._parse(client, sticker.thumbs),
|
|
||||||
# TODO: mask_position
|
# TODO: mask_position
|
||||||
set_name=set_name,
|
set_name=set_name,
|
||||||
emoji=sticker_attributes.alt or None,
|
emoji=sticker_attributes.alt or None,
|
||||||
@ -143,5 +143,6 @@ class Sticker(PyrogramType):
|
|||||||
mime_type=sticker.mime_type,
|
mime_type=sticker.mime_type,
|
||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
date=sticker.date,
|
date=sticker.date,
|
||||||
|
thumbnails=Thumbnail._parse(client, sticker),
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .thumbnail import Thumbnail
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
|
|
||||||
@ -41,9 +42,6 @@ class Video(PyrogramType):
|
|||||||
duration (``int``):
|
duration (``int``):
|
||||||
Duration of the video in seconds as defined by sender.
|
Duration of the video in seconds as defined by sender.
|
||||||
|
|
||||||
thumb (:obj:`PhotoSize`, *optional*):
|
|
||||||
Video thumbnail.
|
|
||||||
|
|
||||||
file_name (``str``, *optional*):
|
file_name (``str``, *optional*):
|
||||||
Video file name.
|
Video file name.
|
||||||
|
|
||||||
@ -58,11 +56,14 @@ class Video(PyrogramType):
|
|||||||
|
|
||||||
date (``int``, *optional*):
|
date (``int``, *optional*):
|
||||||
Date the video was sent in Unix time.
|
Date the video was sent in Unix time.
|
||||||
|
|
||||||
|
thumbnails (List of :obj:`Thumbnail`, *optional*):
|
||||||
|
Video thumbnails.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = [
|
__slots__ = [
|
||||||
"file_id", "width", "height", "duration", "thumb", "file_name", "mime_type", "supports_streaming", "file_size",
|
"file_id", "width", "height", "duration", "file_name", "mime_type", "supports_streaming", "file_size", "date",
|
||||||
"date"
|
"thumbnails"
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -73,12 +74,12 @@ class Video(PyrogramType):
|
|||||||
width: int,
|
width: int,
|
||||||
height: int,
|
height: int,
|
||||||
duration: int,
|
duration: int,
|
||||||
thumb: PhotoSize = None,
|
|
||||||
file_name: str = None,
|
file_name: str = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
supports_streaming: bool = None,
|
supports_streaming: bool = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
date: int = None
|
date: int = None,
|
||||||
|
thumbnails: List[Thumbnail] = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
@ -86,16 +87,20 @@ class Video(PyrogramType):
|
|||||||
self.width = width
|
self.width = width
|
||||||
self.height = height
|
self.height = height
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
self.thumb = thumb
|
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
self.mime_type = mime_type
|
self.mime_type = mime_type
|
||||||
self.supports_streaming = supports_streaming
|
self.supports_streaming = supports_streaming
|
||||||
self.file_size = file_size
|
self.file_size = file_size
|
||||||
self.date = date
|
self.date = date
|
||||||
|
self.thumbnails = thumbnails
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, video: types.Document, video_attributes: types.DocumentAttributeVideo,
|
def _parse(
|
||||||
file_name: str) -> "Video":
|
client,
|
||||||
|
video: types.Document,
|
||||||
|
video_attributes: types.DocumentAttributeVideo,
|
||||||
|
file_name: str
|
||||||
|
) -> "Video":
|
||||||
return Video(
|
return Video(
|
||||||
file_id=encode(
|
file_id=encode(
|
||||||
pack(
|
pack(
|
||||||
@ -109,11 +114,11 @@ class Video(PyrogramType):
|
|||||||
width=video_attributes.w,
|
width=video_attributes.w,
|
||||||
height=video_attributes.h,
|
height=video_attributes.h,
|
||||||
duration=video_attributes.duration,
|
duration=video_attributes.duration,
|
||||||
thumb=PhotoSize._parse(client, video.thumbs),
|
|
||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
mime_type=video.mime_type,
|
mime_type=video.mime_type,
|
||||||
supports_streaming=video_attributes.supports_streaming,
|
supports_streaming=video_attributes.supports_streaming,
|
||||||
file_size=video.size,
|
file_size=video.size,
|
||||||
date=video.date,
|
date=video.date,
|
||||||
|
thumbnails=Thumbnail._parse(client, video),
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import types
|
from pyrogram.api import types
|
||||||
from .photo_size import PhotoSize
|
from .thumbnail import Thumbnail
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
from ...ext.utils import encode
|
from ...ext.utils import encode
|
||||||
|
|
||||||
@ -38,9 +39,6 @@ class VideoNote(PyrogramType):
|
|||||||
duration (``int``):
|
duration (``int``):
|
||||||
Duration of the video in seconds as defined by sender.
|
Duration of the video in seconds as defined by sender.
|
||||||
|
|
||||||
thumb (:obj:`PhotoSize`, *optional*):
|
|
||||||
Video thumbnail.
|
|
||||||
|
|
||||||
mime_type (``str``, *optional*):
|
mime_type (``str``, *optional*):
|
||||||
MIME type of the file as defined by sender.
|
MIME type of the file as defined by sender.
|
||||||
|
|
||||||
@ -49,9 +47,12 @@ class VideoNote(PyrogramType):
|
|||||||
|
|
||||||
date (``int``, *optional*):
|
date (``int``, *optional*):
|
||||||
Date the video note was sent in Unix time.
|
Date the video note was sent in Unix time.
|
||||||
|
|
||||||
|
thumbnails (List of :obj:`Thumbnail`, *optional*):
|
||||||
|
Video thumbnails.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ["file_id", "thumb", "mime_type", "file_size", "date", "length", "duration"]
|
__slots__ = ["file_id", "mime_type", "file_size", "date", "length", "duration", "thumbnails"]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -60,7 +61,7 @@ class VideoNote(PyrogramType):
|
|||||||
file_id: str,
|
file_id: str,
|
||||||
length: int,
|
length: int,
|
||||||
duration: int,
|
duration: int,
|
||||||
thumb: PhotoSize = None,
|
thumbnails: List[Thumbnail] = None,
|
||||||
mime_type: str = None,
|
mime_type: str = None,
|
||||||
file_size: int = None,
|
file_size: int = None,
|
||||||
date: int = None
|
date: int = None
|
||||||
@ -68,12 +69,12 @@ class VideoNote(PyrogramType):
|
|||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
self.file_id = file_id
|
self.file_id = file_id
|
||||||
self.thumb = thumb
|
|
||||||
self.mime_type = mime_type
|
self.mime_type = mime_type
|
||||||
self.file_size = file_size
|
self.file_size = file_size
|
||||||
self.date = date
|
self.date = date
|
||||||
self.length = length
|
self.length = length
|
||||||
self.duration = duration
|
self.duration = duration
|
||||||
|
self.thumbnails = thumbnails
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, video_note: types.Document, video_attributes: types.DocumentAttributeVideo) -> "VideoNote":
|
def _parse(client, video_note: types.Document, video_attributes: types.DocumentAttributeVideo) -> "VideoNote":
|
||||||
@ -89,9 +90,9 @@ class VideoNote(PyrogramType):
|
|||||||
),
|
),
|
||||||
length=video_attributes.w,
|
length=video_attributes.w,
|
||||||
duration=video_attributes.duration,
|
duration=video_attributes.duration,
|
||||||
thumb=PhotoSize._parse(client, video_note.thumbs),
|
|
||||||
file_size=video_note.size,
|
file_size=video_note.size,
|
||||||
mime_type=video_note.mime_type,
|
mime_type=video_note.mime_type,
|
||||||
date=video_note.date,
|
date=video_note.date,
|
||||||
|
thumbnails=Thumbnail._parse(client, video_note),
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user