Skip to content

Commit 5c1c72f

Browse files
SpEcHiDeyasirarism
authored andcommitted
Pyrofork: Add cover and start_timestamp in send_video, reply_video
Signed-off-by: Yasir <git@yasir.id>
1 parent 7662cc1 commit 5c1c72f

File tree

4 files changed

+67
-12
lines changed

4 files changed

+67
-12
lines changed

pyrogram/methods/messages/forward_messages.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ async def forward_messages(
3636
schedule_date: datetime = None,
3737
protect_content: bool = None,
3838
allow_paid_broadcast: bool = None,
39-
drop_author: bool = None
39+
drop_author: bool = None,
40+
remove_caption: bool = None,
41+
new_video_start_timestamp: int = None,
4042
) -> Union["types.Message", List["types.Message"]]:
4143
"""Forward messages of any kind.
4244
@@ -76,7 +78,13 @@ async def forward_messages(
7678
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only.
7779
7880
drop_author (``bool``, *optional*):
79-
Forwards messages without quoting the original author
81+
Pass True to forwards messages without quoting the original author.
82+
83+
remove_caption (``bool``, *optional*):
84+
Pass True to remove media captions of message copies.
85+
86+
new_video_start_timestamp (``int``, *optional*):
87+
The new video start timestamp. Pass time to replace video start timestamp in the forwarded message.
8088
8189
Returns:
8290
:obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was not
@@ -106,7 +114,9 @@ async def forward_messages(
106114
schedule_date=utils.datetime_to_timestamp(schedule_date),
107115
noforwards=protect_content,
108116
allow_paid_floodskip=allow_paid_broadcast,
109-
drop_author=drop_author
117+
drop_author=drop_author,
118+
drop_media_captions=remove_caption,
119+
video_timestamp=new_video_start_timestamp
110120
)
111121
)
112122

pyrogram/methods/messages/send_video.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ async def send_video(
5555
reply_to_chat_id: Union[int, str] = None,
5656
quote_text: str = None,
5757
quote_entities: List["types.MessageEntity"] = None,
58+
cover: Optional[Union[str, "io.BytesIO"]] = None,
59+
start_timestamp: int = None,
5860
schedule_date: datetime = None,
5961
protect_content: bool = None,
6062
allow_paid_broadcast: bool = None,
@@ -159,6 +161,12 @@ async def send_video(
159161
List of special entities that appear in quote_text, which can be specified instead of *parse_mode*.
160162
for reply_to_message only.
161163
164+
cover (``str`` | :obj:`io.BytesIO`, *optional*):
165+
Cover of the video; pass None to skip cover uploading.
166+
167+
start_timestamp (``int``, *optional*):
168+
Timestamp from which the video playing must start, in seconds.
169+
162170
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
163171
Date when the message will be automatically sent.
164172
@@ -255,13 +263,17 @@ async def progress(current, total):
255263
h=height
256264
),
257265
raw.types.DocumentAttributeFilename(file_name=file_name or os.path.basename(video))
258-
]
266+
],
267+
video_cover=await self.save_file(cover) if cover else None,
268+
video_timestamp=start_timestamp
259269
)
260270
elif re.match("^https?://", video):
261271
media = raw.types.InputMediaDocumentExternal(
262272
url=video,
263273
ttl_seconds=ttl_seconds,
264-
spoiler=has_spoiler
274+
spoiler=has_spoiler,
275+
video_cover=await self.save_file(cover) if cover else None,
276+
video_timestamp=start_timestamp
265277
)
266278
else:
267279
media = utils.get_input_media_from_file_id(video, FileType.VIDEO, ttl_seconds=ttl_seconds)
@@ -283,7 +295,9 @@ async def progress(current, total):
283295
h=height
284296
),
285297
raw.types.DocumentAttributeFilename(file_name=file_name or video.name)
286-
]
298+
],
299+
video_cover=await self.save_file(cover) if cover else None,
300+
video_timestamp=start_timestamp
287301
)
288302

289303
while True:

pyrogram/methods/payments/send_paid_media.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ async def send_paid_media(
200200
spoiler=i.has_spoiler,
201201
mime_type=self.guess_mime_type(i.media) or "video/mp4",
202202
nosound_video=is_animation,
203-
attributes=attributes
203+
attributes=attributes,
204+
video_cover=await self.save_file(i.cover),
205+
video_timestamp=i.start_timestamp
204206
)
205207
)
206208
)
@@ -219,6 +221,8 @@ async def send_paid_media(
219221
peer=await self.resolve_peer(chat_id),
220222
media=raw.types.InputMediaDocumentExternal(
221223
url=i.media,
224+
video_cover=await self.save_file(i.cover),
225+
video_timestamp=i.start_timestamp,
222226
spoiler=i.has_spoiler
223227
)
224228
)
@@ -251,7 +255,9 @@ async def send_paid_media(
251255
h=i.height
252256
),
253257
raw.types.DocumentAttributeFilename(file_name=getattr(i.media, "name", "video.mp4"))
254-
]
258+
],
259+
video_cover=await self.save_file(i.cover),
260+
video_timestamp=i.start_timestamp
255261
)
256262
)
257263
)

pyrogram/types/messages_and_media/message.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3593,6 +3593,9 @@ async def reply_video(
35933593
quote_entities: List["types.MessageEntity"] = None,
35943594
allow_paid_broadcast: bool = None,
35953595
message_effect_id: int = None,
3596+
cover: Optional[Union[str, "io.BytesIO"]] = None,
3597+
start_timestamp: int = None,
3598+
schedule_date: datetime = None,
35963599
invert_media: bool = None,
35973600
reply_markup: Union[
35983601
"types.InlineKeyboardMarkup",
@@ -3695,7 +3698,16 @@ async def reply_video(
36953698
for reply_to_message only.
36963699
36973700
allow_paid_broadcast (``bool``, *optional*):
3698-
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots
3701+
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots.
3702+
3703+
cover (``str`` | :obj:`io.BytesIO`, *optional*):
3704+
Cover of the video; pass None to skip cover uploading.
3705+
3706+
start_timestamp (``int``, *optional*):
3707+
Timestamp from which the video playing must start, in seconds.
3708+
3709+
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
3710+
Date when the message will be automatically sent.
36993711
37003712
message_effect_id (``int`` ``64-bit``, *optional*):
37013713
Unique identifier of the message effect to be added to the message; for private chats only.
@@ -3779,6 +3791,9 @@ async def reply_video(
37793791
quote_entities=quote_entities,
37803792
allow_paid_broadcast=allow_paid_broadcast,
37813793
message_effect_id=message_effect_id,
3794+
cover=cover,
3795+
start_timestamp=start_timestamp,
3796+
schedule_date=schedule_date,
37823797
invert_media=invert_media,
37833798
reply_markup=reply_markup,
37843799
progress=progress,
@@ -4525,7 +4540,9 @@ async def forward(
45254540
schedule_date: datetime = None,
45264541
protect_content: bool = None,
45274542
allow_paid_broadcast: bool = None,
4528-
drop_author: bool = None
4543+
drop_author: bool = None,
4544+
remove_caption: bool = None,
4545+
new_video_start_timestamp: int = None,
45294546
) -> Union["types.Message", List["types.Message"]]:
45304547
"""Bound method *forward* of :obj:`~pyrogram.types.Message`.
45314548
@@ -4568,7 +4585,13 @@ async def forward(
45684585
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots
45694586
45704587
drop_author (``bool``, *optional*):
4571-
Forwards messages without quoting the original author
4588+
Forwards messages without quoting the original author.
4589+
4590+
remove_caption (``bool``, *optional*):
4591+
Pass True to remove media captions of message copies.
4592+
4593+
new_video_start_timestamp (``int``, *optional*):
4594+
The new video start timestamp. Pass time to replace video start timestamp in the forwarded message.
45724595
45734596
Returns:
45744597
On success, the forwarded Message is returned.
@@ -4585,7 +4608,9 @@ async def forward(
45854608
schedule_date=schedule_date,
45864609
protect_content=protect_content,
45874610
allow_paid_broadcast=allow_paid_broadcast,
4588-
drop_author=drop_author
4611+
drop_author=drop_author,
4612+
remove_caption=remove_caption,
4613+
new_video_start_timestamp=new_video_start_timestamp,
45894614
)
45904615

45914616
async def copy(

0 commit comments

Comments
 (0)