mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-28 20:40:47 +08:00
Add extra auth func to aviod program fail to startup
This commit is contained in:
@@ -13,6 +13,10 @@ class DownloadClient:
|
||||
def __init__(self):
|
||||
self.client = getClient()
|
||||
|
||||
def auth(self):
|
||||
host, username, password = settings.downloader.host, settings.downloader.username, settings.downloader.password
|
||||
self.client.auth(host, username, password)
|
||||
|
||||
def init_downloader(self):
|
||||
prefs = {
|
||||
"rss_auto_downloading_enabled": True,
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
from module.conf import settings
|
||||
|
||||
|
||||
def getClient():
|
||||
host = settings.downloader.host
|
||||
username = settings.downloader.username
|
||||
password = settings.downloader.password
|
||||
# TODO 多下载器支持
|
||||
# 从 settings 里读取下载器名称,然后返回对应 Client
|
||||
from .qb_downloader import QbDownloader
|
||||
return QbDownloader(host, username, password)
|
||||
return QbDownloader()
|
||||
|
||||
@@ -7,27 +7,30 @@ from qbittorrentapi.exceptions import Conflict409Error
|
||||
from module.conf import settings
|
||||
from module.ab_decorator import qb_connect_failed_wait
|
||||
|
||||
from .exceptions import ConflictError
|
||||
from module.downloader.exceptions import ConflictError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class QbDownloader:
|
||||
@qb_connect_failed_wait
|
||||
def __init__(self, host, username, password):
|
||||
def __init__(self):
|
||||
self._client: Client | None = None
|
||||
|
||||
@qb_connect_failed_wait
|
||||
def auth(self, host, username, password):
|
||||
self._client = Client(
|
||||
host=host,
|
||||
username=username,
|
||||
password=password,
|
||||
VERIFY_WEBUI_CERTIFICATE=settings.downloader.ssl,
|
||||
RAISE_ERROR_FOR_UNSUPPORTED_QBITTORRENT_VERSIONS=True,
|
||||
VERIFY_WEBUI_CERTIFICATE=settings.downloader.ssl
|
||||
)
|
||||
while True:
|
||||
try:
|
||||
self._client.auth_log_in()
|
||||
break
|
||||
except LoginFailed:
|
||||
logger.debug(
|
||||
logger.warning(
|
||||
f"Can't login qBittorrent Server {host} by {username}, retry in {5} seconds."
|
||||
)
|
||||
time.sleep(5)
|
||||
|
||||
Reference in New Issue
Block a user