Ejemplo n.º 1
0
import PIL.ImageOps
from PIL import Image, ImageDraw, ImageFont
import requests
from bs4 import BeautifulSoup as bs
from pymediainfo import MediaInfo
from telethon.tl.types import MessageMediaPhoto
from validators.url import url

BASE_URL = "https://isubtitles.org"
from userbot.thunderconfig import Config

sedpath = Config.TMP_DOWNLOAD_DIRECTORY
from userbot import logging

logger = logging.getLogger("[--WARNING--]")
if not os.path.isdir(sedpath):
    os.makedirs(sedpath)


# Thanks To Userge-X
async def runcmd(cmd: str) -> Tuple[str, str, int, int]:
    """ run command in terminal """
    args = shlex.split(cmd)
    process = await asyncio.create_subprocess_exec(
        *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
    stdout, stderr = await process.communicate()
    return (
        stdout.decode("utf-8", "replace").strip(),
        stderr.decode("utf-8", "replace").strip(),
        process.returncode,
Ejemplo n.º 2
0
import os
import shlex
import asyncio
from glob import glob
from os.path import isfile, relpath, basename
from typing import Tuple, Dict, List, Union, Optional

from userbot import logging, Config

_LOG = logging.getLogger(__name__)


def humanbytes(size: float) -> str:
    """humanize size"""
    if not size:
        return ""
    power = 1024
    t_n = 0
    power_dict = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'}
    while size > power:
        size /= power
        t_n += 1
    return "{:.2f} {}B".format(size, power_dict[t_n])


def time_formatter(seconds: float) -> str:
    """humanize time"""
    minutes, seconds = divmod(int(seconds), 60)
    hours, minutes = divmod(minutes, 60)
    days, hours = divmod(hours, 24)
    tmp = ((str(days) + "d, ") if days else "") + \
Ejemplo n.º 3
0
 def getLogger(name: str) -> logging.Logger:
     """ This returns new logger object """
     _LOG.debug(_LOG_STR, f"Creating Logger => {name}")
     return logging.getLogger(name)