Update bot.py

This commit is contained in:
DerrtSML 2025-06-23 17:29:50 +03:00 committed by GitHub
parent edfbe9f81b
commit 309297cc34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

15
bot.py
View File

@ -44,8 +44,19 @@ def init_qbittorrent_client():
logger.error("QBittorrent credentials are not fully set in environment variables.") logger.error("QBittorrent credentials are not fully set in environment variables.")
return False return False
try: try:
qb = Client(f"http://{QBT_HOST}:{QBT_PORT}/") # --- ИЗМЕНИТЕ ЭТИ СТРОКИ ---
qb.login(QBT_USERNAME, QBT_PASSWORD) # Передайте учетные данные прямо в конструктор Client
# Используйте 'host' вместо 'f"http://{QBT_HOST}:{QBT_PORT}/"'
# qbittorrentapi ожидает хост без 'http://' и без порта
qb = Client(
host=f"{QBT_HOST}:{QBT_PORT}", # Хост и порт вместе
username=QBT_USERNAME,
password=QBT_PASSWORD
)
# Проверим подключение, вызвав что-нибудь простое, например, api_version
# Это также выполняет аутентификацию
qb.app.api_version # Просто обращение к любому атрибуту qbittorrentapi, чтобы проверить соединение
logger.info(f"Successfully connected to qBittorrent at {QBT_HOST}:{QBT_PORT}") logger.info(f"Successfully connected to qBittorrent at {QBT_HOST}:{QBT_PORT}")
return True return True
except APIError as e: except APIError as e: