From 521d3f20d8cb03165f5a79b2f4c92d3c624ddc34 Mon Sep 17 00:00:00 2001 From: shininome Date: Mon, 9 Oct 2023 09:38:28 +0800 Subject: [PATCH 1/8] fix telegram notification wrong when no image --- backend/src/module/notification/plugin/telegram.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/src/module/notification/plugin/telegram.py b/backend/src/module/notification/plugin/telegram.py index ac35623d..c8cd2a59 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}") From 9d9b243d97250c0ec528b400e527729254c979c7 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Tue, 10 Oct 2023 13:52:08 +0800 Subject: [PATCH 2/8] fix: first run not create poster folder problem. --- backend/src/module/core/program.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/src/module/core/program.py b/backend/src/module/core/program.py index ee73c5f5..c8b42ab9 100644 --- a/backend/src/module/core/program.py +++ b/backend/src/module/core/program.py @@ -36,6 +36,9 @@ def startup(self): if not self.database: first_run() logger.info("[Core] No db file exists, create database file.") + if not self.img_cache: + logger.info("[Core] No image cache exists, create image cache.") + cache_image() return {"status": "First run detected."} if self.legacy_data: logger.info( From 87a49c49b1f42ae7b277e7c89e593677ec35fdc3 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Tue, 10 Oct 2023 13:53:56 +0800 Subject: [PATCH 3/8] fix: first run not create poster folder problem. --- backend/src/module/conf/__init__.py | 1 + backend/src/module/core/program.py | 3 --- backend/src/module/update/startup.py | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-) 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/core/program.py b/backend/src/module/core/program.py index c8b42ab9..ee73c5f5 100644 --- a/backend/src/module/core/program.py +++ b/backend/src/module/core/program.py @@ -36,9 +36,6 @@ def startup(self): if not self.database: first_run() logger.info("[Core] No db file exists, create database file.") - if not self.img_cache: - logger.info("[Core] No image cache exists, create image cache.") - cache_image() return {"status": "First run detected."} if self.legacy_data: logger.info( 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) From 78e67fef85fb6c62f85c48f93ac37d50fb896c4d Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Tue, 10 Oct 2023 14:02:17 +0800 Subject: [PATCH 4/8] chore: update gitignore. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From de63a5b0b5918041f5fb066ade04a45b456dda38 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Wed, 11 Oct 2023 13:09:17 +0800 Subject: [PATCH 5/8] fix: analyser log error. --- backend/src/module/rss/analyser.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) 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="无法解析此链接。", + ) From f5d8790454b1507d4e82308acf900c940e2ab2ec Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Wed, 11 Oct 2023 16:16:48 +0800 Subject: [PATCH 6/8] change: remove season info in mikan parser. --- backend/src/module/parser/analyser/mikan_parser.py | 3 +++ 1 file changed, 3 insertions(+) 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}") From bed3757bb76196e15b750bf4ecdb07dd34703096 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Wed, 11 Oct 2023 16:35:03 +0800 Subject: [PATCH 7/8] =?UTF-8?q?fix:=20=E9=80=9A=E8=BF=87=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E8=8E=B7=E5=BE=97=E7=9A=84=E7=95=AA=E5=89=A7=E5=90=8E=E7=BB=AD?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=87=BA=E7=8E=B0=E9=97=AE=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/module/manager/collector.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(): From cf7424b9ad56a73778aad8116150154f62727a67 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Wed, 11 Oct 2023 18:38:45 +0800 Subject: [PATCH 8/8] fix: bug of delete bangumi. --- backend/src/module/manager/torrent.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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(