2222from typing import Union
2323
2424import pyrogram
25- from pyrogram .client .ext import BaseClient , utils
25+ from pyrogram .client .ext import BaseClient , FileData , utils
2626from pyrogram .errors import FileIdInvalid
2727
2828
@@ -110,15 +110,15 @@ def download_media(
110110 mime_type = getattr (media , "mime_type" , None )
111111 date = getattr (media , "date" , None )
112112
113- data = self . FileData (
113+ data = FileData (
114114 file_name = file_name ,
115115 file_size = file_size ,
116116 mime_type = mime_type ,
117117 date = date
118118 )
119119
120120 def get_existing_attributes () -> dict :
121- return dict (filter (lambda x : x [1 ] is not None , data ._asdict () .items ()))
121+ return dict (filter (lambda x : x [1 ] is not None , data .__dict__ .items ()))
122122
123123 try :
124124 decoded = utils .decode (file_id_str )
@@ -128,7 +128,7 @@ def get_existing_attributes() -> dict:
128128 unpacked = struct .unpack ("<iiqqib" , decoded )
129129 dc_id , peer_id , volume_id , local_id , is_big = unpacked [1 :]
130130
131- data = self . FileData (
131+ data = FileData (
132132 ** get_existing_attributes (),
133133 media_type = media_type ,
134134 dc_id = dc_id ,
@@ -139,25 +139,25 @@ def get_existing_attributes() -> dict:
139139 )
140140 elif media_type in (0 , 2 , 14 ):
141141 unpacked = struct .unpack ("<iiqqc" , decoded )
142- dc_id , file_id , access_hash , thumb_size = unpacked [1 :]
142+ dc_id , document_id , access_hash , thumb_size = unpacked [1 :]
143143
144- data = self . FileData (
144+ data = FileData (
145145 ** get_existing_attributes (),
146146 media_type = media_type ,
147147 dc_id = dc_id ,
148- file_id = file_id ,
148+ document_id = document_id ,
149149 access_hash = access_hash ,
150150 thumb_size = thumb_size .decode ()
151151 )
152152 elif media_type in (3 , 4 , 5 , 8 , 9 , 10 , 13 ):
153153 unpacked = struct .unpack ("<iiqq" , decoded )
154- dc_id , file_id , access_hash = unpacked [1 :]
154+ dc_id , document_id , access_hash = unpacked [1 :]
155155
156- data = self . FileData (
156+ data = FileData (
157157 ** get_existing_attributes (),
158158 media_type = media_type ,
159159 dc_id = dc_id ,
160- file_id = file_id ,
160+ document_id = document_id ,
161161 access_hash = access_hash
162162 )
163163 else :
0 commit comments