This commit is contained in:
jxxghp
2024-08-16 17:03:51 +08:00
parent c030f52418
commit 6e334ef333
4 changed files with 23 additions and 23 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ class EmbyModule(_ModuleBase, _MediaServerBase):
media_statistics = [] media_statistics = []
for server in servers: for server in servers:
media_statistic = server.get_medias_count() media_statistic = server.get_medias_count()
if not media_statistics: if not media_statistic:
continue continue
media_statistic.user_count = server.get_user_count() media_statistic.user_count = server.get_user_count()
media_statistics.append(media_statistic) media_statistics.append(media_statistic)
+2 -2
View File
@@ -176,14 +176,14 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase):
# 选择文件 # 选择文件
server.set_files(torrent_hash=torrent_hash, file_ids=file_ids, priority=0) server.set_files(torrent_hash=torrent_hash, file_ids=file_ids, priority=0)
# 开始任务 # 开始任务
if settings.QB_FORCE_RESUME: if server.is_force_resume():
# 强制继续 # 强制继续
server.torrents_set_force_start(torrent_hash) server.torrents_set_force_start(torrent_hash)
else: else:
server.start_torrents(torrent_hash) server.start_torrents(torrent_hash)
return downloader or self._default_server, torrent_hash, f"添加下载成功,已选择集数:{sucess_epidised}" return downloader or self._default_server, torrent_hash, f"添加下载成功,已选择集数:{sucess_epidised}"
else: else:
if settings.QB_FORCE_RESUME: if server.is_force_resume():
server.torrents_set_force_start(torrent_hash) server.torrents_set_force_start(torrent_hash)
return downloader or self._default_server, torrent_hash, "添加下载成功" return downloader or self._default_server, torrent_hash, "添加下载成功"
+14 -10
View File
@@ -7,6 +7,7 @@ from qbittorrentapi.client import Client
from qbittorrentapi.transfer import TransferInfoDictionary from qbittorrentapi.transfer import TransferInfoDictionary
from app.log import logger from app.log import logger
from app.utils.string import StringUtils
class Qbittorrent: class Qbittorrent:
@@ -27,18 +28,13 @@ class Qbittorrent:
""" """
若不设置参数,则创建配置文件设置的下载器 若不设置参数,则创建配置文件设置的下载器
""" """
if not host: if host and port:
self._host, self._port = host, port
elif host:
self._host, self._port = StringUtils.get_domain_address(address=host, prefix=True)
else:
logger.error("Qbittorrent配置不完整!") logger.error("Qbittorrent配置不完整!")
return return
self._host = host
if not port:
# 从host中获取端口
if ":" in host:
host, port = host.split(":")
self._host = host
self._port = int(port)
else:
self._port = port
self._username = username self._username = username
self._password = password self._password = password
self._category = category self._category = category
@@ -176,12 +172,20 @@ class Qbittorrent:
except Exception as err: except Exception as err:
logger.error(f"设置种子Tag出错:{str(err)}") logger.error(f"设置种子Tag出错:{str(err)}")
def is_force_resume(self) -> bool:
"""
是否支持强制作种
"""
return self._force_resume
def torrents_set_force_start(self, ids: Union[str, list]): def torrents_set_force_start(self, ids: Union[str, list]):
""" """
设置强制作种 设置强制作种
""" """
if not self.qbc: if not self.qbc:
return return
if not self._force_resume:
return
try: try:
self.qbc.torrents_set_force_start(enable=True, torrent_hashes=ids) self.qbc.torrents_set_force_start(enable=True, torrent_hashes=ids)
except Exception as err: except Exception as err:
+6 -10
View File
@@ -5,6 +5,7 @@ from transmission_rpc import Client, Torrent, File
from transmission_rpc.session import SessionStats, Session from transmission_rpc.session import SessionStats, Session
from app.log import logger from app.log import logger
from app.utils.string import StringUtils
class Transmission: class Transmission:
@@ -26,18 +27,13 @@ class Transmission:
""" """
若不设置参数,则创建配置文件设置的下载器 若不设置参数,则创建配置文件设置的下载器
""" """
if not host: if host and port:
self._host, self._port = host, port
elif host:
self._host, self._port = StringUtils.get_domain_address(address=host, prefix=False)
else:
logger.error("Transmission配置不完整!") logger.error("Transmission配置不完整!")
return return
self._host = host
if not port:
# 从host中获取端口
if ":" in host:
host, port = host.split(":")
self._host = host
self._port = int(port)
else:
self._port = port
self._username = username self._username = username
self._password = password self._password = password
if self._host and self._port: if self._host and self._port: