def update_all_messages():
    msg = get_readable_message()
    msg += f"<b>🖥️ CPU:</b> {psutil.cpu_percent()}%\n" \
           f"<b>🚀 RAM:</b> {psutil.virtual_memory().percent}%\n" \
           f"<b>📦 DISK:</b> {psutil.disk_usage('/').percent}%\n"
    with download_dict_lock:
        dlspeed_bytes = 0
        uldl_bytes = 0
        for download in list(download_dict.values()):
            speedy = download.speed()
            if download.status() == MirrorStatus.STATUS_DOWNLOADING:
                if 'KiB/s' in speedy:
                    dlspeed_bytes += float(speedy.split('K')[0]) * 1024
                elif 'MiB/s' in speedy:
                    dlspeed_bytes += float(speedy.split('M')[0]) * 1048576
            if download.status() == MirrorStatus.STATUS_UPLOADING:
                if 'KB/s' in speedy:
                    uldl_bytes += float(speedy.split('K')[0]) * 1024
                elif 'MB/s' in speedy:
                    uldl_bytes += float(speedy.split('M')[0]) * 1048576
        dlspeed = get_readable_file_size(dlspeed_bytes)
        ulspeed = get_readable_file_size(uldl_bytes)
        msg += f"\n<b>DL:</b>{dlspeed}ps 🔻| <b>UL:</b>{ulspeed}ps 🔺\n"
    with status_reply_dict_lock:
        for chat_id in list(status_reply_dict.keys()):
            if status_reply_dict[
                    chat_id] and msg != status_reply_dict[chat_id].text:
                if len(msg) == 0:
                    msg = "Starting DL"
                try:
                    editMessage(msg, status_reply_dict[chat_id])
                except Exception as e:
                    LOGGER.error(str(e))
                status_reply_dict[chat_id].text = msg
def sendStatusMessage(msg, bot):
    progress = get_readable_message()
    progress += f"<b>🖥 CPU:</b> {psutil.cpu_percent()}%\n" \
           f"<b>🚀 RAM:</b> {psutil.virtual_memory().percent}%\n" \
           f"<b>📦 DISK:</b> {psutil.disk_usage('/').percent}%\n"
    with download_dict_lock:
        dlspeed_bytes = 0
        uldl_bytes = 0
        for download in list(download_dict.values()):
            speedy = download.speed()
            if download.status() == MirrorStatus.STATUS_DOWNLOADING:
                if 'KiB/s' in speedy:
                    dlspeed_bytes += float(speedy.split('K')[0]) * 1024
                elif 'MiB/s' in speedy:
                    dlspeed_bytes += float(speedy.split('M')[0]) * 1048576
            if download.status() == MirrorStatus.STATUS_UPLOADING:
                if 'KB/s' in speedy:
                    uldl_bytes += float(speedy.split('K')[0]) * 1024
                elif 'MB/s' in speedy:
                    uldl_bytes += float(speedy.split('M')[0]) * 1048576
        dlspeed = get_readable_file_size(dlspeed_bytes)
        ulspeed = get_readable_file_size(uldl_bytes)
        progress += f"\n<b>DL:</b>{dlspeed}ps 🔻| <b>UL:</b>{ulspeed}ps 🔺\n"
    with status_reply_dict_lock:
        if msg.message.chat.id in list(status_reply_dict.keys()):
            try:
                message = status_reply_dict[msg.message.chat.id]
                deleteMessage(bot, message)
                del status_reply_dict[msg.message.chat.id]
            except Exception as e:
                LOGGER.error(str(e))
                del status_reply_dict[msg.message.chat.id]
        message = sendMessage(progress, bot, msg)
        status_reply_dict[msg.message.chat.id] = message
Exemplo n.º 3
0
def get_readable_message():
    with download_dict_lock:
        msg = "✥════ @𝐏𝐫𝐢𝐢𝐢𝐢𝐲𝐨𝐁𝐎𝐓𝐬 ════✥"
        for download in list(download_dict.values()):
            msg += f"<b>\n\n🗂 𝗙𝗶𝗹𝗲𝗡𝗮𝗺𝗲 : </b> <code>{download.name()}</code>"
            msg += f"\n<b>🚦 𝐒𝐭𝐚𝐭𝐮𝐬 : </b> <i>{download.status()}</i>"
            if download.status(
            ) != MirrorStatus.STATUS_ARCHIVING and download.status(
            ) != MirrorStatus.STATUS_EXTRACTING:
                msg += f"\n<code>{get_progress_bar_string(download)} {download.progress()}</code>"
                if download.status() == MirrorStatus.STATUS_DOWNLOADING:
                    msg += f"\n<b>📥 𝐃𝐨𝐰𝐧𝐥𝐨𝐚𝐝𝐞𝐝 : </b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
                else:
                    msg += f"\n<b>📤 𝐔𝐩𝐥𝐨𝐚𝐝𝐞𝐝 : </b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
                msg += f"\n<b>🚀 𝐒𝐩𝐞𝐞𝐝 : </b> {download.speed()}, \n<b>⏳ 𝐄𝐓𝐀 : </b> {download.eta()} "
                # if hasattr(download, 'is_torrent'):
                try:
                    msg += f"\n<b>⚓️ 𝐈𝐧𝐟𝐨 : -Seeders:</b> {download.aria_download().num_seeders}" \
                        f" | <b>🔄 𝐏𝐞𝐞𝐫𝐬 : </b> {download.aria_download().connections}"
                except:
                    pass
            if download.status() == MirrorStatus.STATUS_DOWNLOADING:
                msg += f"\n<b>🚫 𝐓𝐨 𝐒𝐭𝐨𝐩 : </b> <code>/{BotCommands.CancelMirror} {download.gid()}</code>"
            msg += "\n\n"
        return msg
Exemplo n.º 4
0
def getDownloadByGid(gid):
    with download_dict_lock:
        for dl in download_dict.values():
            status = dl.status()
            if status != MirrorStatus.STATUS_UPLOADING and status != MirrorStatus.STATUS_ARCHIVING \
                    and status != MirrorStatus.STATUS_EXTRACTING:
                if dl.gid() == gid:
                    return dl
    return None
Exemplo n.º 5
0
def cancel_all(update, context):
    with download_dict_lock:
        count = 0
        for dlDetails in list(download_dict.values()):
            if dlDetails.status() == MirrorStatus.STATUS_DOWNLOADING \
                    or dlDetails.status() == MirrorStatus.STATUS_WAITING:
                dlDetails.download().cancel_download()
                count += 1
    delete_all_messages()
    sendMessage(f'Cancelled {count} downloads!', context.bot, update)
Exemplo n.º 6
0
def update_all_messages():
    total, used, free = shutil.disk_usage('.')
    used = get_readable_file_size(used)
    free = get_readable_file_size(free)
    msg = get_readable_message()
    msg += f"<b>🖥️ CPU:</b> {psutil.cpu_percent()}%" \
           f"<b>🚀 RAM:</b> {psutil.virtual_memory().percent}%" \
           f"<b>📦 DISK:</b> {psutil.disk_usage('/').percent}%"
    with download_dict_lock:
        dlspeed_bytes = 0
        uldl_bytes = 0
        for download in list(download_dict.values()):
            speedy = download.speed()
            if download.status() == MirrorStatus.STATUS_DOWNLOADING:
                if 'KiB/s' in speedy:
                    dlspeed_bytes += float(speedy.split('K')[0]) * 1024
                elif 'MiB/s' in speedy:
                    dlspeed_bytes += float(speedy.split('M')[0]) * 1048576
            if download.status() == MirrorStatus.STATUS_UPLOADING:
                if 'KB/s' in speedy:
                    uldl_bytes += float(speedy.split('K')[0]) * 1024
                elif 'MB/s' in speedy:
                    uldl_bytes += float(speedy.split('M')[0]) * 1048576
        dlspeed = get_readable_file_size(dlspeed_bytes)
        ulspeed = get_readable_file_size(uldl_bytes)
        msg += f"\n<b>USED:</b> {used} | <b>FREE:</b> {free}\n<b>DL:</b> {dlspeed}ps 🔻 | <b>UL:</b> {ulspeed}ps 🔺\n"
    with status_reply_dict_lock:
        for chat_id in list(status_reply_dict.keys()):
            if status_reply_dict[
                    chat_id] and msg != status_reply_dict[chat_id].text:
                if len(msg) == 0:
                    msg = "Starting DL"
                try:
                    keyboard = [[
                        InlineKeyboardButton("🔄 REFRESH 🔄",
                                             callback_data=str(ONE)),
                        InlineKeyboardButton("❌ CLOSE ❌",
                                             callback_data=str(TWO)),
                    ]]
                    editMessage(msg,
                                status_reply_dict[chat_id],
                                reply_markup=InlineKeyboardMarkup(keyboard))
                except Exception as e:
                    LOGGER.error(str(e))
                status_reply_dict[chat_id].text = msg
Exemplo n.º 7
0
def get_readable_message():
    with download_dict_lock:
        msg = "<b>ⓂⓍⓉ Ⓜⓘⓡⓡⓞⓡ ⓏⓄⓃⒺ</b>" 
        for download in list(download_dict.values()):
            msg += f"<b>𝓯𝓲𝓵𝓮𝓷𝓪𝓶𝓮:</b> <code>{download.name()}</code>"
            msg += f"\n<b>𝓢𝓽𝓪𝓽𝓾𝓼:</b> <i>{download.status()}</i>"
            if download.status() != MirrorStatus.STATUS_ARCHIVING and download.status() != MirrorStatus.STATUS_EXTRACTING:
                msg += f"\n<code>{get_progress_bar_string(download)} {download.progress()}</code>"
                if download.status() == MirrorStatus.STATUS_DOWNLOADING:
                    msg += f"\n<b>𝓓𝓸𝔀𝓷𝓵𝓸𝓪𝓭𝓮𝓭:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
                else:
                    msg += f"\n<b>𝓤𝓹𝓵𝓸𝓪𝓭𝓮𝓭:</b> {get_readable_file_size(download.processed_bytes())} of {download.size()}"
                msg += f"\n<b>𝓼𝓹𝓮𝓮𝓭:</b> {download.speed()}, \n<b>ETA:</b> {download.eta()} "
                # if hasattr(download, 'is_torrent'):
                try:
                    msg += f"\n<b>𝓲𝓷𝓯𝓸- 𝓼𝓮𝓮𝓭𝓮𝓻𝓼:</b> {download.aria_download().num_seeders}" \
                        f" | <b>𝓹𝓮𝓮𝓻𝓼:</b> {download.aria_download().connections}"
                except:
                    pass
            if download.status() == MirrorStatus.STATUS_DOWNLOADING:
                msg += f"\n<b>𝓣𝓸 𝓢𝓽𝓸𝓹:</b> <code>/{BotCommands.CancelMirror} {download.gid()}</code>"
            msg += "\n\n"
        return msg