From b831d71bf77261bb58697990a113309633e4a52b Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 22 Aug 2023 13:43:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A4=9A=E9=80=9A=E7=9F=A5Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/download.py | 2 -- app/chain/__init__.py | 8 ++++---- app/chain/cookiecloud.py | 3 +-- app/chain/rss.py | 1 - app/db/downloadhistory_oper.py | 2 +- app/modules/slack/__init__.py | 6 +++--- app/modules/telegram/__init__.py | 6 +++--- app/modules/themoviedb/scraper.py | 4 ++-- app/modules/wechat/__init__.py | 6 +++--- app/schemas/types.py | 1 - 10 files changed, 17 insertions(+), 22 deletions(-) diff --git a/app/api/endpoints/download.py b/app/api/endpoints/download.py index c637c3a5..df164686 100644 --- a/app/api/endpoints/download.py +++ b/app/api/endpoints/download.py @@ -11,8 +11,6 @@ from app.core.context import MediaInfo, Context, TorrentInfo from app.core.metainfo import MetaInfo from app.core.security import verify_token from app.db import get_db -from app.db.models.user import User -from app.db.userauth import get_current_active_superuser from app.schemas import NotExistMediaInfo, MediaType router = APIRouter() diff --git a/app/chain/__init__.py b/app/chain/__init__.py index 59a0bcbc..c452f58f 100644 --- a/app/chain/__init__.py +++ b/app/chain/__init__.py @@ -97,8 +97,8 @@ class ChainBase(metaclass=ABCMeta): if isinstance(temp, list): result.extend(temp) else: - # 返回结果非列表也非空,则继续执行下一模块 - result = func(*args, **kwargs) + # 中止继续执行 + break except Exception as err: logger.error(f"运行模块 {method} 出错:{module.__class__.__name__} - {err}\n{traceback.print_exc()}") return result @@ -345,7 +345,7 @@ class ChainBase(metaclass=ABCMeta): return self.run_module("refresh_mediaserver", mediainfo=mediainfo, file_path=file_path) return None - def post_message(self, message: Notification) -> Optional[bool]: + def post_message(self, message: Notification) -> None: """ 发送消息 :param message: 消息体 @@ -364,7 +364,7 @@ class ChainBase(metaclass=ABCMeta): f"title={message.title}, " f"text={message.text}," f"userid={message.userid}") - return self.run_module("post_message", message=message) + self.run_module("post_message", message=message) def post_medias_message(self, message: Notification, medias: List[MediaInfo]) -> Optional[bool]: """ diff --git a/app/chain/cookiecloud.py b/app/chain/cookiecloud.py index 6f276ffb..da6cdccd 100644 --- a/app/chain/cookiecloud.py +++ b/app/chain/cookiecloud.py @@ -8,9 +8,8 @@ from sqlalchemy.orm import Session from app.chain import ChainBase from app.chain.site import SiteChain from app.core.config import settings -from app.db.siteicon_oper import SiteIconOper from app.db.site_oper import SiteOper -from app.helper.browser import PlaywrightHelper +from app.db.siteicon_oper import SiteIconOper from app.helper.cloudflare import under_challenge from app.helper.cookiecloud import CookieCloudHelper from app.helper.message import MessageHelper diff --git a/app/chain/rss.py b/app/chain/rss.py index 7c301926..47f5798f 100644 --- a/app/chain/rss.py +++ b/app/chain/rss.py @@ -1,6 +1,5 @@ import json import re -import time from datetime import datetime from typing import Tuple, Optional diff --git a/app/db/downloadhistory_oper.py b/app/db/downloadhistory_oper.py index c26766cc..b97d010d 100644 --- a/app/db/downloadhistory_oper.py +++ b/app/db/downloadhistory_oper.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import Any, List +from typing import Any from app.db import DbOper from app.db.models.downloadhistory import DownloadHistory diff --git a/app/modules/slack/__init__.py b/app/modules/slack/__init__.py index d65e70d9..945107a2 100644 --- a/app/modules/slack/__init__.py +++ b/app/modules/slack/__init__.py @@ -182,14 +182,14 @@ class SlackModule(_ModuleBase): return None @checkMessage(MessageChannel.Slack) - def post_message(self, message: Notification) -> Optional[bool]: + def post_message(self, message: Notification) -> None: """ 发送消息 :param message: 消息 :return: 成功或失败 """ - return self.slack.send_msg(title=message.title, text=message.text, - image=message.image, userid=message.userid) + self.slack.send_msg(title=message.title, text=message.text, + image=message.image, userid=message.userid) @checkMessage(MessageChannel.Slack) def post_medias_message(self, message: Notification, medias: List[MediaInfo]) -> Optional[bool]: diff --git a/app/modules/telegram/__init__.py b/app/modules/telegram/__init__.py index 43f9ae3b..a58708c8 100644 --- a/app/modules/telegram/__init__.py +++ b/app/modules/telegram/__init__.py @@ -90,14 +90,14 @@ class TelegramModule(_ModuleBase): return None @checkMessage(MessageChannel.Telegram) - def post_message(self, message: Notification) -> Optional[bool]: + def post_message(self, message: Notification) -> None: """ 发送消息 :param message: 消息体 :return: 成功或失败 """ - return self.telegram.send_msg(title=message.title, text=message.text, - image=message.image, userid=message.userid) + self.telegram.send_msg(title=message.title, text=message.text, + image=message.image, userid=message.userid) @checkMessage(MessageChannel.Telegram) def post_medias_message(self, message: Notification, medias: List[MediaInfo]) -> Optional[bool]: diff --git a/app/modules/themoviedb/scraper.py b/app/modules/themoviedb/scraper.py index 3a6f45fd..5652f600 100644 --- a/app/modules/themoviedb/scraper.py +++ b/app/modules/themoviedb/scraper.py @@ -271,11 +271,11 @@ class TmdbScraper: # 添加时间 DomUtils.add_node(doc, root, "dateadded", time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) # TMDBID - uniqueid = DomUtils.add_node(doc, root, "uniqueid", tmdbid) + uniqueid = DomUtils.add_node(doc, root, "uniqueid", str(tmdbid)) uniqueid.setAttribute("type", "tmdb") uniqueid.setAttribute("default", "true") # tmdbid - DomUtils.add_node(doc, root, "tmdbid", tmdbid) + DomUtils.add_node(doc, root, "tmdbid", str(tmdbid)) # 标题 DomUtils.add_node(doc, root, "title", episodeinfo.get("name") or "第 %s 集" % episode) # 简介 diff --git a/app/modules/wechat/__init__.py b/app/modules/wechat/__init__.py index 4fcd7d5f..78204792 100644 --- a/app/modules/wechat/__init__.py +++ b/app/modules/wechat/__init__.py @@ -114,14 +114,14 @@ class WechatModule(_ModuleBase): return None @checkMessage(MessageChannel.Wechat) - def post_message(self, message: Notification) -> Optional[bool]: + def post_message(self, message: Notification) -> None: """ 发送消息 :param message: 消息内容 :return: 成功或失败 """ - return self.wechat.send_msg(title=message.title, text=message.text, - image=message.image, userid=message.userid) + self.wechat.send_msg(title=message.title, text=message.text, + image=message.image, userid=message.userid) @checkMessage(MessageChannel.Wechat) def post_medias_message(self, message: Notification, medias: List[MediaInfo]) -> Optional[bool]: diff --git a/app/schemas/types.py b/app/schemas/types.py index c5b035d5..2f05578b 100644 --- a/app/schemas/types.py +++ b/app/schemas/types.py @@ -42,7 +42,6 @@ class EventType(Enum): NoticeMessage = "notice.message" - # 系统配置Key字典 class SystemConfigKey(Enum): # 用户已安装的插件