diff --git a/.gitignore b/.gitignore index 159da783..485008df 100644 --- a/.gitignore +++ b/.gitignore @@ -172,7 +172,7 @@ cython_debug/ /src/module/conf/config_dev.ini -test.* + .run /backend/src/templates/ /backend/src/config/ @@ -190,6 +190,7 @@ lerna-debug.log* node_modules dist +webui/.vite/deps/* dist.zip dist-ssr *.local diff --git a/backend/src/module/conf/__init__.py b/backend/src/module/conf/__init__.py index 9a1b7aef..67acbd55 100644 --- a/backend/src/module/conf/__init__.py +++ b/backend/src/module/conf/__init__.py @@ -8,5 +8,6 @@ DATA_PATH = "sqlite:///data/data.db" LEGACY_DATA_PATH = Path("data/data.json") VERSION_PATH = Path("config/version.info") +POSTERS_PATH = Path("data/posters") PLATFORM = "Windows" if "\\" in settings.downloader.path else "Unix" diff --git a/backend/src/module/manager/collector.py b/backend/src/module/manager/collector.py index 4b264b9a..282db739 100644 --- a/backend/src/module/manager/collector.py +++ b/backend/src/module/manager/collector.py @@ -53,8 +53,9 @@ def subscribe_season(data: Bangumi): engine.add_rss( rss_link=data.rss_link, name=data.official_title, aggregate=False ) + result = engine.download_bangumi(data) engine.bangumi.add(data) - return engine.download_bangumi(data) + return result def eps_complete(): diff --git a/backend/src/module/manager/torrent.py b/backend/src/module/manager/torrent.py index 5de9a823..42ab01ef 100644 --- a/backend/src/module/manager/torrent.py +++ b/backend/src/module/manager/torrent.py @@ -40,19 +40,16 @@ def delete_rule(self, _id: int | str, file: bool = False): data = self.bangumi.search_id(int(_id)) if isinstance(data, Bangumi): with DownloadClient() as client: - # client.remove_rule(data.rule_name) - # client.remove_rss_feed(data.official_title) self.rss.delete(data.official_title) self.bangumi.delete_one(int(_id)) if file: torrent_message = self.delete_torrents(data, client) - return torrent_message logger.info(f"[Manager] Delete rule for {data.official_title}") return ResponseModel( status_code=200, status=True, - msg_en=f"Delete rule for {data.official_title}", - msg_zh=f"删除 {data.official_title} 规则", + msg_en=f"Delete rule for {data.official_title}. {torrent_message.msg_en if file else ''}", + msg_zh=f"删除 {data.official_title} 规则。{torrent_message.msg_zh if file else ''}", ) else: return ResponseModel( diff --git a/backend/src/module/notification/plugin/telegram.py b/backend/src/module/notification/plugin/telegram.py index a6a52bde..c2eeb534 100644 --- a/backend/src/module/notification/plugin/telegram.py +++ b/backend/src/module/notification/plugin/telegram.py @@ -26,13 +26,12 @@ def post_msg(self, notify: Notification) -> bool: data = { "chat_id": self.chat_id, "caption": text, + "text": text, "disable_notification": True, } photo = load_image(notify.poster_path) if photo: - resp = self.post_files( - self.photo_url, data, files={"photo": photo} - ) + resp = self.post_files(self.photo_url, data, files={"photo": photo}) else: resp = self.post_data(self.message_url, data) logger.debug(f"Telegram notification: {resp.status_code}") diff --git a/backend/src/module/parser/analyser/mikan_parser.py b/backend/src/module/parser/analyser/mikan_parser.py index b498b449..7fe16895 100644 --- a/backend/src/module/parser/analyser/mikan_parser.py +++ b/backend/src/module/parser/analyser/mikan_parser.py @@ -1,3 +1,5 @@ +import re + from bs4 import BeautifulSoup from urllib3.util import parse_url @@ -14,6 +16,7 @@ def mikan_parser(homepage: str): official_title = soup.select_one( 'p.bangumi-title a[href^="/Home/Bangumi/"]' ).text + official_title = re.sub(r"第.*季", "", official_title) if poster_div: poster_path = poster_div.split("url('")[1].split("')")[0] img = req.get_content(f"https://{root_path}{poster_path}") diff --git a/backend/src/module/rss/analyser.py b/backend/src/module/rss/analyser.py index dc141f33..af1bc79a 100644 --- a/backend/src/module/rss/analyser.py +++ b/backend/src/module/rss/analyser.py @@ -82,16 +82,14 @@ def rss_to_data( def link_to_data(self, rss: RSSItem) -> Bangumi | ResponseModel: torrents = self.get_rss_torrents(rss.url, False) - try: - for torrent in torrents: - data = self.torrent_to_data(torrent, rss) - if data: - return data - except Exception as e: - logger.debug(e) - return ResponseModel( - status=False, - status_code=406, - msg_en="No new title has been found.", - msg_zh="没有找到新的番剧。", - ) + for torrent in torrents: + data = self.torrent_to_data(torrent, rss) + if data: + return data + else: + return ResponseModel( + status=False, + status_code=406, + msg_en="Cannot parse this link.", + msg_zh="无法解析此链接。", + ) diff --git a/backend/src/module/update/startup.py b/backend/src/module/update/startup.py index a80120c0..ecdde5e3 100644 --- a/backend/src/module/update/startup.py +++ b/backend/src/module/update/startup.py @@ -1,6 +1,7 @@ import logging from module.rss import RSSEngine +from module.conf import POSTERS_PATH logger = logging.getLogger(__name__) @@ -15,3 +16,4 @@ def first_run(): with RSSEngine() as engine: engine.create_table() engine.user.add_default_user() + POSTERS_PATH.mkdir(parents=True, exist_ok=True)