mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix download && message
This commit is contained in:
@@ -483,7 +483,7 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
if not message.userid and message.mtype:
|
if not message.userid and message.mtype:
|
||||||
# 没有指定用户ID时,按规则确定发送对象
|
# 没有指定用户ID时,按规则确定发送对象
|
||||||
# 默认发送全体
|
# 默认发送全体
|
||||||
to_targets = {}
|
to_targets = None
|
||||||
notify_action = self.notificationhelper.get_switch(message.mtype)
|
notify_action = self.notificationhelper.get_switch(message.mtype)
|
||||||
if notify_action == "admin":
|
if notify_action == "admin":
|
||||||
# 仅发送管理员
|
# 仅发送管理员
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase):
|
|||||||
if settings.TORRENT_TAG and settings.TORRENT_TAG not in torrent_tags:
|
if settings.TORRENT_TAG and settings.TORRENT_TAG not in torrent_tags:
|
||||||
logger.info(f"给种子 {torrent_hash} 打上标签:{settings.TORRENT_TAG}")
|
logger.info(f"给种子 {torrent_hash} 打上标签:{settings.TORRENT_TAG}")
|
||||||
server.set_torrents_tag(ids=torrent_hash, tags=[settings.TORRENT_TAG])
|
server.set_torrents_tag(ids=torrent_hash, tags=[settings.TORRENT_TAG])
|
||||||
return downloader or self._default_server, torrent_hash, f"下载任务已存在"
|
return downloader or self._default_server_name, torrent_hash, f"下载任务已存在"
|
||||||
return None, None, f"添加种子任务失败:{content}"
|
return None, None, f"添加种子任务失败:{content}"
|
||||||
else:
|
else:
|
||||||
# 获取种子Hash
|
# 获取种子Hash
|
||||||
@@ -158,7 +158,7 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase):
|
|||||||
# 种子文件
|
# 种子文件
|
||||||
torrent_files = server.get_files(torrent_hash)
|
torrent_files = server.get_files(torrent_hash)
|
||||||
if not torrent_files:
|
if not torrent_files:
|
||||||
return downloader or self._default_server, torrent_hash, "获取种子文件失败,下载任务可能在暂停状态"
|
return downloader or self._default_server_name, torrent_hash, "获取种子文件失败,下载任务可能在暂停状态"
|
||||||
|
|
||||||
# 不需要的文件ID
|
# 不需要的文件ID
|
||||||
file_ids = []
|
file_ids = []
|
||||||
@@ -183,11 +183,11 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase):
|
|||||||
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_name, torrent_hash, f"添加下载成功,已选择集数:{sucess_epidised}"
|
||||||
else:
|
else:
|
||||||
if server.is_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_name, torrent_hash, "添加下载成功"
|
||||||
|
|
||||||
def list_torrents(self, status: TorrentStatus = None,
|
def list_torrents(self, status: TorrentStatus = None,
|
||||||
hashs: Union[list, str] = None,
|
hashs: Union[list, str] = None,
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ class Slack:
|
|||||||
_ds_url = f"http://127.0.0.1:{settings.PORT}/api/v1/message?token={settings.API_TOKEN}"
|
_ds_url = f"http://127.0.0.1:{settings.PORT}/api/v1/message?token={settings.API_TOKEN}"
|
||||||
_channel = ""
|
_channel = ""
|
||||||
|
|
||||||
def __init__(self, oauth_token: str = None, app_token: str = None, channel: str = "", **kwargs):
|
def __init__(self, SLACK_OAUTH_TOKEN: str = None, SLACK_APP_TOKEN: str = None, SLACK_CHANNEL: str = "", **kwargs):
|
||||||
|
|
||||||
if not oauth_token or not app_token:
|
if not SLACK_OAUTH_TOKEN or not SLACK_APP_TOKEN:
|
||||||
logger.error("Slack 配置不完整!")
|
logger.error("Slack 配置不完整!")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
slack_app = App(token=oauth_token,
|
slack_app = App(token=SLACK_OAUTH_TOKEN,
|
||||||
ssl_check_enabled=False,
|
ssl_check_enabled=False,
|
||||||
url_verification_enabled=False)
|
url_verification_enabled=False)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
@@ -39,7 +39,7 @@ class Slack:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._client = slack_app.client
|
self._client = slack_app.client
|
||||||
self._channel = channel
|
self._channel = SLACK_CHANNEL
|
||||||
|
|
||||||
# 标记消息来源
|
# 标记消息来源
|
||||||
if kwargs.get("name"):
|
if kwargs.get("name"):
|
||||||
@@ -79,7 +79,7 @@ class Slack:
|
|||||||
try:
|
try:
|
||||||
self._service = SocketModeHandler(
|
self._service = SocketModeHandler(
|
||||||
slack_app,
|
slack_app,
|
||||||
app_token
|
SLACK_APP_TOKEN
|
||||||
)
|
)
|
||||||
self._service.connect()
|
self._service.connect()
|
||||||
logger.info("Slack消息接收服务启动")
|
logger.info("Slack消息接收服务启动")
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ lock = Lock()
|
|||||||
|
|
||||||
|
|
||||||
class SynologyChat:
|
class SynologyChat:
|
||||||
def __init__(self, webhook: str = None, token: str = None, **kwargs):
|
def __init__(self, SYNOLOGYCHAT_WEBHOOK: str = None, SYNOLOGYCHAT_TOKEN: str = None, **kwargs):
|
||||||
if not webhook or not token:
|
if not SYNOLOGYCHAT_WEBHOOK or not SYNOLOGYCHAT_TOKEN:
|
||||||
logger.error("SynologyChat配置不完整!")
|
logger.error("SynologyChat配置不完整!")
|
||||||
return
|
return
|
||||||
self._req = RequestUtils(content_type="application/x-www-form-urlencoded")
|
self._req = RequestUtils(content_type="application/x-www-form-urlencoded")
|
||||||
self._webhook_url = webhook
|
self._webhook_url = SYNOLOGYCHAT_WEBHOOK
|
||||||
self._token = token
|
self._token = SYNOLOGYCHAT_TOKEN
|
||||||
if self._webhook_url:
|
if self._webhook_url:
|
||||||
self._domain = StringUtils.get_base_url(self._webhook_url)
|
self._domain = StringUtils.get_base_url(self._webhook_url)
|
||||||
|
|
||||||
|
|||||||
@@ -113,9 +113,9 @@ class TelegramModule(_ModuleBase, _MessageBase):
|
|||||||
if text:
|
if text:
|
||||||
logger.info(f"收到来自 {source} 的Telegram消息:userid={user_id}, username={user_name}, text={text}")
|
logger.info(f"收到来自 {source} 的Telegram消息:userid={user_id}, username={user_name}, text={text}")
|
||||||
# 检查权限
|
# 检查权限
|
||||||
admin_users = config.config.get("admins")
|
admin_users = config.config.get("TELEGRAM_ADMINS")
|
||||||
user_list = config.config.get("users")
|
user_list = config.config.get("TELEGRAM_USERS")
|
||||||
chat_id = config.config.get("chat_id")
|
chat_id = config.config.get("TELEGRAM_CHAT_ID")
|
||||||
if text.startswith("/"):
|
if text.startswith("/"):
|
||||||
if admin_users \
|
if admin_users \
|
||||||
and str(user_id) not in admin_users.split(',') \
|
and str(user_id) not in admin_users.split(',') \
|
||||||
|
|||||||
@@ -25,17 +25,17 @@ class Telegram:
|
|||||||
_event = Event()
|
_event = Event()
|
||||||
_bot: telebot.TeleBot = None
|
_bot: telebot.TeleBot = None
|
||||||
|
|
||||||
def __init__(self, token: str = None, chat_id: str = None, **kwargs):
|
def __init__(self, TELEGRAM_TOKEN: str = None, TELEGRAM_CHAT_ID: str = None, **kwargs):
|
||||||
"""
|
"""
|
||||||
初始化参数
|
初始化参数
|
||||||
"""
|
"""
|
||||||
if not token or not chat_id:
|
if not TELEGRAM_TOKEN or not TELEGRAM_CHAT_ID:
|
||||||
logger.error("Telegram配置不完整!")
|
logger.error("Telegram配置不完整!")
|
||||||
return
|
return
|
||||||
# Token
|
# Token
|
||||||
self._telegram_token = token
|
self._telegram_token = TELEGRAM_TOKEN
|
||||||
# Chat Id
|
# Chat Id
|
||||||
self._telegram_chat_id = chat_id
|
self._telegram_chat_id = TELEGRAM_CHAT_ID
|
||||||
# 初始化机器人
|
# 初始化机器人
|
||||||
if self._telegram_token and self._telegram_chat_id:
|
if self._telegram_token and self._telegram_chat_id:
|
||||||
# bot
|
# bot
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class TransmissionModule(_ModuleBase, _DownloaderBase):
|
|||||||
if settings.TORRENT_TAG and settings.TORRENT_TAG not in labels:
|
if settings.TORRENT_TAG and settings.TORRENT_TAG not in labels:
|
||||||
labels.append(settings.TORRENT_TAG)
|
labels.append(settings.TORRENT_TAG)
|
||||||
server.set_torrent_tag(ids=torrent_hash, tags=labels)
|
server.set_torrent_tag(ids=torrent_hash, tags=labels)
|
||||||
return downloader or self._default_server, torrent_hash, f"下载任务已存在"
|
return downloader or self._default_server_name, torrent_hash, f"下载任务已存在"
|
||||||
return None, None, f"添加种子任务失败:{content}"
|
return None, None, f"添加种子任务失败:{content}"
|
||||||
else:
|
else:
|
||||||
torrent_hash = torrent.hashString
|
torrent_hash = torrent.hashString
|
||||||
@@ -154,7 +154,7 @@ class TransmissionModule(_ModuleBase, _DownloaderBase):
|
|||||||
# 选择文件
|
# 选择文件
|
||||||
torrent_files = server.get_files(torrent_hash)
|
torrent_files = server.get_files(torrent_hash)
|
||||||
if not torrent_files:
|
if not torrent_files:
|
||||||
return downloader or self._default_server, torrent_hash, "获取种子文件失败,下载任务可能在暂停状态"
|
return downloader or self._default_server_name, torrent_hash, "获取种子文件失败,下载任务可能在暂停状态"
|
||||||
# 需要的文件信息
|
# 需要的文件信息
|
||||||
file_ids = []
|
file_ids = []
|
||||||
unwanted_file_ids = []
|
unwanted_file_ids = []
|
||||||
@@ -175,9 +175,9 @@ class TransmissionModule(_ModuleBase, _DownloaderBase):
|
|||||||
server.set_unwanted_files(torrent_hash, unwanted_file_ids)
|
server.set_unwanted_files(torrent_hash, unwanted_file_ids)
|
||||||
# 开始任务
|
# 开始任务
|
||||||
server.start_torrents(torrent_hash)
|
server.start_torrents(torrent_hash)
|
||||||
return downloader or self._default_server, torrent_hash, "添加下载任务成功"
|
return downloader or self._default_server_name, torrent_hash, "添加下载任务成功"
|
||||||
else:
|
else:
|
||||||
return downloader or self._default_server, torrent_hash, "添加下载任务成功"
|
return downloader or self._default_server_name, torrent_hash, "添加下载任务成功"
|
||||||
|
|
||||||
def list_torrents(self, status: TorrentStatus = None,
|
def list_torrents(self, status: TorrentStatus = None,
|
||||||
hashs: Union[list, str] = None,
|
hashs: Union[list, str] = None,
|
||||||
|
|||||||
@@ -22,21 +22,21 @@ class VoceChat:
|
|||||||
# 请求对象
|
# 请求对象
|
||||||
_client = None
|
_client = None
|
||||||
|
|
||||||
def __init__(self, host: str = None, apikey: str = None, channel_id: str = None, **kwargs):
|
def __init__(self, VOCECHAT_HOST: str = None, VOCECHAT_API_KEY: str = None, VOCECHAT_CHANNEL_ID: str = None, **kwargs):
|
||||||
"""
|
"""
|
||||||
初始化
|
初始化
|
||||||
"""
|
"""
|
||||||
if not host or not apikey or not channel_id:
|
if not VOCECHAT_HOST or not VOCECHAT_API_KEY or not VOCECHAT_CHANNEL_ID:
|
||||||
logger.error("VoceChat配置不完整!")
|
logger.error("VoceChat配置不完整!")
|
||||||
return
|
return
|
||||||
self._host = host
|
self._host = VOCECHAT_HOST
|
||||||
if self._host:
|
if self._host:
|
||||||
if not self._host.endswith("/"):
|
if not self._host.endswith("/"):
|
||||||
self._host += "/"
|
self._host += "/"
|
||||||
if not self._host.startswith("http"):
|
if not self._host.startswith("http"):
|
||||||
self._playhost = "http://" + self._host
|
self._playhost = "http://" + self._host
|
||||||
self._apikey = apikey
|
self._apikey = VOCECHAT_API_KEY
|
||||||
self._channel_id = channel_id
|
self._channel_id = VOCECHAT_CHANNEL_ID
|
||||||
if self._apikey and self._host and self._channel_id:
|
if self._apikey and self._host and self._channel_id:
|
||||||
self._client = RequestUtils(headers={
|
self._client = RequestUtils(headers={
|
||||||
"content-type": "text/markdown",
|
"content-type": "text/markdown",
|
||||||
|
|||||||
@@ -37,18 +37,18 @@ class WeChat:
|
|||||||
# 企业微信创新菜单URL
|
# 企业微信创新菜单URL
|
||||||
_create_menu_url = "/cgi-bin/menu/create?access_token=%s&agentid=%s"
|
_create_menu_url = "/cgi-bin/menu/create?access_token=%s&agentid=%s"
|
||||||
|
|
||||||
def __init__(self, corpid: str = None, appsecret: str = None, appid: str = None,
|
def __init__(self, WECHAT_CORPID: str = None, WECHAT_APP_SECRET: str = None, WECHAT_APP_ID: str = None,
|
||||||
proxy: str = None, **kwargs):
|
WECHAT_PROXY: str = None, **kwargs):
|
||||||
"""
|
"""
|
||||||
初始化
|
初始化
|
||||||
"""
|
"""
|
||||||
if not corpid or not appsecret or not appid:
|
if not WECHAT_CORPID or not WECHAT_APP_SECRET or not WECHAT_APP_ID:
|
||||||
logger.error("企业微信配置不完整!")
|
logger.error("企业微信配置不完整!")
|
||||||
return
|
return
|
||||||
self._corpid = corpid
|
self._corpid = WECHAT_CORPID
|
||||||
self._appsecret = appsecret
|
self._appsecret = WECHAT_APP_SECRET
|
||||||
self._appid = appid
|
self._appid = WECHAT_APP_ID
|
||||||
self._proxy = proxy or "https://qyapi.weixin.qq.com"
|
self._proxy = WECHAT_PROXY or "https://qyapi.weixin.qq.com"
|
||||||
|
|
||||||
if self._corpid and self._appsecret and self._appid:
|
if self._corpid and self._appsecret and self._appid:
|
||||||
self.__get_access_token()
|
self.__get_access_token()
|
||||||
|
|||||||
Reference in New Issue
Block a user