Skip to content

Commit 1835b62

Browse files
authored
Merge pull request pyrogram#556 from drizzt/video-ttl_seconds
Add ttl_seconds support for send_video and reply_video
2 parents e7667d8 + babbe00 commit 1835b62

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

pyrogram/methods/messages/send_video.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async def send_video(
3737
caption: str = "",
3838
parse_mode: Union[str, None] = object,
3939
caption_entities: List["types.MessageEntity"] = None,
40+
ttl_seconds: int = None,
4041
duration: int = 0,
4142
width: int = 0,
4243
height: int = 0,
@@ -83,6 +84,11 @@ async def send_video(
8384
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
8485
List of special entities that appear in the caption, which can be specified instead of __parse_mode__.
8586
87+
ttl_seconds (``int``, *optional*):
88+
Self-Destruct Timer.
89+
If you set a timer, the video will self-destruct in *ttl_seconds*
90+
seconds after it was viewed.
91+
8692
duration (``int``, *optional*):
8793
Duration of sent video in seconds.
8894
@@ -155,6 +161,9 @@ async def send_video(
155161
# Add caption to the video
156162
app.send_video("me", "video.mp4", caption="recording")
157163
164+
# Send self-destructing video
165+
app.send_photo("me", "video.mp4", ttl_seconds=10)
166+
158167
# Keep track of the progress while uploading
159168
def progress(current, total):
160169
print(f"{current * 100 / total:.1f}%")
@@ -171,6 +180,7 @@ def progress(current, total):
171180
media = raw.types.InputMediaUploadedDocument(
172181
mime_type=self.guess_mime_type(video) or "video/mp4",
173182
file=file,
183+
ttl_seconds=ttl_seconds,
174184
thumb=thumb,
175185
attributes=[
176186
raw.types.DocumentAttributeVideo(
@@ -184,7 +194,8 @@ def progress(current, total):
184194
)
185195
elif re.match("^https?://", video):
186196
media = raw.types.InputMediaDocumentExternal(
187-
url=video
197+
url=video,
198+
ttl_seconds=ttl_seconds
188199
)
189200
else:
190201
media = utils.get_input_media_from_file_id(video, FileType.VIDEO)
@@ -194,6 +205,7 @@ def progress(current, total):
194205
media = raw.types.InputMediaUploadedDocument(
195206
mime_type=self.guess_mime_type(video.name) or "video/mp4",
196207
file=file,
208+
ttl_seconds=ttl_seconds,
197209
thumb=thumb,
198210
attributes=[
199211
raw.types.DocumentAttributeVideo(

pyrogram/types/messages_and_media/message.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,7 @@ async def reply_video(
21242124
caption: str = "",
21252125
parse_mode: Union[str, None] = object,
21262126
caption_entities: List["types.MessageEntity"] = None,
2127+
ttl_seconds: int = None,
21272128
duration: int = 0,
21282129
width: int = 0,
21292130
height: int = 0,
@@ -2181,6 +2182,11 @@ async def reply_video(
21812182
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`):
21822183
List of special entities that appear in the caption, which can be specified instead of __parse_mode__.
21832184
2185+
ttl_seconds (``int``, *optional*):
2186+
Self-Destruct Timer.
2187+
If you set a timer, the video will self-destruct in *ttl_seconds*
2188+
seconds after it was viewed.
2189+
21842190
duration (``int``, *optional*):
21852191
Duration of sent video in seconds.
21862192
@@ -2252,6 +2258,7 @@ async def reply_video(
22522258
caption=caption,
22532259
parse_mode=parse_mode,
22542260
caption_entities=caption_entities,
2261+
ttl_seconds=ttl_seconds,
22552262
duration=duration,
22562263
width=width,
22572264
height=height,

0 commit comments

Comments
 (0)