Co-authored-by: Danish <danish@ultroid.tech> Co-authored-by: Aditya <me@xditya.me> Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com> Co-authored-by: sppidy <sppidy@users.noreply.github.com> Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com> Co-authored-by: divkix <divkix@users.noreply.github.com> Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com> Co-authored-by: Programming Error <error@notavailable.live>
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
# Ultroid - UserBot
|
|
# Copyright (C) 2021 TeamUltroid
|
|
#
|
|
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
|
# PLease read the GNU Affero General Public License in
|
|
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
|
"""
|
|
✘ Commands Available -
|
|
|
|
•`{i}megadl <link>`
|
|
It Downloads and Upload Files from mega.nz links.
|
|
"""
|
|
import time
|
|
from datetime import datetime
|
|
|
|
from . import *
|
|
|
|
|
|
@ultroid_cmd(pattern="megadl ?(.*)")
|
|
async def _(e):
|
|
link = e.pattern_match.group(1)
|
|
if os.path.isdir("mega"):
|
|
await bash("rm -rf mega")
|
|
os.mkdir("mega")
|
|
xx = await eor(e, f"Processing...\nTo Check Progress : `{HNDLR}ls mega`")
|
|
s = datetime.now()
|
|
x, y = await bash(f"megadl {link} --path mega")
|
|
ok = get_all_files("mega")
|
|
tt = time.time()
|
|
c = 0
|
|
for kk in ok:
|
|
try:
|
|
res = await uploader(kk, kk, tt, xx, "Uploading...")
|
|
await e.client.send_file(
|
|
e.chat_id,
|
|
res,
|
|
caption="`" + kk.split("/")[-1] + "`",
|
|
force_document=True,
|
|
thumb="resources/extras/ultroid.jpg",
|
|
)
|
|
c += 1
|
|
except Exception as er:
|
|
LOGS.info(er)
|
|
ee = datetime.now()
|
|
t = time_formatter(((ee - s).seconds) * 1000)
|
|
size = 0
|
|
for path, dirs, files in os.walk("mega"):
|
|
for f in files:
|
|
fp = os.path.join(path, f)
|
|
size += os.path.getsize(fp)
|
|
await xx.delete()
|
|
await e.client.send_message(
|
|
e.chat_id,
|
|
f"Downloaded And Uploaded Total - `{c}` files of `{humanbytes(size)}` in `{t}`",
|
|
)
|
|
await bash("rm -rf mega")
|