From d77644ab16f7524e0adc19cf4bd093025dd34f87 Mon Sep 17 00:00:00 2001 From: honue Date: Wed, 29 Nov 2023 12:46:49 +0800 Subject: [PATCH 1/3] fix singleton.py --- app/utils/singleton.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/utils/singleton.py b/app/utils/singleton.py index a6bf423d..908b2ffd 100644 --- a/app/utils/singleton.py +++ b/app/utils/singleton.py @@ -9,9 +9,10 @@ class Singleton(abc.ABCMeta, type): _instances: dict = {} def __call__(cls, *args, **kwargs): - if cls not in cls._instances: - cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) - return cls._instances[cls] + key = (cls, args, frozenset(kwargs.items())) + if key not in cls._instances: + cls._instances[key] = super().__call__(*args, **kwargs) + return cls._instances[key] class AbstractSingleton(abc.ABC, metaclass=Singleton): From d049e04fa2a41587cf7e278ac955c7c7e9078ef1 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 29 Nov 2023 13:13:58 +0800 Subject: [PATCH 2/3] v1.4.7 --- version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.py b/version.py index 9f5e3664..26944e77 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -APP_VERSION = 'v1.4.6' +APP_VERSION = 'v1.4.7' From e5ac7f10d484ed65f506ec343fcc6422478e3595 Mon Sep 17 00:00:00 2001 From: honue Date: Wed, 29 Nov 2023 13:23:28 +0800 Subject: [PATCH 3/3] update downloader init --- app/modules/qbittorrent/qbittorrent.py | 14 ++++++++++---- app/modules/transmission/transmission.py | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/modules/qbittorrent/qbittorrent.py b/app/modules/qbittorrent/qbittorrent.py index b0acaf14..54746ba5 100644 --- a/app/modules/qbittorrent/qbittorrent.py +++ b/app/modules/qbittorrent/qbittorrent.py @@ -20,10 +20,16 @@ class Qbittorrent(metaclass=Singleton): qbc: Client = None - def __init__(self): - self._host, self._port = StringUtils.get_domain_address(address=settings.QB_HOST, prefix=True) - self._username = settings.QB_USER - self._password = settings.QB_PASSWORD + def __init__(self, host: str = None, port: int = None, username: str = None, password: str = None): + """ + 若不设置参数,则创建配置文件设置的下载器 + """ + if host and port: + self._host, self._port = host, port + else: + self._host, self._port = StringUtils.get_domain_address(address=settings.QB_HOST, prefix=True) + self._username = username if username else settings.QB_USER + self._password = password if password else settings.QB_PASSWORD if self._host and self._port: self.qbc = self.__login_qbittorrent() diff --git a/app/modules/transmission/transmission.py b/app/modules/transmission/transmission.py index fa7b9bd8..4824df33 100644 --- a/app/modules/transmission/transmission.py +++ b/app/modules/transmission/transmission.py @@ -24,10 +24,16 @@ class Transmission(metaclass=Singleton): "peersGettingFromUs", "peersSendingToUs", "uploadRatio", "uploadedEver", "downloadedEver", "downloadDir", "error", "errorString", "doneDate", "queuePosition", "activityDate", "trackers"] - def __init__(self): - self._host, self._port = StringUtils.get_domain_address(address=settings.TR_HOST, prefix=False) - self._username = settings.TR_USER - self._password = settings.TR_PASSWORD + def __init__(self, host: str = None, port: int = None, username: str = None, password: str = None): + """ + 若不设置参数,则创建配置文件设置的下载器 + """ + if host and port: + self._host, self._port = host, port + else: + self._host, self._port = StringUtils.get_domain_address(address=settings.TR_HOST, prefix=False) + self._username = username if username else settings.TR_USER + self._password = password if password else settings.TR_PASSWORD if self._host and self._port: self.trc = self.__login_transmission()