File size: 2,346 Bytes
db78256 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# ruff: noqa: E402
from uvloop import install
install()
from subprocess import run as srun
from os import getcwd
from asyncio import Lock, new_event_loop, set_event_loop
from logging import (
ERROR,
INFO,
WARNING,
FileHandler,
StreamHandler,
basicConfig,
getLogger,
)
from os import cpu_count
from time import time
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from .core.config_manager import BinConfig
from sabnzbdapi import SabnzbdClient
getLogger("requests").setLevel(WARNING)
getLogger("urllib3").setLevel(WARNING)
getLogger("pyrogram").setLevel(ERROR)
getLogger("aiohttp").setLevel(ERROR)
getLogger("apscheduler").setLevel(ERROR)
getLogger("httpx").setLevel(WARNING)
getLogger("pymongo").setLevel(WARNING)
getLogger("aiohttp").setLevel(WARNING)
bot_start_time = time()
bot_loop = new_event_loop()
set_event_loop(bot_loop)
basicConfig(
format="[%(asctime)s] [%(levelname)s] - %(message)s", # [%(filename)s:%(lineno)d]
datefmt="%d-%b-%y %I:%M:%S %p",
handlers=[FileHandler("log.txt"), StreamHandler()],
level=INFO,
)
LOGGER = getLogger(__name__)
cpu_no = cpu_count()
threads = max(1, cpu_no // 2)
cores = ",".join(str(i) for i in range(threads))
bot_cache = {}
DOWNLOAD_DIR = "/usr/src/app/downloads/"
intervals = {"status": {}, "qb": "", "jd": "", "nzb": "", "stopAll": False}
qb_torrents = {}
jd_downloads = {}
nzb_jobs = {}
user_data = {}
aria2_options = {}
qbit_options = {}
nzb_options = {}
queued_dl = {}
queued_up = {}
status_dict = {}
task_dict = {}
rss_dict = {}
shortener_dict = {}
var_list = [
"BOT_TOKEN",
"TELEGRAM_API",
"TELEGRAM_HASH",
"OWNER_ID",
"DATABASE_URL",
"BASE_URL",
"UPSTREAM_REPO",
"UPSTREAM_BRANCH",
"UPDATE_PKGS",
]
auth_chats = {}
excluded_extensions = ["aria2", "!qB"]
drives_names = []
drives_ids = []
index_urls = []
sudo_users = []
non_queued_dl = set()
non_queued_up = set()
multi_tags = set()
task_dict_lock = Lock()
queue_dict_lock = Lock()
qb_listener_lock = Lock()
nzb_listener_lock = Lock()
jd_listener_lock = Lock()
cpu_eater_lock = Lock()
same_directory_lock = Lock()
sabnzbd_client = SabnzbdClient(
host="http://localhost",
api_key="admin",
port="8070",
)
srun([BinConfig.QBIT_NAME, "-d", f"--profile={getcwd()}"], check=False)
scheduler = AsyncIOScheduler(event_loop=bot_loop)
|