@@ -96,19 +96,21 @@ async def upload(self):
96
96
await self .__listener .onUploadComplete (None , size , self .__msgs_dict , self .__total_files , self .__corrupted , self .name )
97
97
98
98
async def __upload_file (self , up_path , file ):
99
- thumb_path = self .__thumb
99
+ thumb = self .__thumb
100
100
self .__is_corrupted = False
101
101
cap_mono = f"<code>{ file } </code>"
102
102
try :
103
103
is_video , is_audio , is_image = await get_document_type (up_path )
104
104
105
- if not is_image and thumb_path is None :
105
+ if not is_image and thumb is None :
106
106
file_name = ospath .splitext (file )[0 ]
107
107
thumb_path = f"{ self .__path } /yt-dlp-thumb/{ file_name } .jpg"
108
+ if ospath .isfile (thumb_path ):
109
+ thumb = thumb_path
108
110
109
111
if self .__as_doc or (not is_video and not is_audio and not is_image ):
110
- if is_video and thumb_path is None :
111
- thumb_path = await take_ss (up_path , None )
112
+ if is_video and thumb is None :
113
+ thumb = await take_ss (up_path , None )
112
114
if self .__is_cancelled :
113
115
return
114
116
if config_dict ['LEECH_LOG' ]:
@@ -117,7 +119,7 @@ async def __upload_file(self, up_path, file):
117
119
chat_id = int (chat ),
118
120
document = up_path ,
119
121
caption = cap_mono ,
120
- thumb = thumb_path ,
122
+ thumb = thumb ,
121
123
disable_notification = True ,
122
124
progress = self .__upload_progress )
123
125
if config_dict ['BOT_PM' ]:
@@ -133,7 +135,7 @@ async def __upload_file(self, up_path, file):
133
135
document = up_path ,
134
136
caption = cap_mono ,
135
137
quote = True ,
136
- thumb = thumb_path ,
138
+ thumb = thumb ,
137
139
disable_notification = True ,
138
140
progress = self .__upload_progress )
139
141
if is_video :
@@ -142,10 +144,10 @@ async def __upload_file(self, up_path, file):
142
144
osrename (up_path , new_path )
143
145
up_path = new_path
144
146
duration = (await get_media_info (up_path ))[0 ]
145
- if thumb_path is None :
146
- thumb_path = await take_ss (up_path , duration )
147
- if thumb_path is not None :
148
- with Image .open (thumb_path ) as img :
147
+ if thumb is None :
148
+ thumb = await take_ss (up_path , duration )
149
+ if thumb is not None :
150
+ with Image .open (thumb ) as img :
149
151
width , height = img .size
150
152
else :
151
153
width = 480
@@ -161,7 +163,7 @@ async def __upload_file(self, up_path, file):
161
163
duration = duration ,
162
164
width = width ,
163
165
height = height ,
164
- thumb = thumb_path ,
166
+ thumb = thumb ,
165
167
supports_streaming = True ,
166
168
disable_notification = True ,
167
169
progress = self .__upload_progress )
@@ -181,7 +183,7 @@ async def __upload_file(self, up_path, file):
181
183
caption = cap_mono ,
182
184
quote = True ,
183
185
disable_notification = True ,
184
- thumb = thumb_path ,
186
+ thumb = thumb ,
185
187
supports_streaming = True ,
186
188
duration = duration ,
187
189
progress = self .__upload_progress )
@@ -197,7 +199,7 @@ async def __upload_file(self, up_path, file):
197
199
duration = duration ,
198
200
performer = artist ,
199
201
title = title ,
200
- thumb = thumb_path ,
202
+ thumb = thumb ,
201
203
progress = self .__upload_progress )
202
204
if config_dict ['BOT_PM' ]:
203
205
try :
@@ -215,7 +217,7 @@ async def __upload_file(self, up_path, file):
215
217
duration = duration ,
216
218
performer = artist ,
217
219
title = title ,
218
- thumb = thumb_path ,
220
+ thumb = thumb ,
219
221
disable_notification = True ,
220
222
progress = self .__upload_progress )
221
223
elif is_image :
@@ -244,14 +246,14 @@ async def __upload_file(self, up_path, file):
244
246
quote = True ,
245
247
disable_notification = True ,
246
248
progress = self .__upload_progress )
247
- if self .__thumb is None and thumb_path is not None and ospath .lexists ( thumb_path ):
248
- osremove (thumb_path )
249
+ if self .__thumb is None and thumb is not None and ospath .exists ( thumb ):
250
+ osremove (thumb )
249
251
except FloodWait as f :
250
252
LOGGER .warning (str (f ))
251
253
await sleep (f .value )
252
254
except Exception as err :
253
- if self .__thumb is None and thumb_path is not None and ospath .lexists ( thumb_path ):
254
- osremove (thumb_path )
255
+ if self .__thumb is None and thumb is not None and ospath .exists ( thumb ):
256
+ osremove (thumb )
255
257
err_type = "RPCError: " if isinstance (err , RPCError ) else ""
256
258
LOGGER .error (f"{ err_type } { err } . Path: { up_path } " )
257
259
raise err
@@ -279,7 +281,7 @@ def __user_settings(self):
279
281
user_id = self .__listener .message .from_user .id
280
282
user_dict = user_data .get (user_id , {})
281
283
self .__as_doc = user_dict .get ('as_doc' ) or config_dict ['AS_DOCUMENT' ]
282
- if not ospath .lexists (self .__thumb ):
284
+ if not ospath .exists (self .__thumb ):
283
285
self .__thumb = None
284
286
285
287
async def __prepare_file (self , file_ , dirpath ):
0 commit comments