Merge pull request #566 from EstrellaXD/3.1-dev

3.1.9
This commit is contained in:
Estrella Pan
2023-10-11 18:40:08 +08:00
committed by GitHub
8 changed files with 25 additions and 23 deletions

3
.gitignore vendored
View File

@@ -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

View File

@@ -8,5 +8,6 @@ TMDB_API = "32b19d6a05b512190a056fa4e747cbbc"
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"

View File

@@ -53,8 +53,9 @@ class SeasonCollector(DownloadClient):
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():

View File

@@ -40,19 +40,16 @@ class TorrentManager(Database):
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(

View File

@@ -26,13 +26,12 @@ class TelegramNotification(RequestContent):
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}")

View File

@@ -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}")

View File

@@ -82,16 +82,14 @@ class RSSAnalyser(TitleParser):
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="无法解析此链接。",
)

View File

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