Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
6835c38c24
@ -20,10 +20,16 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
|
|
||||||
qbc: Client = None
|
qbc: Client = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, host: str = None, port: int = None, username: str = None, password: str = None):
|
||||||
self._host, self._port = StringUtils.get_domain_address(address=settings.QB_HOST, prefix=True)
|
"""
|
||||||
self._username = settings.QB_USER
|
若不设置参数,则创建配置文件设置的下载器
|
||||||
self._password = settings.QB_PASSWORD
|
"""
|
||||||
|
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:
|
if self._host and self._port:
|
||||||
self.qbc = self.__login_qbittorrent()
|
self.qbc = self.__login_qbittorrent()
|
||||||
|
|
||||||
|
@ -24,10 +24,16 @@ class Transmission(metaclass=Singleton):
|
|||||||
"peersGettingFromUs", "peersSendingToUs", "uploadRatio", "uploadedEver", "downloadedEver", "downloadDir",
|
"peersGettingFromUs", "peersSendingToUs", "uploadRatio", "uploadedEver", "downloadedEver", "downloadDir",
|
||||||
"error", "errorString", "doneDate", "queuePosition", "activityDate", "trackers"]
|
"error", "errorString", "doneDate", "queuePosition", "activityDate", "trackers"]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, host: str = None, port: int = None, username: str = None, password: str = None):
|
||||||
self._host, self._port = StringUtils.get_domain_address(address=settings.TR_HOST, prefix=False)
|
"""
|
||||||
self._username = settings.TR_USER
|
若不设置参数,则创建配置文件设置的下载器
|
||||||
self._password = settings.TR_PASSWORD
|
"""
|
||||||
|
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:
|
if self._host and self._port:
|
||||||
self.trc = self.__login_transmission()
|
self.trc = self.__login_transmission()
|
||||||
|
|
||||||
|
@ -9,9 +9,10 @@ class Singleton(abc.ABCMeta, type):
|
|||||||
_instances: dict = {}
|
_instances: dict = {}
|
||||||
|
|
||||||
def __call__(cls, *args, **kwargs):
|
def __call__(cls, *args, **kwargs):
|
||||||
if cls not in cls._instances:
|
key = (cls, args, frozenset(kwargs.items()))
|
||||||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
if key not in cls._instances:
|
||||||
return cls._instances[cls]
|
cls._instances[key] = super().__call__(*args, **kwargs)
|
||||||
|
return cls._instances[key]
|
||||||
|
|
||||||
|
|
||||||
class AbstractSingleton(abc.ABC, metaclass=Singleton):
|
class AbstractSingleton(abc.ABC, metaclass=Singleton):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user