Skip to content

Commit

Permalink
Revert "Partly revert change + fix docs"
Browse files Browse the repository at this point in the history
This reverts commit 92e4f49.
  • Loading branch information
eyMarv committed Nov 7, 2024
1 parent 3583d2e commit 0330d6a
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ class Message(Object, Update):
video (:obj:`~pyrogram.types.Video`, *optional*):
Message is a video, information about the video.
video_processing_pending (``bool``, *optional*):
True, if the video is still processing.
alternative_videos (List of :obj:`~pyrogram.types.Video`, *optional*):
Alternative qualities of the video, if the message is a video.
voice (:obj:`~pyrogram.types.Voice`, *optional*):
Message is a voice message, information about the file.
Expand Down Expand Up @@ -506,6 +512,8 @@ def __init__(
invoice: "types.MessageInvoice" = None,
story: Union["types.MessageStory", "types.Story"] = None,
video: "types.Video" = None,
video_processing_pending: bool = None,
alternative_videos: List["types.Video"] = None,
voice: "types.Voice" = None,
video_note: "types.VideoNote" = None,
web_page_preview: "types.WebPagePreview" = None,
Expand Down Expand Up @@ -624,6 +632,8 @@ def __init__(
self.invoice = invoice
self.story = story
self.video = video
self.video_processing_pending = video_processing_pending
self.alternative_videos = alternative_videos
self.voice = voice
self.video_note = video_note
self.web_page_preview = web_page_preview
Expand Down Expand Up @@ -1127,6 +1137,7 @@ async def _parse(
voice = None
animation = None
video = None
alternative_videos = []
video_note = None
web_page_preview = None
sticker = None
Expand Down Expand Up @@ -1203,15 +1214,28 @@ async def _parse(
)
media_type = enums.MessageMediaType.VIDEO_NOTE
else:
video = types.Video._parse(
client,
doc,
video_attributes,
file_name,
media.ttl_seconds,
)
video = types.Video._parse(client, doc, video_attributes, file_name, media.ttl_seconds)
media_type = enums.MessageMediaType.VIDEO
has_media_spoiler = media.spoiler

altdocs = media.alt_documents or []
for altdoc in altdocs:
if isinstance(altdoc, raw.types.Document):
altdoc_attributes = {type(i): i for i in altdoc.attributes}
altdoc_file_name = getattr(
altdoc_attributes.get(
raw.types.DocumentAttributeFilename, None
), "file_name", None
)

altdoc_video_attribute = altdoc_attributes.get(raw.types.DocumentAttributeVideo,
None)

if altdoc_video_attribute:
alternative_videos.append(
types.Video._parse(client, altdoc, altdoc_video_attribute,
altdoc_file_name)
)
elif raw.types.DocumentAttributeAudio in attributes:
audio_attributes = attributes[
raw.types.DocumentAttributeAudio
Expand Down Expand Up @@ -1344,6 +1368,12 @@ async def _parse(
invoice=invoice,
story=story,
video=video,
video_processing_pending=getattr(
message, "video_processing_pending", None
),
alternative_videos=(
types.List(alternative_videos) if alternative_videos else None
),
video_note=video_note,
web_page_preview=web_page_preview,
sticker=sticker,
Expand Down

0 comments on commit 0330d6a

Please sign in to comment.