Skip to content

Commit 1a73258

Browse files
committed
add /leech file
1 parent 40a535b commit 1a73258

File tree

4 files changed

+47
-10
lines changed

4 files changed

+47
-10
lines changed

publicleechgroup/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
# the logging things
1919
import logging
20+
import os
2021
from logging.handlers import RotatingFileHandler
2122
from time import time
2223

publicleechgroup/helper_funcs/download_aria_p_n.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ async def call_apropriate_function(
213213
incoming_link,
214214
c_file_name,
215215
sent_message_to_update_tg_p,
216-
is_zip
216+
is_zip,
217+
force_doc=False,
218+
cfn=None
217219
):
218220
if incoming_link.lower().startswith("magnet:"):
219221
sagtus, err_message = add_magnet(aria_instance, incoming_link, c_file_name)
@@ -263,7 +265,9 @@ async def call_apropriate_function(
263265
sent_message_to_update_tg_p,
264266
to_upload_file,
265267
user_id,
266-
response
268+
response,
269+
force_doc=force_doc,
270+
cfn=cfn
267271
)
268272
LOGGER.info(final_response)
269273
message_to_send = ""

publicleechgroup/helper_funcs/upload_to_tg.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ async def upload_to_tg(
5454
from_user,
5555
dict_contatining_uploaded_files,
5656
edit_media=False,
57-
custom_caption=None
57+
custom_caption=None,
58+
force_doc=False,
59+
cfn=None
5860
):
5961
LOGGER.info(local_file_name)
6062
base_file_name = os.path.basename(local_file_name)
@@ -90,7 +92,9 @@ async def upload_to_tg(
9092
from_user,
9193
dict_contatining_uploaded_files,
9294
edit_media,
93-
caption_str
95+
caption_str,
96+
force_doc=force_doc,
97+
cfn=cfn
9498
)
9599
else:
96100
if os.path.getsize(local_file_name) > TG_MAX_FILE_SIZE:
@@ -118,25 +122,40 @@ async def upload_to_tg(
118122
message,
119123
os.path.join(splitted_dir, le_file),
120124
from_user,
121-
dict_contatining_uploaded_files
125+
dict_contatining_uploaded_files,
126+
force_doc=force_doc,
127+
cfn=cfn
122128
)
123129
else:
124130
sent_message = await upload_single_file(
125131
message,
126132
local_file_name,
127133
caption_str,
128134
from_user,
129-
edit_media
135+
edit_media,
136+
force_doc,
137+
cfn
130138
)
131139
if sent_message is not None:
132140
dict_contatining_uploaded_files[os.path.basename(local_file_name)] = sent_message.message_id
133141
# await message.delete()
134142
return dict_contatining_uploaded_files
135143

136144

137-
async def upload_single_file(message, local_file_name, caption_str, from_user, edit_media):
145+
async def upload_single_file(
146+
message,
147+
local_file_name,
148+
caption_str,
149+
from_user,
150+
edit_media,
151+
force_doc=False,
152+
cfn=None
153+
):
138154
await asyncio.sleep(EDIT_SLEEP_TIME_OUT)
139155
sent_message = None
156+
if cfn:
157+
os.rename(local_file_name, cfn)
158+
local_file_name = cfn
140159
start_time = time.time()
141160
#
142161
thumbnail_location = os.path.join(
@@ -151,7 +170,10 @@ async def upload_single_file(message, local_file_name, caption_str, from_user, e
151170
message_for_progress_display = await message.reply_text(
152171
"starting upload of {}".format(os.path.basename(local_file_name))
153172
)
154-
if local_file_name.upper().endswith(("MKV", "MP4", "WEBM")):
173+
174+
if local_file_name.upper().endswith((
175+
"M4V", "MP4", "MOV", "FLV", "WMV", "3GP", "MPEG", "WEBM", "MKV"
176+
)) and not force_doc:
155177
metadata = extractMetadata(createParser(local_file_name))
156178
duration = 0
157179
if metadata.has("duration"):
@@ -230,7 +252,10 @@ async def upload_single_file(message, local_file_name, caption_str, from_user, e
230252
)
231253
if thumb is not None:
232254
os.remove(thumb)
233-
elif local_file_name.upper().endswith(("MP3", "M4A", "M4B", "FLAC", "WAV")):
255+
256+
elif local_file_name.upper().endswith((
257+
"MP3", "M4A", "M4B", "FLAC", "WAV", "AIF", "OGG", "AAC", "DTS"
258+
)) and not force_doc:
234259
metadata = extractMetadata(createParser(local_file_name))
235260
duration = 0
236261
title = ""
@@ -285,6 +310,7 @@ async def upload_single_file(message, local_file_name, caption_str, from_user, e
285310
)
286311
if thumb is not None:
287312
os.remove(thumb)
313+
288314
else:
289315
thumb_image_path = None
290316
if os.path.isfile(thumbnail_location):
@@ -330,5 +356,6 @@ async def upload_single_file(message, local_file_name, caption_str, from_user, e
330356

331357
if message.message_id != message_for_progress_display.message_id:
332358
await message_for_progress_display.delete()
359+
333360
os.remove(local_file_name)
334361
return sent_message

publicleechgroup/plugins/incoming_message_fn.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ async def leech_commandi_f(client, message):
7777
"checking",
7878
quote=True
7979
)
80+
force_doc = False
8081
m_sgra = " ".join(message.command[1:])
82+
if "file" in m_sgra.lower():
83+
force_doc = True
8184
# get link from the incoming message
8285
dl_url, cf_name, _, _ = await extract_link(
8386
message.reply_to_message, "LEECH"
@@ -125,7 +128,9 @@ async def leech_commandi_f(client, message):
125128
dl_url,
126129
new_download_location,
127130
m_,
128-
is_zip
131+
is_zip,
132+
force_doc=force_doc,
133+
cfn=cf_name
129134
)
130135
if not sagtus:
131136
# if FAILED, display the error message

0 commit comments

Comments
 (0)