From b9eab058d8b9a5364ba58da92363e0e6c6e3d0d5 Mon Sep 17 00:00:00 2001
From: huzunluartemis <111054559+hartemis@users.noreply.github.com>
Date: Wed, 28 Sep 2022 20:37:24 +0300
Subject: [PATCH 1/7] playlist index -> filename
---
.../mirror_utils/download_utils/yt_dlp_download_helper.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/helper/mirror_utils/download_utils/yt_dlp_download_helper.py b/bot/helper/mirror_utils/download_utils/yt_dlp_download_helper.py
index 45ac12ec93..b2a42ad8fb 100644
--- a/bot/helper/mirror_utils/download_utils/yt_dlp_download_helper.py
+++ b/bot/helper/mirror_utils/download_utils/yt_dlp_download_helper.py
@@ -179,7 +179,7 @@ def add_download(self, link, path, name, qual, playlist, args):
if self.__is_cancelled:
return
if self.is_playlist:
- self.opts['outtmpl'] = f"{path}/{self.name}/%(title)s.%(ext)s"
+ self.opts['outtmpl'] = f"{path}/{self.name}/%(playlist_index)s.%(n_entries)s %(title)s.%(ext)s"
elif args is None:
self.opts['outtmpl'] = f"{path}/{self.name}"
else:
From 247e550a22b9a5b38ec5c1f86b4126d9e49766c8 Mon Sep 17 00:00:00 2001
From: huzunluartemis <111054559+hartemis@users.noreply.github.com>
Date: Wed, 28 Sep 2022 20:47:06 +0300
Subject: [PATCH 2/7] new FILENAME_WITH_PATHS variable for upload with full
filename + filepaths
this will help to users who extract archieves from compressed files.
---
.../mirror_utils/upload_utils/pyrogramEngine.py | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
index 263a7e78eb..b0242cf0cf 100644
--- a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
+++ b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
@@ -5,7 +5,7 @@
from PIL import Image
from threading import RLock
-from bot import AS_DOCUMENT, AS_DOC_USERS, AS_MEDIA_USERS, CUSTOM_FILENAME, EXTENSION_FILTER, app, app_session, BOT_PM, LEECH_LOG
+from bot import AS_DOCUMENT, AS_DOC_USERS, AS_MEDIA_USERS, CUSTOM_FILENAME, EXTENSION_FILTER, app, app_session, BOT_PM, LEECH_LOG, FILENAME_WITH_PATHS
from bot.helper.ext_utils.fs_utils import take_ss, get_media_info, get_media_streams, clean_unwanted
from bot.helper.ext_utils.bot_utils import get_readable_file_size
@@ -85,14 +85,25 @@ def __upload_file(self, up_path, file_, dirpath):
LEECH_DUMP = int(setstr)
leechchat = LEECH_DUMP
else: leechchat = self.__listener.message.chat.id
+ # print full path file location +
+ if FILENAME_WITH_PATHS:
+ keption = DOWNLOAD_DIR
+ if not keption.endswith('/'): keption = keption + '/'
+ if not keption.startswith('/'): keption = '/' + keption
+ keption = up_path.replace(keption, '', 1)
+ zoy = keption.split('/')[0]
+ keption = keption.replace(zoy, '', 1)
+ if keption.startswith('/'): keption = keption.replace('/', '', 1)
+ else: keption = None
+ # print full path file location -
if CUSTOM_FILENAME is not None:
- cap_mono = f"{CUSTOM_FILENAME} {file_}"
+ cap_mono = f"{CUSTOM_FILENAME} {keption or file_}"
file_ = f"{CUSTOM_FILENAME} {file_}"
new_path = ospath.join(dirpath, file_)
osrename(up_path, new_path)
up_path = new_path
else:
- cap_mono = f"{file_}"
+ cap_mono = f"{keption or file_}"
notMedia = False
thumb = self.__thumb
self.__is_corrupted = False
From 6f6763ddc3ccab14c0bd5fc707c38629ac3941ed Mon Sep 17 00:00:00 2001
From: huzunluartemis <111054559+hartemis@users.noreply.github.com>
Date: Wed, 28 Sep 2022 20:48:54 +0300
Subject: [PATCH 3/7] Update __init__.py
---
bot/__init__.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/bot/__init__.py b/bot/__init__.py
index e1fb0732cc..3ace911533 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -352,6 +352,11 @@ def aria2c_init():
AS_DOCUMENT = AS_DOCUMENT.lower() == 'true'
except:
AS_DOCUMENT = False
+try:
+ FILENAME_WITH_PATHS = getConfig('FILENAME_WITH_PATHS')
+ FILENAME_WITH_PATHS = FILENAME_WITH_PATHS.lower() == 'true'
+except:
+ FILENAME_WITH_PATHS = False
try:
EQUAL_SPLITS = getConfig('EQUAL_SPLITS')
EQUAL_SPLITS = EQUAL_SPLITS.lower() == 'true'
From 15d05387db45a3cd9bdc7bfa03b2b88e25a0cdcd Mon Sep 17 00:00:00 2001
From: huzunluartemis <111054559+hartemis@users.noreply.github.com>
Date: Wed, 28 Sep 2022 20:51:44 +0300
Subject: [PATCH 4/7] Update README.md
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 37d82e79b6..78f62e214d 100644
--- a/README.md
+++ b/README.md
@@ -198,6 +198,7 @@ Fill up rest of the fields. Meaning of each field is discussed below:
- `LEECH_SPLIT_SIZE`: Size of split in bytes. Default is `2GB`. Default is `4GB` if your account is premium. `Str`
- `AS_DOCUMENT`: Default type of Telegram file upload. Default is `False` mean as media. `Bool`
- `EQUAL_SPLITS`: Split files larger than **LEECH_SPLIT_SIZE** into equal parts size (Not working with zip cmd). Default is `False`. `Bool`
+- `FILENAME_WITH_PATHS`: Send files along with their directory names. Useful for archives. Default is `False`. `Bool`
- `CUSTOM_FILENAME`: Add custom word to leeched file name. `Str`
- `USER_SESSION_STRING`: To download/upload from your telegram account. If you own premium account. To generate session string use this command `python3 generate_string_session.py` after mounting repo folder for sure. `Str`. **NOTE**: You can't use bot with private message. Use it with supergroup or channel.
@@ -563,4 +564,4 @@ Where host is the name of extractor (eg. instagram, Twitch). Multiple accounts o
-----
-Base Repo Credit: [Anasty](https://github.com/anasty17/mirror-leech-telegram-bot)
\ No newline at end of file
+Base Repo Credit: [Anasty](https://github.com/anasty17/mirror-leech-telegram-bot)
From b0811855f2e75e06968fbe36eaaa8d5390d407df Mon Sep 17 00:00:00 2001
From: huzunluartemis <111054559+hartemis@users.noreply.github.com>
Date: Wed, 28 Sep 2022 21:23:00 +0300
Subject: [PATCH 5/7] Update pyrogramEngine.py
---
bot/helper/mirror_utils/upload_utils/pyrogramEngine.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
index b0242cf0cf..a9d627b878 100644
--- a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
+++ b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
@@ -5,7 +5,7 @@
from PIL import Image
from threading import RLock
-from bot import AS_DOCUMENT, AS_DOC_USERS, AS_MEDIA_USERS, CUSTOM_FILENAME, EXTENSION_FILTER, app, app_session, BOT_PM, LEECH_LOG, FILENAME_WITH_PATHS
+from bot import AS_DOCUMENT, AS_DOC_USERS, AS_MEDIA_USERS, CUSTOM_FILENAME, EXTENSION_FILTER, app, app_session, BOT_PM, LEECH_LOG, FILENAME_WITH_PATHS, DOWNLOAD_DIR
from bot.helper.ext_utils.fs_utils import take_ss, get_media_info, get_media_streams, clean_unwanted
from bot.helper.ext_utils.bot_utils import get_readable_file_size
From f2a2cde4ed108348cd4388c161b4c3d2953e4ef7 Mon Sep 17 00:00:00 2001
From: huzunluartemis <111054559+hartemis@users.noreply.github.com>
Date: Wed, 28 Sep 2022 21:33:53 +0300
Subject: [PATCH 6/7] fix #135
---
bot/helper/mirror_utils/upload_utils/pyrogramEngine.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
index a9d627b878..94e595d890 100644
--- a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
+++ b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
@@ -138,7 +138,7 @@ def __upload_file(self, up_path, file_, dirpath):
supports_streaming=True,
disable_notification=True,
progress=self.__upload_progress)
- if not self.isPrivate and BOT_PM:
+ if BOT_PM:
try:
app.copy_message(chat_id=self.__user_id, from_chat_id=self.__sent_msg.chat.id, message_id=self.__sent_msg.id)
except Exception as err:
@@ -153,7 +153,7 @@ def __upload_file(self, up_path, file_, dirpath):
thumb=thumb,
disable_notification=True,
progress=self.__upload_progress)
- if not self.isPrivate and BOT_PM:
+ if BOT_PM:
try:
app.copy_message(chat_id=self.__user_id, from_chat_id=self.__sent_msg.chat.id, message_id=self.__sent_msg.id)
except Exception as err:
@@ -163,7 +163,7 @@ def __upload_file(self, up_path, file_, dirpath):
caption=cap_mono,
disable_notification=True,
progress=self.__upload_progress)
- if not self.isPrivate and BOT_PM:
+ if BOT_PM:
try:
app.copy_message(chat_id=self.__user_id, from_chat_id=self.__sent_msg.chat.id, message_id=self.__sent_msg.id)
except Exception as err:
@@ -182,7 +182,7 @@ def __upload_file(self, up_path, file_, dirpath):
caption=cap_mono,
disable_notification=True,
progress=self.__upload_progress)
- if not self.isPrivate and BOT_PM:
+ if BOT_PM:
try:
app.copy_message(chat_id=self.__user_id, from_chat_id=self.__sent_msg.chat.id, message_id=self.__sent_msg.id)
except Exception as err:
From fb8582fd9ff48ee2099a3498634c7e7df5668c00 Mon Sep 17 00:00:00 2001
From: huzunluartemis <111054559+hartemis@users.noreply.github.com>
Date: Wed, 28 Sep 2022 21:38:01 +0300
Subject: [PATCH 7/7] copyable filenames
---
bot/helper/mirror_utils/upload_utils/pyrogramEngine.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
index 94e595d890..af1e7d35bd 100644
--- a/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
+++ b/bot/helper/mirror_utils/upload_utils/pyrogramEngine.py
@@ -97,13 +97,13 @@ def __upload_file(self, up_path, file_, dirpath):
else: keption = None
# print full path file location -
if CUSTOM_FILENAME is not None:
- cap_mono = f"{CUSTOM_FILENAME} {keption or file_}"
+ cap_mono = f"{CUSTOM_FILENAME} {keption or file_}
"
file_ = f"{CUSTOM_FILENAME} {file_}"
new_path = ospath.join(dirpath, file_)
osrename(up_path, new_path)
up_path = new_path
else:
- cap_mono = f"{keption or file_}"
+ cap_mono = f"{keption or file_}
"
notMedia = False
thumb = self.__thumb
self.__is_corrupted = False