diff --git a/bot/helper/ext_utils/fs_utils.py b/bot/helper/ext_utils/fs_utils.py
index 3844310c4fb..d1d965450ec 100644
--- a/bot/helper/ext_utils/fs_utils.py
+++ b/bot/helper/ext_utils/fs_utils.py
@@ -10,15 +10,12 @@
from PIL import Image
from hachoir.parser import createParser
from hachoir.metadata import extractMetadata
-from fsplit.filesplit import Filesplit
from .exceptions import NotSupportedExtractionArchive
from bot import aria2, LOGGER, DOWNLOAD_DIR, get_client, TG_SPLIT_SIZE
VIDEO_SUFFIXES = ("M4V", "MP4", "MOV", "FLV", "WMV", "3GP", "MPG", "WEBM", "MKV", "AVI")
-fs = Filesplit()
-
def clean_download(path: str):
if os.path.exists(path):
LOGGER.info(f"Cleaning Download: {path}")
@@ -168,14 +165,14 @@ def take_ss(video_file, duration):
subprocess.run(["ffmpeg", "-hide_banner", "-loglevel", "error", "-ss", str(duration),
"-i", video_file, "-vframes", "1", des_dir])
if not os.path.lexists(des_dir):
- return None, 0, 0
+ return None, 0
Image.open(des_dir).convert("RGB").save(des_dir)
img = Image.open(des_dir)
w, h = img.size
img.resize((320, h))
img.save(des_dir, "JPEG")
- return des_dir, 320, h
+ return des_dir, 320
def split(path, size, split_size, start_time=0, i=1):
out_dir = os.path.dirname(path)
@@ -184,8 +181,9 @@ def split(path, size, split_size, start_time=0, i=1):
base_name, extension = os.path.splitext(path)
metadata = extractMetadata(createParser(path))
total_duration = metadata.get('duration').seconds - 8
+ split_size = split_size - 2000000
while start_time < total_duration:
- parted_name = "{}.part{}{}".format(str(base_name), str(i).zfill(2), str(extension))
+ parted_name = "{}.part{}{}".format(str(base_name), str(i).zfill(3), str(extension))
out_path = os.path.join(out_dir, parted_name)
subprocess.run(["ffmpeg", "-hide_banner", "-loglevel", "error", "-i",
path, "-ss", str(start_time), "-fs", str(split_size),
@@ -193,14 +191,13 @@ def split(path, size, split_size, start_time=0, i=1):
out_size = get_path_size(out_path)
if out_size > TG_SPLIT_SIZE:
dif = out_size - TG_SPLIT_SIZE
- split_size = split_size - dif
+ split_size = TG_SPLIT_SIZE - dif
os.remove(out_path)
return split(path, size, split_size, start_time, i)
metadata = extractMetadata(createParser(out_path))
start_time = start_time + metadata.get('duration').seconds - 5
i = i + 1
else:
- #subprocess.run(["split", "--numeric-suffixes=1", "--suffix-length=5", f"--bytes={split_size}", path, out_dir])
- fs.split(file=path, split_size=split_size, output_dir=out_dir)
- csv_path = os.path.join(out_dir, "fs_manifest.csv")
- os.remove(csv_path)
+ out_path = os.path.join(out_dir, base_name + ".")
+ subprocess.run(["split", "--numeric-suffixes=1", "--suffix-length=3", f"--bytes={split_size}", path, out_path])
+
diff --git a/bot/helper/mirror_utils/download_utils/qbit_downloader.py b/bot/helper/mirror_utils/download_utils/qbit_downloader.py
index 3d967bebb34..53fda11207d 100644
--- a/bot/helper/mirror_utils/download_utils/qbit_downloader.py
+++ b/bot/helper/mirror_utils/download_utils/qbit_downloader.py
@@ -53,12 +53,9 @@ def add_torrent(self, link, dire, listener, qbitsel):
self.ext_hash = get_hash_magnet(link)
tor_info = self.client.torrents_info(torrent_hashes=self.ext_hash)
if len(tor_info) > 0:
- if tor_info[0].state == "pausedDL":
- self.client.torrents_delete(torrent_hashes=self.ext_hash)
- else:
- sendMessage("This Torrent is already in list.", listener.bot, listener.update)
- self.client.auth_log_out()
- return
+ sendMessage("This Torrent is already in list.", listener.bot, listener.update)
+ self.client.auth_log_out()
+ return
if is_file:
op = self.client.torrents_add(torrent_files=[link], save_path=dire)
os.remove(link)
diff --git a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
index 4551fc97abf..17766d6fccd 100644
--- a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
+++ b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
@@ -45,8 +45,12 @@ def upload(self):
self.user_settings()
for dirpath, subdir, files in sorted(os.walk(path)):
for file in sorted(files):
+ if self.is_cancelled:
+ return
up_path = os.path.join(dirpath, file)
self.upload_file(up_path, file)
+ if self.is_cancelled:
+ return
msgs_dict[file] = self.sent_msg.message_id
os.remove(up_path)
self.last_uploaded = 0
@@ -54,6 +58,7 @@ def upload(self):
self.__listener.onUploadComplete(self.name, None, msgs_dict, None, None)
def upload_file(self, up_path, file):
+ cap_mono = f"{file}
"
notMedia = False
thumb = self.thumb
try:
@@ -66,11 +71,12 @@ def upload_file(self, up_path, file):
if metadata.has("duration"):
duration = metadata.get("duration").seconds
if thumb is None:
- thumb, width, height = take_ss(up_path, duration)
+ thumb, width = take_ss(up_path, duration)
+ if self.is_cancelled:
+ return
self.sent_msg = self.sent_msg.reply_video(video=up_path,
quote=True,
- caption=file,
- parse_mode="html",
+ caption=cap_mono,
duration=duration,
width=width,
height=height,
@@ -88,8 +94,7 @@ def upload_file(self, up_path, file):
artist = metadata.get("artist") if metadata.has("artist") else None
self.sent_msg = self.sent_msg.reply_audio(audio=up_path,
quote=True,
- caption=file,
- parse_mode="html",
+ caption=cap_mono,
duration=duration,
performer=artist,
title=title,
@@ -99,8 +104,7 @@ def upload_file(self, up_path, file):
elif file.upper().endswith(IMAGE_SUFFIXES):
self.sent_msg = self.sent_msg.reply_photo(photo=up_path,
quote=True,
- caption=file,
- parse_mode="html",
+ caption=cap_mono,
supports_streaming=True,
disable_notification=True,
progress=self.upload_progress)
@@ -110,8 +114,7 @@ def upload_file(self, up_path, file):
self.sent_msg = self.sent_msg.reply_document(document=up_path,
quote=True,
thumb=thumb,
- caption=file,
- parse_mode="html",
+ caption=cap_mono,
disable_notification=True,
progress=self.upload_progress)
except FloodWait as f:
diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py
index 28a3a95cdf9..c3e6c4d0186 100644
--- a/bot/modules/mirror.py
+++ b/bot/modules/mirror.py
@@ -205,7 +205,7 @@ def onUploadComplete(self, link: str, size, files, folders, typ):
chat_id = str(self.message.chat.id)
count = len(files)
if OWNER_ID == int(chat_id):
- msg = f'Name: {link}\n'
+ msg = f'Name: {link}
\n'
msg += f'Total Files: {count}'
sendMessage(msg, self.bot, self.update)
else:
diff --git a/requirements.txt b/requirements.txt
index 4a547401d25..07fa2c92624 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,7 +6,6 @@ attrdict
beautifulsoup4
cloudscrape
feedparser
-filesplit
google-api-python-client
google-auth-httplib2
google-auth-oauthlib
@@ -15,7 +14,7 @@ hachoir
js2py
lk21
lxml
-Pillow
+pillow
psutil
psycopg2-binary
pybase64