@@ -43,6 +43,8 @@ async def send_video(
4343 duration : int = 0 ,
4444 width : int = 0 ,
4545 height : int = 0 ,
46+ video_start_timestamp : int = 0 ,
47+ video_cover : Union [str , BinaryIO ] = None ,
4648 thumb : Union [str , BinaryIO ] = None ,
4749 file_name : str = None ,
4850 supports_streaming : bool = True ,
@@ -88,7 +90,7 @@ async def send_video(
8890 video (``str`` | ``BinaryIO``):
8991 Video to send.
9092 Pass a file_id as string to send a video that exists on the Telegram servers,
91- pass an HTTP URL as a string for Telegram to get a video from the Internet,
93+ pass a HTTP URL as a string for Telegram to get a video from the Internet,
9294 pass a file path as string to upload a new video that exists on your local machine, or
9395 pass a binary file-like object with its attribute ".name" set for in-memory uploads.
9496
@@ -119,6 +121,15 @@ async def send_video(
119121 height (``int``, *optional*):
120122 Video height.
121123
124+ video_start_timestamp (``int``, *optional*):
125+ Video startpoint, in seconds.
126+
127+ video_cover (``str`` | ``BinaryIO``, *optional*):
128+ Video cover.
129+ Pass a file_id as string to attach a photo that exists on the Telegram servers,
130+ pass a file path as string to upload a new photo civer that exists on your local machine, or
131+ pass a binary file-like object with its attribute ".name" set for in-memory uploads.
132+
122133 thumb (``str`` | ``BinaryIO``, *optional*):
123134 Thumbnail of the video sent.
124135 The thumbnail should be in JPEG format and less than 200 KB in size.
@@ -227,15 +238,53 @@ async def send_video(
227238 # Send self-destructing video
228239 await app.send_video("me", "video.mp4", ttl_seconds=10)
229240
241+ # Add video_cover to the video
242+ await app.send_video(channel_id, "video.mp4", video_cover="photo.jpg")
243+
230244 # Keep track of the progress while uploading
231245 async def progress(current, total):
232246 print(f"{current * 100 / total:.1f}%")
233247
234248 await app.send_video("me", "video.mp4", progress=progress)
235249 """
236250 file = None
251+ vcover_file = None
252+ vcover_media = None
253+ peer = await self .resolve_peer (chat_id )
237254
238255 try :
256+ if video_cover is not None :
257+ if isinstance (video_cover , str ):
258+ if os .path .isfile (video_cover ):
259+ vcover_media = await self .invoke (
260+ raw .functions .messages .UploadMedia (
261+ peer = peer ,
262+ media = raw .types .InputMediaUploadedPhoto (
263+ file = await self .save_file (video_cover )
264+ )
265+ )
266+ )
267+ elif re .match ("^https?://" , video_cover ):
268+ raise ValueError ("Video cover can't be a URL" )
269+ else :
270+ vcover_file = utils .get_input_media_from_file_id (video_cover , FileType .PHOTO ).id
271+ else :
272+ vcover_media = await self .invoke (
273+ raw .functions .messages .UploadMedia (
274+ peer = peer ,
275+ media = raw .types .InputMediaUploadedPhoto (
276+ file = await self .save_file (video_cover )
277+ )
278+ )
279+ )
280+
281+ if vcover_media :
282+ vcover_file = raw .types .InputPhoto (
283+ id = vcover_media .photo .id ,
284+ access_hash = vcover_media .photo .access_hash ,
285+ file_reference = vcover_media .photo .file_reference
286+ )
287+
239288 if isinstance (video , str ):
240289 if os .path .isfile (video ):
241290 thumb = await self .save_file (thumb )
@@ -246,6 +295,8 @@ async def progress(current, total):
246295 ttl_seconds = ttl_seconds ,
247296 spoiler = has_spoiler ,
248297 thumb = thumb ,
298+ video_cover = vcover_file ,
299+ video_timestamp = video_start_timestamp ,
249300 nosound_video = no_sound ,
250301 attributes = [
251302 raw .types .DocumentAttributeVideo (
@@ -261,7 +312,9 @@ async def progress(current, total):
261312 media = raw .types .InputMediaDocumentExternal (
262313 url = video ,
263314 ttl_seconds = ttl_seconds ,
264- spoiler = has_spoiler
315+ spoiler = has_spoiler ,
316+ video_cover = vcover_file ,
317+ video_timestamp = video_start_timestamp
265318 )
266319 else :
267320 media = utils .get_input_media_from_file_id (video , FileType .VIDEO , ttl_seconds = ttl_seconds , has_spoiler = has_spoiler )
@@ -274,6 +327,8 @@ async def progress(current, total):
274327 ttl_seconds = ttl_seconds ,
275328 spoiler = has_spoiler ,
276329 thumb = thumb ,
330+ video_cover = vcover_file ,
331+ video_timestamp = video_start_timestamp ,
277332 nosound_video = no_sound ,
278333 attributes = [
279334 raw .types .DocumentAttributeVideo (
@@ -290,7 +345,6 @@ async def progress(current, total):
290345
291346 while True :
292347 try :
293- peer = await self .resolve_peer (chat_id )
294348 r = await self .invoke (
295349 raw .functions .messages .SendMedia (
296350 peer = peer ,
0 commit comments