1919import asyncio
2020import os
2121from datetime import datetime
22- from typing import Union , Optional , Callable , BinaryIO , List
22+ from typing import Union , Optional , Callable , BinaryIO , List , Literal , overload
2323
2424import pyrogram
2525from pyrogram import types , utils
2929
3030
3131class DownloadMedia :
32+ @overload
33+ async def download_media (
34+ self : "pyrogram.Client" ,
35+ message : Union [
36+ str ,
37+ "types.Message" ,
38+ "types.Story" ,
39+ "types.Audio" ,
40+ "types.Document" ,
41+ "types.Photo" ,
42+ "types.Sticker" ,
43+ "types.Animation" ,
44+ "types.Video" ,
45+ "types.Voice" ,
46+ "types.VideoNote" ,
47+ "types.PaidMediaInfo" ,
48+ "types.Thumbnail" ,
49+ "types.StrippedThumbnail" ,
50+ "types.PaidMediaPreview" ,
51+ ],
52+ file_name : str = DEFAULT_DOWNLOAD_DIR ,
53+ * ,
54+ in_memory : bool = False ,
55+ block : Literal [False ],
56+ progress : Callable = None ,
57+ progress_args : tuple = (),
58+ ) -> None : ...
59+
60+ @overload
61+ async def download_media (
62+ self : "pyrogram.Client" ,
63+ message : Union [
64+ str ,
65+ "types.Message" ,
66+ "types.Story" ,
67+ "types.Audio" ,
68+ "types.Document" ,
69+ "types.Photo" ,
70+ "types.Sticker" ,
71+ "types.Animation" ,
72+ "types.Video" ,
73+ "types.Voice" ,
74+ "types.VideoNote" ,
75+ "types.PaidMediaInfo" ,
76+ "types.Thumbnail" ,
77+ "types.StrippedThumbnail" ,
78+ "types.PaidMediaPreview" ,
79+ ],
80+ file_name : str = DEFAULT_DOWNLOAD_DIR ,
81+ * ,
82+ in_memory : Literal [True ],
83+ block : bool = True ,
84+ progress : Callable = None ,
85+ progress_args : tuple = (),
86+ ) -> Union [BinaryIO , list [BinaryIO ]]: ...
87+
88+ @overload
89+ async def download_media (
90+ self : "pyrogram.Client" ,
91+ message : Union [
92+ str ,
93+ "types.Message" ,
94+ "types.Story" ,
95+ "types.Audio" ,
96+ "types.Document" ,
97+ "types.Photo" ,
98+ "types.Sticker" ,
99+ "types.Animation" ,
100+ "types.Video" ,
101+ "types.Voice" ,
102+ "types.VideoNote" ,
103+ "types.PaidMediaInfo" ,
104+ "types.Thumbnail" ,
105+ "types.StrippedThumbnail" ,
106+ "types.PaidMediaPreview" ,
107+ ],
108+ file_name : str = DEFAULT_DOWNLOAD_DIR ,
109+ * ,
110+ in_memory : Literal [False ],
111+ block : bool = True ,
112+ progress : Callable = None ,
113+ progress_args : tuple = (),
114+ ) -> Union [str , list [str ]]:
115+ ...
116+
32117 async def download_media (
33118 self : "pyrogram.Client" ,
34119 message : Union [
@@ -53,7 +138,7 @@ async def download_media(
53138 block : bool = True ,
54139 progress : Callable = None ,
55140 progress_args : tuple = ()
56- ) -> Optional [ Union [Union [ str , BinaryIO ] , List [Union [str , BinaryIO ]]] ]:
141+ ) -> Union [str , BinaryIO , List [Union [str , BinaryIO ]], None ]:
57142 """Download the media from a message.
58143
59144 .. include:: /_includes/usable-by/users-bots.rst
0 commit comments