Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yamraaj #8

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
28 changes: 16 additions & 12 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,26 @@ def stats(update, context):
cpuUsage = psutil.cpu_percent(interval=0.5)
memory = psutil.virtual_memory().percent
disk = psutil.disk_usage('/').percent
stats = f'<b>Bot Uptime:</b> <code>{currentTime}</code>\n' \
f'<b>Total Disk Space:</b> <code>{total}</code>\n' \
f'<b>Used:</b> <code>{used}</code> ' \
f'<b>Free:</b> <code>{free}</code>\n\n' \
f'<b>Upload:</b> <code>{sent}</code>\n' \
f'<b>Download:</b> <code>{recv}</code>\n\n' \
f'<b>CPU:</b> <code>{cpuUsage}%</code> ' \
f'<b>RAM:</b> <code>{memory}%</code> ' \
f'<b>DISK:</b> <code>{disk}%</code>'
stats = f'<b>╭───「 ⭕️ BOT STATS ⭕️ 」 </b>\n' \
f'<b>│</b>\n' \
f'<b>├ ⏰ Bot Uptime:</b> <code>{currentTime}</code>\n' \
f'<b>├ 🗄 Total Disk Space:</b> <code>{total}</code>\n' \
f'<b>├ 🗂 Used:</b> <code>{used}</code> ' \
f'<b>├ 📂 Free:</b> <code>{free}</code>\n\n' \
f'<b>├ 📤 Upload:</b> <code>{sent}</code>\n' \
f'<b>├ 📥 Download:</b> <code>{recv}</code>\n\n' \
f'<b>├ 🖥️ CPU:</b> <code>{cpuUsage}%</code> ' \
f'<b>├ 🚀 RAM:</b> <code>{memory}%</code> ' \
f'<b>├ 🗄 DISK:</b> <code>{disk}%</code>' \
f'<b>│</b>\n' \
f'<b>╰──「 🚸 @𝐘𝐚𝐦𝐫𝐚𝐚𝐣𝟎𝟎𝟕 🚸 」</b>'
sendMessage(stats, context.bot, update)


def start(update, context):
buttons = button_build.ButtonMaker()
buttons.buildbutton("Repo", "https://www.github.com/anasty17/mirror-leech-telegram-bot")
buttons.buildbutton("Channel", "https://t.me/mirrorLeechTelegramBot")
buttons.buildbutton("Repo", "https://www.github.com/crazy-racer/mirror-leech-telegram-bot")
buttons.buildbutton("Channel", "https://t.me/Mirrorclouds")
reply_markup = InlineKeyboardMarkup(buttons.build_menu(2))
if CustomFilters.authorized_user(update) or CustomFilters.authorized_chat(update):
start_string = f'''
Expand Down Expand Up @@ -159,7 +163,7 @@ def log(update, context):
help = Telegraph(access_token=telegraph_token).create_page(
title='Mirrorbot Help',
author_name='Mirrorbot',
author_url='https://github.com/anasty17/mirror-leech-telegram-bot',
author_url='https://github.com/crazy-racer/mirror-leech-telegram-bot',
html_content=help_string_telegraph,
)["path"]

Expand Down
47 changes: 24 additions & 23 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@


class MirrorStatus:
STATUS_UPLOADING = "Uploading...📤"
STATUS_DOWNLOADING = "Downloading...📥"
STATUS_CLONING = "Cloning...♻️"
STATUS_WAITING = "Queued...📝"
STATUS_FAILED = "Failed 🚫. Cleaning Download..."
STATUS_PAUSE = "Paused...⭕️"
STATUS_ARCHIVING = "Archiving...🔐"
STATUS_EXTRACTING = "Extracting...📂"
STATUS_SPLITTING = "Splitting...✂️"
STATUS_UPLOADING = "𝗨𝗽𝗹𝗼𝗮𝗱𝗶𝗻𝗚...📤"
STATUS_DOWNLOADING = "𝗗𝗼𝘄𝗻𝗹𝗼𝗮𝗱𝗶𝗻𝗚...📥"
STATUS_CLONING = "𝘾𝙡𝙤𝙣𝙞𝙣𝙜...♻️"
STATUS_WAITING = "𝗤𝘂𝗲𝘂𝗲𝗱...📝"
STATUS_FAILED = "𝗙𝗮𝗶𝗹𝗲𝗱 🚫! 𝗖𝗹𝗲𝗮𝗻𝗶𝗻𝗴 𝗱𝗼𝘄𝗻𝗹𝗼𝗮𝗱..."
STATUS_PAUSE = "𝙋𝙖𝙪𝙨𝙚𝙙...⭕️"
STATUS_ARCHIVING = "𝘼𝙧𝙘𝙝𝙞𝙫𝙞𝙣𝙜...🔐"
STATUS_EXTRACTING = "𝙀𝙭𝙩𝙧𝙖𝙘𝙩𝙞𝙣𝙜...📂"
STATUS_SPLITTING = "𝙎𝙥𝙡𝙞𝙩𝙩𝙞𝙣𝙜...✂️"

SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']

Expand Down Expand Up @@ -103,14 +103,14 @@ def get_progress_bar_string(status):
p = 0 if total == 0 else round(completed * 100 / total)
p = min(max(p, 0), 100)
cFull = p // 8
p_str = '' * cFull
p_str += '' * (12 - cFull)
p_str = '' * cFull
p_str += '' * (12 - cFull)
p_str = f"[{p_str}]"
return p_str

def get_readable_message():
with download_dict_lock:
msg = ""
msg = "✥═══ @𝐘𝐚𝐦𝐫𝐚𝐚𝐣𝟎𝟎𝟕 ═══✥"
start = 0
if STATUS_LIMIT is not None:
dick_no = len(download_dict)
Expand All @@ -121,33 +121,34 @@ def get_readable_message():
globals()['PAGE_NO'] -= 1
start = COUNT
for index, download in enumerate(list(download_dict.values())[start:], start=1):
msg += f"<b>Name:</b> <code>{download.name()}</code>"
msg += f"\n<b>Status:</b> <i>{download.status()}</i>"
msg += f"<b>🗂𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲:</b> <code>{download.name()}</code>"
msg += f"\n<b>𝐒𝐭𝐚𝐭𝐮𝐬:</b> <i>{download.status()}</i>"
if download.status() not in [
MirrorStatus.STATUS_ARCHIVING,
MirrorStatus.STATUS_EXTRACTING,
MirrorStatus.STATUS_SPLITTING,
]:
msg += f"\n{get_progress_bar_string(download)} {download.progress()}"
if download.status() == MirrorStatus.STATUS_CLONING:
msg += f"\n<b>Cloned:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
msg += f"\n<b>♻️ 𝐂𝐥𝐨𝐧𝐞𝐝 :</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
elif download.status() == MirrorStatus.STATUS_UPLOADING:
msg += f"\n<b>Uploaded:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
msg += f"\n<b>📤 𝐔𝐩𝐥𝐨𝐚𝐝𝐞𝐝 :</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
else:
msg += f"\n<b>Downloaded:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
msg += f"\n<b>Speed:</b> {download.speed()}"
msg += f"\n<b>📥 𝐃𝐨𝐰𝐧𝐥𝐨𝐚𝐝𝐞𝐝 :</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
msg += f"\n<b>⚡𝐒𝐩𝐞𝐞𝐝 :</b> {download.speed()}"
msg += f"\n<b>ETA:</b> {download.eta()}"
try:
msg += f"\n<b>Seeders:</b> {download.aria_download().num_seeders}" \
f" | <b>Peers:</b> {download.aria_download().connections}"
msg += f"\n<b>⚓️𝐒𝐞𝐞𝐝𝐞𝐫𝐬 :</b> {download.aria_download().num_seeders}" \
f" | <b>🔄 𝐏𝐞𝐞𝐫𝐬 :</b> {download.aria_download().connections}"
except:
pass
try:
msg += f"\n<b>Seeders:</b> {download.torrent_info().num_seeds}" \
f" | <b>Leechers:</b> {download.torrent_info().num_leechs}"
msg += f"\n<b>⚓️ 𝐒𝐞𝐞𝐝𝐞𝐫𝐬 :</b> {download.torrent_info().num_seeds}" \
f" | <b>🔄 𝐋𝐞𝐞𝐜𝐡𝐞𝐫𝐬 :</b> {download.torrent_info().num_leechs}"
except:
pass
msg += f"\n<code>/{BotCommands.CancelMirror} {download.gid()}</code>"
msg += f'\n<b>👨‍🦱 𝐔𝐬𝐞𝐫 :</b> <a href="tg://user?id={download.message.from_user.id}">{download.message.from_user.first_name}</a> (<code>{download.message.from_user.id}</code>)'
msg += f"\n<b>🚫 𝐓𝐨 𝐒𝐭𝐨𝐩 :</b> <code>/{BotCommands.CancelMirror} {download.gid()}</code>"
msg += "\n___________________________\n"
if STATUS_LIMIT is not None and index == STATUS_LIMIT:
break
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .download_helper import DownloadHelper
import time
from youtube_dl import YoutubeDL, DownloadError
from yt_dlp import YoutubeDL, DownloadError
from bot import download_dict_lock, download_dict
from ..status_utils.youtube_dl_download_status import YoutubeDLDownloadStatus
import logging
Expand All @@ -17,9 +17,9 @@ def __init__(self, obj):
def debug(self, msg):
LOGGER.debug(msg)
# Hack to fix changing changing extension
match = re.search(r'.ffmpeg..Merging formats into..(.*?).$', msg)
match = re.search(r'.Merger..Merging formats into..(.*?).$', msg)
if match and not self.obj.is_playlist:
newname = match.group(1)
newname = match[1]
newname = newname.split("/")
newname = newname[-1]
self.obj.name = newname
Expand Down Expand Up @@ -159,10 +159,12 @@ def add_download(self, link, path, qual, name):
self.opts['postprocessors'] = [{'key': 'FFmpegExtractAudio','preferredcodec': 'mp3','preferredquality': '320',}]
else:
self.opts['format'] = qual
if not self.is_playlist:
self.opts['outtmpl'] = f"{path}/{self.name}"
else:
self.opts['outtmpl'] = f"{path}/{self.name}/%(title)s.%(ext)s"
self.opts['outtmpl'] = (
f"{path}/{self.name}/%(title)s.%(ext)s"
if self.is_playlist
else f"{path}/{self.name}"
)

self.__download(link)

def cancel_download(self):
Expand Down
Loading