Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.1.9 #566

Merged
merged 9 commits into from
Oct 11, 2023
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ cython_debug/

/src/module/conf/config_dev.ini

test.*

.run
/backend/src/templates/
/backend/src/config/
Expand All @@ -190,6 +190,7 @@ lerna-debug.log*

node_modules
dist
webui/.vite/deps/*
dist.zip
dist-ssr
*.local
Expand Down
1 change: 1 addition & 0 deletions backend/src/module/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion backend/src/module/manager/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 2 additions & 5 deletions backend/src/module/manager/torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 2 additions & 3 deletions backend/src/module/notification/plugin/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
3 changes: 3 additions & 0 deletions backend/src/module/parser/analyser/mikan_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from bs4 import BeautifulSoup
from urllib3.util import parse_url

Expand All @@ -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}")
Expand Down
24 changes: 11 additions & 13 deletions backend/src/module/rss/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="无法解析此链接。",
)
2 changes: 2 additions & 0 deletions backend/src/module/update/startup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from module.rss import RSSEngine
from module.conf import POSTERS_PATH

logger = logging.getLogger(__name__)

Expand All @@ -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)