| import random |
| import urllib3 |
| import logging |
| import asyncio |
| import traceback |
| import mimetypes |
| import time, math |
| from datetime import datetime |
| from typing import Dict, Union |
| from typing import Union, BinaryIO, List, Optional, Callable |
|
|
| from pyrogram import raw |
| from pyrogram import types |
| from pyrogram import filters, Client |
| from pyrogram import utils as pgutils |
| from pyrogram import StopTransmission, enums |
| from pyrogram import Client, utils, raw |
|
|
| from pyrogram.file_id import FileType |
| from pyrogram.session import Session, Auth |
| from pyrogram.errors import FilePartMissing,AuthBytesInvalid,FloodWait |
| from pyrogram.file_id import FileId, FileType, ThumbnailSource |
| from pyrogram.enums import ParseMode, ChatType |
| from pyrogram.enums.parse_mode import ParseMode |
| from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton |
|
|
|
|
| |
|
|
| from FileStream.bot import FileStream |
| from FileStream.bot import MULTI_CLIENTS, WORK_LOADS |
| from FileStream.Database import Database |
| from FileStream.config import Telegram, Server |
| from FileStream.Tools.tool import TimeFormatter |
|
|
| from FileStream.utils.FileProcessors.bot_utils import is_user_banned, is_user_exist, is_user_joined, gen_link, is_channel_banned, is_channel_exist, is_user_authorized, upload_type_func |
| from FileStream.utils.FileProcessors.custom_dl import ByteStreamer |
| from FileStream.utils.FileProcessors.custom_ul import TeleUploader |
| from FileStream.utils.FileProcessors.custom_mix import TGFileController |
| from FileStream.utils.FileProcessors.translation import LANG, BUTTON |
| from FileStream.utils.FileProcessors.human_readable import humanbytes |
| from FileStream.utils.FileProcessors.file_properties import get_file_ids,get_file_info |
|
|
|
|
| async def progress(current, total, progress_args): |
| progress_text = LANG.BASIC_PRIV_FILE.format( |
| progress_args[1], humanbytes(progress_args[2])) |
| |
| now = time.time() |
| diff = now - progress_args[3] |
| if round(diff % 10.00) == 0 or current == total: |
| percentage = current * 100 / total |
| speed = current / diff |
| elapsed_time = round(diff) * 1000 |
| time_to_completion = round((total - current) / speed) * 1000 |
| estimated_total_time = elapsed_time + time_to_completion |
|
|
| elapsed_time = TimeFormatter(milliseconds=elapsed_time) |
| estimated_total_time = TimeFormatter( |
| milliseconds=estimated_total_time) |
|
|
| progress = "{0}{1}".format( |
| ''.join(["●" for i in range(math.floor(percentage / 5))]), |
| ''.join(["○" for i in range(20 - math.floor(percentage / 5)) |
| ]) |
| ) |
| tmp = progress_text + '\n' + progress + LANG.PROGRESS_BAR.format( |
| percentage=round(percentage, 2), |
| current=humanbytes(current), |
| total=humanbytes(total), |
| speed=humanbytes(speed), |
| est_time=estimated_total_time |
| if estimated_total_time != '' else "0 s") |
| try: |
| await progress_args[0].edit_text( |
| text=tmp, |
| parse_mode=ParseMode.HTML, |
| disable_web_page_preview=True, |
| ) |
|
|
| except FloodWait as w: |
| print(f"Sleeping for {str(w.wait_time)}s") |
| await asyncio.sleep(w.wait_time) |
| except Exception as e: |
| print(e) |