Pyrofork: Add cover and start_timestamp in send_video, reply_video

Signed-off-by: Yasir <git@yasir.id>
This commit is contained in:
shriMADhav U k 2025-02-03 11:26:07 +07:00 committed by Yasir
parent 7662cc164f
commit 5c1c72f068
4 changed files with 67 additions and 12 deletions

View file

@ -36,7 +36,9 @@ class ForwardMessages:
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
drop_author: bool = None
drop_author: bool = None,
remove_caption: bool = None,
new_video_start_timestamp: int = None,
) -> Union["types.Message", List["types.Message"]]:
"""Forward messages of any kind.
@ -76,7 +78,13 @@ class ForwardMessages:
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only.
drop_author (``bool``, *optional*):
Forwards messages without quoting the original author
Pass True to forwards messages without quoting the original author.
remove_caption (``bool``, *optional*):
Pass True to remove media captions of message copies.
new_video_start_timestamp (``int``, *optional*):
The new video start timestamp. Pass time to replace video start timestamp in the forwarded message.
Returns:
:obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was not
@ -106,7 +114,9 @@ class ForwardMessages:
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
drop_author=drop_author
drop_author=drop_author,
drop_media_captions=remove_caption,
video_timestamp=new_video_start_timestamp
)
)

View file

@ -55,6 +55,8 @@ class SendVideo:
reply_to_chat_id: Union[int, str] = None,
quote_text: str = None,
quote_entities: List["types.MessageEntity"] = None,
cover: Optional[Union[str, "io.BytesIO"]] = None,
start_timestamp: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
@ -159,6 +161,12 @@ class SendVideo:
List of special entities that appear in quote_text, which can be specified instead of *parse_mode*.
for reply_to_message only.
cover (``str`` | :obj:`io.BytesIO`, *optional*):
Cover of the video; pass None to skip cover uploading.
start_timestamp (``int``, *optional*):
Timestamp from which the video playing must start, in seconds.
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
@ -255,13 +263,17 @@ class SendVideo:
h=height
),
raw.types.DocumentAttributeFilename(file_name=file_name or os.path.basename(video))
]
],
video_cover=await self.save_file(cover) if cover else None,
video_timestamp=start_timestamp
)
elif re.match("^https?://", video):
media = raw.types.InputMediaDocumentExternal(
url=video,
ttl_seconds=ttl_seconds,
spoiler=has_spoiler
spoiler=has_spoiler,
video_cover=await self.save_file(cover) if cover else None,
video_timestamp=start_timestamp
)
else:
media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=ttl_seconds)
@ -283,7 +295,9 @@ class SendVideo:
h=height
),
raw.types.DocumentAttributeFilename(file_name=file_name or video.name)
]
],
video_cover=await self.save_file(cover) if cover else None,
video_timestamp=start_timestamp
)
while True:

View file

@ -200,7 +200,9 @@ class SendPaidMedia:
spoiler=i.has_spoiler,
mime_type=self.guess_mime_type(i.media) or "video/mp4",
nosound_video=is_animation,
attributes=attributes
attributes=attributes,
video_cover=await self.save_file(i.cover),
video_timestamp=i.start_timestamp
)
)
)
@ -219,6 +221,8 @@ class SendPaidMedia:
peer=await self.resolve_peer(chat_id),
media=raw.types.InputMediaDocumentExternal(
url=i.media,
video_cover=await self.save_file(i.cover),
video_timestamp=i.start_timestamp,
spoiler=i.has_spoiler
)
)
@ -251,7 +255,9 @@ class SendPaidMedia:
h=i.height
),
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "video.mp4"))
]
],
video_cover=await self.save_file(i.cover),
video_timestamp=i.start_timestamp
)
)
)

View file

@ -3593,6 +3593,9 @@ class Message(Object, Update):
quote_entities: List["types.MessageEntity"] = None,
allow_paid_broadcast: bool = None,
message_effect_id: int = None,
cover: Optional[Union[str, "io.BytesIO"]] = None,
start_timestamp: int = None,
schedule_date: datetime = None,
invert_media: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
@ -3695,7 +3698,16 @@ class Message(Object, Update):
for reply_to_message only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots.
cover (``str`` | :obj:`io.BytesIO`, *optional*):
Cover of the video; pass None to skip cover uploading.
start_timestamp (``int``, *optional*):
Timestamp from which the video playing must start, in seconds.
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
message_effect_id (``int`` ``64-bit``, *optional*):
Unique identifier of the message effect to be added to the message; for private chats only.
@ -3779,6 +3791,9 @@ class Message(Object, Update):
quote_entities=quote_entities,
allow_paid_broadcast=allow_paid_broadcast,
message_effect_id=message_effect_id,
cover=cover,
start_timestamp=start_timestamp,
schedule_date=schedule_date,
invert_media=invert_media,
reply_markup=reply_markup,
progress=progress,
@ -4525,7 +4540,9 @@ class Message(Object, Update):
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
drop_author: bool = None
drop_author: bool = None,
remove_caption: bool = None,
new_video_start_timestamp: int = None,
) -> Union["types.Message", List["types.Message"]]:
"""Bound method *forward* of :obj:`~pyrogram.types.Message`.
@ -4568,7 +4585,13 @@ class Message(Object, Update):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots
drop_author (``bool``, *optional*):
Forwards messages without quoting the original author
Forwards messages without quoting the original author.
remove_caption (``bool``, *optional*):
Pass True to remove media captions of message copies.
new_video_start_timestamp (``int``, *optional*):
The new video start timestamp. Pass time to replace video start timestamp in the forwarded message.
Returns:
On success, the forwarded Message is returned.
@ -4585,7 +4608,9 @@ class Message(Object, Update):
schedule_date=schedule_date,
protect_content=protect_content,
allow_paid_broadcast=allow_paid_broadcast,
drop_author=drop_author
drop_author=drop_author,
remove_caption=remove_caption,
new_video_start_timestamp=new_video_start_timestamp,
)
async def copy(