Skip to content

Commit

Permalink
v1.1.3-x 🛠 Bug Fixes (4GB Leech) & More
Browse files Browse the repository at this point in the history
>> Added New Vars `SOURCE_LINK`, 
`DELETE_LINKS`, `MIRROR_FILENAME_PREFIX`, `MIRROR_FILENAME_SUFFIX` & `MIRROR_FILENAME_REMNAME`
>> Fixed All 4GB Bugs ( New Advanced Way )
>> Changed File Format Func, More Consize & added Auto Remove www. Links
>> Added Source Link & Delete User Links for Group Usage
>> Added Modes with User Initail Link Type & Elapsed Time
>> Added New Method for Buttons on 2GB+ Files
>> Added Prefix, Suffix & Remname for Mirror/Clone Settings 
>> Removed URL Buttons on Leech Complete, and Reverted to Msg with Link.
>> Fixed Limits for Owner / Sudo
>> Added Auto Delete on Help Messages
>> Fixed Bot Status Footer
>> More Minor Unnoticeable changes around the Corners...
>> More Updates in Nxt Update !! ( Links Log & New DDL Servers )

THANK YOU ... ( Leave a Star & Fork in Supporting WZML-X )
  • Loading branch information
SilentDemonSD authored Jun 28, 2023
1 parent 0b40e81 commit 01f7581
Show file tree
Hide file tree
Showing 29 changed files with 426 additions and 253 deletions.
35 changes: 31 additions & 4 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
def get_version():
MAJOR = '1'
MINOR = '1'
PATCH = '2'
PATCH = '3'
return f"v{MAJOR}.{MINOR}.{PATCH}-x"


Expand Down Expand Up @@ -185,9 +185,13 @@ def get_version():
USER_SESSION_STRING = environ.get('USER_SESSION_STRING', '')
if len(USER_SESSION_STRING) != 0:
log_info("Creating client from USER_SESSION_STRING")
user = tgClient('user', TELEGRAM_API, TELEGRAM_HASH, session_string=USER_SESSION_STRING,
parse_mode=enums.ParseMode.HTML).start()
IS_PREMIUM_USER = user.me.is_premium
try:
user = tgClient('user', TELEGRAM_API, TELEGRAM_HASH, session_string=USER_SESSION_STRING,
parse_mode=enums.ParseMode.HTML).start()
IS_PREMIUM_USER = user.me.is_premium
except Exception as e:
log_error(f"Failed making client from USER_SESSION_STRING : [{e.NAME}] {e.MESSAGE}")
user = ''

MEGA_EMAIL = environ.get('MEGA_EMAIL', '')
MEGA_PASSWORD = environ.get('MEGA_PASSWORD', '')
Expand Down Expand Up @@ -227,6 +231,18 @@ def get_version():
LEECH_FILENAME_REMNAME = environ.get('LEECH_FILENAME_REMNAME', '')
if len(LEECH_FILENAME_REMNAME) == 0:
LEECH_FILENAME_REMNAME = ''

MIRROR_FILENAME_PREFIX = environ.get('MIRROR_FILENAME_PREFIX', '')
if len(MIRROR_FILENAME_PREFIX) == 0:
MIRROR_FILENAME_PREFIX = ''

MIRROR_FILENAME_SUFFIX = environ.get('MIRROR_FILENAME_SUFFIX', '')
if len(MIRROR_FILENAME_SUFFIX) == 0:
MIRROR_FILENAME_SUFFIX = ''

MIRROR_FILENAME_REMNAME = environ.get('MIRROR_FILENAME_REMNAME', '')
if len(MIRROR_FILENAME_REMNAME) == 0:
MIRROR_FILENAME_REMNAME = ''

SEARCH_PLUGINS = environ.get('SEARCH_PLUGINS', '')
if len(SEARCH_PLUGINS) == 0:
Expand Down Expand Up @@ -306,6 +322,12 @@ def get_version():
SHOW_MEDIAINFO = environ.get('SHOW_MEDIAINFO', '')
SHOW_MEDIAINFO = SHOW_MEDIAINFO.lower() == 'true'

SOURCE_LINK = environ.get('SOURCE_LINK', '')
SOURCE_LINK = SOURCE_LINK.lower() == 'true'

DELETE_LINKS = environ.get('DELETE_LINKS', '')
DELETE_LINKS = DELETE_LINKS.lower() == 'true'

EQUAL_SPLITS = environ.get('EQUAL_SPLITS', '')
EQUAL_SPLITS = EQUAL_SPLITS.lower() == 'true'

Expand Down Expand Up @@ -507,6 +529,7 @@ def get_version():
'CAP_FONT': CAP_FONT,
'CMD_SUFFIX': CMD_SUFFIX,
'DATABASE_URL': DATABASE_URL,
'DELETE_LINKS': DELETE_LINKS,
'DEFAULT_UPLOAD': DEFAULT_UPLOAD,
'DOWNLOAD_DIR': DOWNLOAD_DIR,
'STORAGE_THRESHOLD': STORAGE_THRESHOLD,
Expand Down Expand Up @@ -547,6 +570,9 @@ def get_version():
'LEECH_FILENAME_SUFFIX': LEECH_FILENAME_SUFFIX,
'LEECH_FILENAME_CAPTION': LEECH_FILENAME_CAPTION,
'LEECH_FILENAME_REMNAME': LEECH_FILENAME_REMNAME,
'MIRROR_FILENAME_PREFIX': MIRROR_FILENAME_PREFIX,
'MIRROR_FILENAME_SUFFIX': MIRROR_FILENAME_SUFFIX,
'MIRROR_FILENAME_REMNAME': MIRROR_FILENAME_REMNAME,
'LEECH_SPLIT_SIZE': LEECH_SPLIT_SIZE,
'LOGIN_PASS': LOGIN_PASS,
'TOKEN_TIMEOUT': TOKEN_TIMEOUT,
Expand All @@ -572,6 +598,7 @@ def get_version():
'SEARCH_PLUGINS': SEARCH_PLUGINS,
'SET_COMMANDS': SET_COMMANDS,
'SHOW_MEDIAINFO': SHOW_MEDIAINFO,
'SOURCE_LINK': SOURCE_LINK,
'STATUS_LIMIT': STATUS_LIMIT,
'STATUS_UPDATE_INTERVAL': STATUS_UPDATE_INTERVAL,
'STOP_DUPLICATE': STOP_DUPLICATE,
Expand Down
25 changes: 10 additions & 15 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ def get_rclone_version():

class EngineStatus:
STATUS_ARIA = f"Aria2 v{aria2.client.get_version()['version']}"
STATUS_GD = f"G-API v{get_distribution('google-api-python-client').version}"
STATUS_GD = f"Google-API v{get_distribution('google-api-python-client').version}"
STATUS_MEGA = f"MegaSDK v{MegaApi('test').getVersion()}"
STATUS_QB = f"qBit {get_client().app.version}"
STATUS_TG = f"Pyro v{get_distribution('pyrogram').version}"
STATUS_TG = f"Pyrogram v{get_distribution('pyrogram').version}"
STATUS_YT = f"yt-dlp v{get_distribution('yt-dlp').version}"
STATUS_EXT = "pExtract"
STATUS_SPLIT_MERGE = f"ffmpeg v{get_ffmpeg_version()}"
Expand All @@ -199,26 +199,23 @@ def get_readable_message():
globals()['PAGE_NO'] = PAGES
for download in list(download_dict.values())[STATUS_START:STATUS_LIMIT+STATUS_START]:
msg_link = download.message.link if download.message.chat.type in [
ChatType.SUPERGROUP, ChatType.CHANNEL] else ''
ChatType.SUPERGROUP, ChatType.CHANNEL] and not config_dict['DELETE_LINKS'] else ''
msg += BotTheme('STATUS_NAME', Name=escape(f'{download.name()}'))
if download.status() not in [MirrorStatus.STATUS_SPLITTING, MirrorStatus.STATUS_SEEDING]:
if download.status() != MirrorStatus.STATUS_UPLOADDDL:
msg += BotTheme('BAR', Bar=f"{get_progress_bar_string(download.progress())} {download.progress()}")
msg += BotTheme('PROCESSED',
Processed=f"{download.processed_bytes()} of {download.size()}")
msg += BotTheme('PROCESSED', Processed=f"{download.processed_bytes()} of {download.size()}")
msg += BotTheme('STATUS', Status=download.status(), Url=msg_link)
if download.status() != MirrorStatus.STATUS_UPLOADDDL:
msg += BotTheme('ETA', Eta=download.eta())
if download.status() != MirrorStatus.STATUS_UPLOADDDL:
msg += BotTheme('SPEED', Speed=download.speed())
msg += BotTheme('ELAPSED', Elapsed=get_readable_time(time() -
download.message.date.timestamp()))
msg += BotTheme('ELAPSED', Elapsed=get_readable_time(time() - download.message.date.timestamp()))
msg += BotTheme('ENGINE', Engine=download.eng())
msg += BotTheme('STA_MODE', Mode=download.upload_details['mode'])
if hasattr(download, 'seeders_num'):
try:
msg += BotTheme('SEEDERS', Seeders=download.seeders_num())
msg += BotTheme('LEECHERS',
Leechers=download.leechers_num())
msg += BotTheme('LEECHERS', Leechers=download.leechers_num())
except:
pass
elif download.status() == MirrorStatus.STATUS_SEEDING:
Expand All @@ -237,8 +234,7 @@ def get_readable_message():
msg += BotTheme('USER',
User=download.message.from_user.mention(style="html"))
msg += BotTheme('ID', Id=download.message.from_user.id)
msg += BotTheme('CANCEL',
Cancel=f"/{BotCommands.CancelMirror}_{download.gid()}")
msg += BotTheme('CANCEL', Cancel=f"/{BotCommands.CancelMirror}_{download.gid()}")

if len(msg) == 0:
return None, None
Expand All @@ -264,6 +260,7 @@ def convert_speed_to_bytes_per_second(spd):
elif tstatus == MirrorStatus.STATUS_UPLOADING or tstatus == MirrorStatus.STATUS_SEEDING:
up_speed += speed_in_bytes_per_second

msg += BotTheme('FOOTER')
if tasks > STATUS_LIMIT:
msg += BotTheme('PAGE', Page=f"{PAGE_NO}/{PAGES}")
msg += BotTheme('TASKS', Tasks=tasks)
Expand All @@ -272,10 +269,8 @@ def convert_speed_to_bytes_per_second(spd):
buttons.ibutton(BotTheme('REFRESH'), "status ref")
buttons.ibutton(BotTheme('NEXT'), "status nex")
button = buttons.build_menu(3)
msg += BotTheme('FOOTER')
msg += BotTheme('Cpu', cpu=cpu_percent())
msg += BotTheme('FREE', free=get_readable_file_size(
disk_usage(config_dict['DOWNLOAD_DIR']).free))
msg += BotTheme('FREE', free=get_readable_file_size(disk_usage(config_dict['DOWNLOAD_DIR']).free))
msg += BotTheme('Ram', ram=virtual_memory().percent)
msg += BotTheme('uptime', uptime=get_readable_time(time() - botStartTime))
msg += BotTheme('DL', DL=get_readable_file_size(dl_speed))
Expand Down
54 changes: 35 additions & 19 deletions bot/helper/ext_utils/leech_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,29 @@ async def split_file(path, size, file_, dirpath, split_size, listener, start_tim
LOGGER.error(err)
return True

async def format_filename(file_, lprefix, lsuffix, lremname, lcaption, dirpath):
async def format_filename(file_, user_id, dirpath=None, isMirror=False):
user_dict = user_data.get(user_id, {})
ftag, ctag = ('m', 'MIRROR') if isMirror else ('l', 'LEECH')
prefix = config_dict[f'{ctag}_FILENAME_PREFIX'] if (val:=user_dict.get(f'{ftag}prefix', '')) == '' else val
remname = config_dict[f'{ctag}_FILENAME_REMNAME'] if (val:=user_dict.get(f'{ftag}remname', '')) == '' else val
suffix = config_dict[f'{ctag}_FILENAME_SUFFIX'] if (val:=user_dict.get(f'{ftag}suffix', '')) == '' else val
lcaption = val if user_dict.get('lcaption') else ''

prefile_ = file_
# SD-Style V2 ~ WZML-X
if lremname:
if not lremname.startswith('|'):
lremname = f"|{lremname}"
lremname = lremname.replace('\s', ' ')
slit = lremname.split("|")
if file_.startswith('www'): #Remove all www.xyz.xyz domains
file_ = ' '.join(file_.split()[1:])

if remname:
if not remname.startswith('|'):
remname = f"|{remname}"
remname = remname.replace('\s', ' ')
slit = remname.split("|")
__newFileName = ospath.splitext(file_)[0]
for rep in range(1, len(slit)):
args = slit[rep].split(":")
if len(args) == 3:
__newFileName = re_sub(
args[0], args[1], __newFileName, int(args[2]))
__newFileName = re_sub(args[0], args[1], __newFileName, int(args[2]))
elif len(args) == 2:
__newFileName = re_sub(args[0], args[1], __newFileName)
elif len(args) == 1:
Expand All @@ -211,29 +220,33 @@ async def format_filename(file_, lprefix, lsuffix, lremname, lcaption, dirpath):
LOGGER.info(f"New Filename : {file_}")

nfile_ = file_
if lprefix:
nfile_ = lprefix.replace('\s', ' ') + file_
lprefix = re_sub('<.*?>', '', lprefix).replace('\s', ' ')
if not file_.startswith(lprefix):
file_ = f"{lprefix}{file_}"
if prefix:
nfile_ = prefix.replace('\s', ' ') + file_
prefix = re_sub('<.*?>', '', prefix).replace('\s', ' ')
if not file_.startswith(prefix):
file_ = f"{prefix}{file_}"

if lsuffix:
lsuffix = lsuffix.replace('\s', ' ')
sufLen = len(lsuffix)
if suffix and not isMirror:
suffix = suffix.replace('\s', ' ')
sufLen = len(suffix)
fileDict = file_.split('.')
_extIn = 1 + len(fileDict[-1])
_extOutName = '.'.join(
fileDict[:-1]).replace('.', ' ').replace('-', ' ')
_newExtFileName = f"{_extOutName}{lsuffix}.{fileDict[-1]}"
_newExtFileName = f"{_extOutName}{suffix}.{fileDict[-1]}"
if len(_extOutName) > (64 - (sufLen + _extIn)):
_newExtFileName = (
_extOutName[: 64 - (sufLen + _extIn)]
+ f"{lsuffix}.{fileDict[-1]}"
+ f"{suffix}.{fileDict[-1]}"
)
file_ = _newExtFileName
elif suffix:
suffix = suffix.replace('\s', ' ')
file_ = f"{ospath.splitext(file_)[0]}{suffix}{ospath.splitext(file_)[1]}" if '.' in file_ else f"{file_}{suffix}"


cap_mono = f"<{config_dict['CAP_FONT']}>{nfile_}</{config_dict['CAP_FONT']}>" if config_dict['CAP_FONT'] else nfile_
if lcaption:
if lcaption and not isMirror:
lcaption = lcaption.replace('\|', '%%').replace('\s', ' ')
slit = lcaption.split("|")
up_path = ospath.join(dirpath, prefile_)
Expand All @@ -252,6 +265,9 @@ async def format_filename(file_, lprefix, lsuffix, lremname, lcaption, dirpath):
elif len(args) == 1:
cap_mono = cap_mono.replace(args[0], '')
cap_mono = cap_mono.replace('%%', '|')

if isMirror:
return file_
return cap_mono, file_


Expand Down
2 changes: 2 additions & 0 deletions bot/helper/ext_utils/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ async def start_from_queued():
async def limit_checker(size, listener, isTorrent=False, isMega=False, isDriveLink=False, isYtdlp=False):
LOGGER.info('Checking Size Limit of file/folder...')
user_id = listener.message.from_user.id
if user_id == OWNER_ID or user_id in user_data and user_data[user_id].get('is_sudo'):
return
limit_exceeded = ''
if listener.isClone:
if CLONE_LIMIT := config_dict['CLONE_LIMIT']:
Expand Down
Loading

0 comments on commit 01f7581

Please sign in to comment.