@@ -40,6 +40,7 @@ async def send_video(
4040 caption_entities : List ["types.MessageEntity" ] = None ,
4141 has_spoiler : bool = None ,
4242 ttl_seconds : int = None ,
43+ view_once : bool = None ,
4344 duration : int = 0 ,
4445 width : int = 0 ,
4546 height : int = 0 ,
@@ -97,6 +98,9 @@ async def send_video(
9798 If you set a timer, the video will self-destruct in *ttl_seconds*
9899 seconds after it was viewed.
99100
101+ view_once (``bool``, *optional*):
102+ Pass True if the photo should be viewable only once.
103+
100104 duration (``int``, *optional*):
101105 Duration of sent video in seconds.
102106
@@ -185,6 +189,9 @@ async def send_video(
185189 # Send self-destructing video
186190 await app.send_video("me", "video.mp4", ttl_seconds=10)
187191
192+ # Send view-once video
193+ await app.send_video("me", "video.mp4", view_once=True)
194+
188195 # Keep track of the progress while uploading
189196 async def progress(current, total):
190197 print(f"{current * 100 / total:.1f}%")
@@ -201,7 +208,7 @@ async def progress(current, total):
201208 media = raw .types .InputMediaUploadedDocument (
202209 mime_type = self .guess_mime_type (video ) or "video/mp4" ,
203210 file = file ,
204- ttl_seconds = ttl_seconds ,
211+ ttl_seconds = 0x7FFFFFFF if view_once else ttl_seconds ,
205212 spoiler = has_spoiler ,
206213 thumb = thumb ,
207214 nosound_video = nosound_video ,
@@ -218,18 +225,18 @@ async def progress(current, total):
218225 elif re .match ("^https?://" , video ):
219226 media = raw .types .InputMediaDocumentExternal (
220227 url = video ,
221- ttl_seconds = ttl_seconds ,
228+ ttl_seconds = 0x7FFFFFFF if view_once else ttl_seconds ,
222229 spoiler = has_spoiler
223230 )
224231 else :
225- media = utils .get_input_media_from_file_id (video , FileType .VIDEO , ttl_seconds = ttl_seconds )
232+ media = utils .get_input_media_from_file_id (video , FileType .VIDEO , ttl_seconds = 0x7FFFFFFF if view_once else ttl_seconds )
226233 else :
227234 thumb = await self .save_file (thumb )
228235 file = await self .save_file (video , progress = progress , progress_args = progress_args )
229236 media = raw .types .InputMediaUploadedDocument (
230237 mime_type = self .guess_mime_type (file_name or video .name ) or "video/mp4" ,
231238 file = file ,
232- ttl_seconds = ttl_seconds ,
239+ ttl_seconds = 0x7FFFFFFF if view_once else ttl_seconds ,
233240 spoiler = has_spoiler ,
234241 thumb = thumb ,
235242 nosound_video = nosound_video ,
0 commit comments