Skip to content

Commit 07bb7f2

Browse files
authored
Merge pull request #849 from EstrellaXD/3.1-dev
3.1.15
2 parents 7913061 + d5b84b9 commit 07bb7f2

38 files changed

+5386
-6424
lines changed

backend/src/module/api/program.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@router.on_event("startup")
2121
async def startup():
22-
program.startup()
22+
await program.startup()
2323

2424

2525
@router.on_event("shutdown")

backend/src/module/core/program.py

+20-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import asyncio
23

34
from module.conf import VERSION, settings
45
from module.models import ResponseModel
@@ -31,7 +32,7 @@ def __start_info():
3132
logger.info("GitHub: https://github.com/EstrellaXD/Auto_Bangumi/")
3233
logger.info("Starting AutoBangumi...")
3334

34-
def startup(self):
35+
async def startup(self):
3536
self.__start_info()
3637
if not self.database:
3738
first_run()
@@ -49,32 +50,27 @@ def startup(self):
4950
if not self.img_cache:
5051
logger.info("[Core] No image cache exists, create image cache.")
5152
cache_image()
52-
self.start()
53+
await self.start()
5354

54-
def start(self):
55+
async def start(self):
5556
self.stop_event.clear()
5657
settings.load()
57-
if self.downloader_status:
58-
if self.enable_renamer:
59-
self.rename_start()
60-
if self.enable_rss:
61-
self.rss_start()
62-
logger.info("Program running.")
63-
return ResponseModel(
64-
status=True,
65-
status_code=200,
66-
msg_en="Program started.",
67-
msg_zh="程序启动成功。",
68-
)
69-
else:
70-
self.stop_event.set()
71-
logger.warning("Program failed to start.")
72-
return ResponseModel(
73-
status=False,
74-
status_code=406,
75-
msg_en="Program failed to start.",
76-
msg_zh="程序启动失败。",
77-
)
58+
while not self.downloader_status:
59+
logger.warning("Downloader is not running.")
60+
logger.info("Waiting for downloader to start.")
61+
await asyncio.sleep(30)
62+
if self.enable_renamer:
63+
self.rename_start()
64+
if self.enable_rss:
65+
self.rss_start()
66+
logger.info("Program running.")
67+
return ResponseModel(
68+
status=True,
69+
status_code=200,
70+
msg_en="Program started.",
71+
msg_zh="程序启动成功。",
72+
)
73+
7874

7975
def stop(self):
8076
if self.is_running:

backend/src/module/models/torrent.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class EpisodeFile(BaseModel):
2323
group: str | None = Field(None)
2424
title: str = Field(...)
2525
season: int = Field(...)
26-
episode: int = Field(None)
26+
episode: int | float = Field(None)
2727
suffix: str = Field(..., regex=r"\.(mkv|mp4|MKV|MP4)$")
2828

2929

@@ -32,6 +32,6 @@ class SubtitleFile(BaseModel):
3232
group: str | None = Field(None)
3333
title: str = Field(...)
3434
season: int = Field(...)
35-
episode: int = Field(None)
35+
episode: int | float = Field(None)
3636
language: str = Field(..., regex=r"(zh|zh-tw)")
3737
suffix: str = Field(..., regex=r"\.(ass|srt|ASS|SRT)$")

backend/src/module/network/request_contents.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ class RequestContent(RequestURL):
1515
def get_torrents(
1616
self,
1717
_url: str,
18-
_filter: str = "|".join(settings.rss_parser.filter),
18+
_filter: str = None,
1919
limit: int = None,
2020
retry: int = 3,
2121
) -> list[Torrent]:
2222
soup = self.get_xml(_url, retry)
2323
if soup:
2424
torrent_titles, torrent_urls, torrent_homepage = rss_parser(soup)
2525
torrents: list[Torrent] = []
26+
if _filter is None:
27+
_filter = "|".join(settings.rss_parser.filter)
2628
for _title, torrent_url, homepage in zip(
2729
torrent_titles, torrent_urls, torrent_homepage
2830
):

backend/src/module/parser/analyser/openai.py

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def _prepare_params(self, text: str, prompt: str) -> dict[str, Any]:
136136
dict(role="system", content=prompt),
137137
dict(role="user", content=text),
138138
],
139+
139140
# set temperature to 0 to make results be more stable and reproducible.
140141
temperature=0,
141142
)

backend/src/module/parser/analyser/raw_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def clean_sub(sub: str | None) -> str | None:
131131

132132

133133
def process(raw_title: str):
134-
raw_title = raw_title.strip().replace("\n", "")
134+
raw_title = raw_title.strip().replace("\n", " ")
135135
content_title = pre_process(raw_title)
136136
# 预处理标题
137137
group = get_group(content_title)

backend/src/module/parser/analyser/torrent_parser.py

+24-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
PLATFORM = "Unix"
1010

1111
RULES = [
12-
r"(.*) - (\d{1,4}(?!\d|p)|\d{1,4}\.\d{1,2}(?!\d|p))(?:v\d{1,2})?(?: )?(?:END)?(.*)",
13-
r"(.*)[\[\ E](\d{1,4}|\d{1,4}\.\d{1,2})(?:v\d{1,2})?(?: )?(?:END)?[\]\ ](.*)",
14-
r"(.*)\[(?:第)?(\d*\.*\d*)[话集話](?:END)?\](.*)",
15-
r"(.*)第?(\d*\.*\d*)[话話集](?:END)?(.*)",
16-
r"(.*)(?:S\d{2})?EP?(\d+)(.*)",
12+
r"(.*) - (\d{1,4}(?:\.\d{1,2})?(?!\d|p))(?:v\d{1,2})?(?: )?(?:END)?(.*)",
13+
r"(.*)[\[\ E](\d{1,4}(?:\.\d{1,2})?)(?:v\d{1,2})?(?: )?(?:END)?[\]\ ](.*)",
14+
r"(.*)\[(?:第)?(\d{1,4}(?:\.\d{1,2})?)[话集話](?:END)?\](.*)",
15+
r"(.*)第?(\d{1,4}(?:\.\d{1,2})?)[话話集](?:END)?(.*)",
16+
r"(.*)(?:S\d{2})?EP?(\d{1,4}(?:\.\d{1,2})?)(.*)",
1717
]
1818

1919
SUBTITLE_LANG = {
@@ -81,7 +81,7 @@ def torrent_parser(
8181
title, season = get_season_and_title(title)
8282
else:
8383
title, _ = get_season_and_title(title)
84-
episode = int(match_obj.group(2))
84+
episode = match_obj.group(2)
8585
suffix = Path(torrent_path).suffix
8686
if file_type == "media":
8787
return EpisodeFile(
@@ -103,3 +103,21 @@ def torrent_parser(
103103
episode=episode,
104104
suffix=suffix,
105105
)
106+
107+
108+
if __name__ == "__main__":
109+
ep = torrent_parser(
110+
"/不时用俄语小声说真心话的邻桌艾莉同学/Season 1/不时用俄语小声说真心话的邻桌艾莉同学 S01E02.mp4"
111+
)
112+
print(ep)
113+
114+
ep = torrent_parser(
115+
"/downloads/Bangumi/关于我转生变成史莱姆这档事 (2018)/Season 3/[ANi] 關於我轉生變成史萊姆這檔事 第三季 - 48.5 [1080P][Baha][WEB-DL][AAC AVC][CHT].mp4"
116+
)
117+
print(ep)
118+
119+
ep = torrent_parser(
120+
"/downloads/Bangumi/关于我转生变成史莱姆这档事 (2018)/Season 3/[ANi] 關於我轉生變成史萊姆這檔事 第三季 - 48.5 [1080P][Baha][WEB-DL][AAC AVC][CHT].srt",
121+
file_type="subtitle",
122+
)
123+
print(ep)

backend/src/test/test_raw_parser.py

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33

44
def test_raw_parser():
5+
# Issue #794, RSS link: https://mikanani.me/RSS/Bangumi?bangumiId=3367&subgroupid=370
6+
content = "[喵萌奶茶屋&LoliHouse] 鹿乃子乃子乃子虎视眈眈 / Shikanoko Nokonoko Koshitantan\n- 01 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕]"
7+
info = raw_parser(content)
8+
assert info.group == "喵萌奶茶屋&LoliHouse"
9+
assert info.title_zh == "鹿乃子乃子乃子虎视眈眈"
10+
assert info.title_en == "Shikanoko Nokonoko Koshitantan"
11+
assert info.resolution == "1080p"
12+
assert info.episode == 1
13+
assert info.season == 1
14+
15+
# Issue #679, RSS link: https://mikanani.me/RSS/Bangumi?bangumiId=3225&subgroupid=370
16+
content = "[LoliHouse] 轮回七次的反派大小姐,在前敌国享受随心所欲的新婚生活\n / 7th Time Loop - 12 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕][END]"
17+
info = raw_parser(content)
18+
assert info.group == "LoliHouse"
19+
assert info.title_zh == "轮回七次的反派大小姐,在前敌国享受随心所欲的新婚生活"
20+
assert info.title_en == "7th Time Loop"
21+
assert info.resolution == "1080p"
22+
assert info.episode == 12
23+
assert info.season == 1
24+
525
content = "【幻樱字幕组】【4月新番】【古见同学有交流障碍症 第二季 Komi-san wa, Komyushou Desu. S02】【22】【GB_MP4】【1920X1080】"
626
info = raw_parser(content)
727
assert info.title_en == "Komi-san wa, Komyushou Desu."

backend/src/test/test_torrent_parser.py

+19
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ def test_torrent_parser():
7272
assert bf.season == 1
7373
assert bf.episode == 6
7474

75+
file_name = "不时用俄语小声说真心话的邻桌艾莉同学 S01E02.mp4"
76+
bf = torrent_parser(file_name)
77+
assert bf.title == "不时用俄语小声说真心话的邻桌艾莉同学"
78+
assert bf.season == 1
79+
assert bf.episode == 2
80+
81+
file_name = "[ANi] 關於我轉生變成史萊姆這檔事 第三季 - 48.5 [1080P][Baha][WEB-DL][AAC AVC][CHT].mp4"
82+
bf = torrent_parser(file_name, season=3)
83+
assert bf.title == "關於我轉生變成史萊姆這檔事 第三季"
84+
assert bf.season == 3
85+
assert bf.episode == 48.5
86+
87+
file_name = "[ANi] 關於我轉生變成史萊姆這檔事 第三季 - 48.5 [1080P][Baha][WEB-DL][AAC AVC][CHT].srt"
88+
sf = torrent_parser(file_name, season=3, file_type="subtitle")
89+
assert sf.title == "關於我轉生變成史萊姆這檔事 第三季"
90+
assert sf.episode == 48.5
91+
assert sf.season == 3
92+
assert sf.language == "zh-tw"
93+
7594

7695
class TestGetPathBasename:
7796
def test_regular_path(self):

webui/.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"i18n-ally.localesPaths": ["src/i18n"],
33
"commentTranslate.targetLanguage": "zh-CN",
4-
"i18n-ally.sourceLanguage": "en",
4+
"i18n-ally.sourceLanguage": "zh-CN",
55
"typescript.tsdk": "node_modules/typescript/lib",
66
"i18n-ally.keystyle": "nested"
77
}

webui/package.json

+29-30
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"type": "module",
44
"version": "0.0.0",
55
"private": true,
6+
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
67
"scripts": {
78
"prepare": "cd .. && husky install ./webui/.husky",
89
"test:build": "vue-tsc --noEmit",
@@ -19,53 +20,51 @@
1920
"generate-pwa-assets": "pwa-assets-generator --preset minimal public/images/logo.svg"
2021
},
2122
"dependencies": {
22-
"@headlessui/vue": "^1.7.13",
23-
"@vueuse/components": "^10.4.1",
24-
"@vueuse/core": "^8.9.4",
23+
"@headlessui/vue": "^1.7.23",
24+
"@vueuse/components": "^10.11.1",
25+
"@vueuse/core": "^10.11.1",
2526
"axios": "^0.27.2",
26-
"naive-ui": "^2.34.4",
27-
"pinia": "^2.1.3",
28-
"rxjs": "^7.8.1",
29-
"vue": "^3.3.4",
30-
"vue-i18n": "^9.2.2",
31-
"vue-inline-svg": "^3.1.2",
32-
"vue-router": "^4.2.1"
27+
"naive-ui": "^2.39.0",
28+
"pinia": "^2.2.2",
29+
"vue": "^3.5.8",
30+
"vue-i18n": "^9.14.0",
31+
"vue-inline-svg": "^3.1.4",
32+
"vue-router": "^4.4.5"
3333
},
3434
"devDependencies": {
3535
"@antfu/eslint-config": "^0.38.6",
3636
"@icon-park/vue-next": "^1.4.2",
3737
"@intlify/unplugin-vue-i18n": "^0.11.0",
38-
"@storybook/addon-essentials": "^7.0.12",
39-
"@storybook/addon-interactions": "^7.0.12",
40-
"@storybook/addon-links": "^7.0.12",
41-
"@storybook/blocks": "^7.0.12",
38+
"@storybook/addon-essentials": "^7.6.20",
39+
"@storybook/addon-interactions": "^7.6.20",
40+
"@storybook/addon-links": "^7.6.20",
41+
"@storybook/blocks": "^7.6.20",
4242
"@storybook/testing-library": "0.0.14-next.2",
43-
"@storybook/vue3": "^7.0.12",
44-
"@storybook/vue3-vite": "^7.0.12",
45-
"@types/node": "^18.16.14",
46-
"@unocss/preset-attributify": "^0.55.3",
43+
"@storybook/vue3": "^7.6.20",
44+
"@storybook/vue3-vite": "^7.6.20",
45+
"@types/node": "^18.19.50",
46+
"@unocss/preset-attributify": "^0.55.7",
4747
"@unocss/preset-rem-to-px": "^0.51.13",
4848
"@unocss/reset": "^0.51.13",
49-
"@vitejs/plugin-vue": "^4.2.3",
49+
"@vitejs/plugin-vue": "^4.6.2",
5050
"@vitejs/plugin-vue-jsx": "^3.1.0",
51-
"@vue/runtime-dom": "^3.3.4",
52-
"eslint": "^8.41.0",
53-
"eslint-config-prettier": "^8.8.0",
54-
"eslint-plugin-storybook": "^0.6.12",
51+
"@vue/runtime-dom": "^3.5.8",
52+
"eslint": "^8.57.1",
53+
"eslint-config-prettier": "^8.10.0",
54+
"eslint-plugin-storybook": "^0.6.15",
5555
"husky": "^8.0.3",
5656
"prettier": "^2.8.8",
5757
"radash": "^12.1.0",
58-
"sass": "^1.62.1",
59-
"storybook": "^7.0.12",
58+
"sass-embedded": "^1.79.3",
59+
"storybook": "^7.6.20",
6060
"typescript": "^4.9.5",
6161
"unocss": "^0.51.13",
6262
"unplugin-auto-import": "^0.10.3",
6363
"unplugin-vue-components": "^0.24.1",
6464
"unplugin-vue-router": "^0.6.4",
65-
"vite": "^4.3.5",
66-
"vite-plugin-pwa": "^0.16.4",
65+
"vite": "^4.5.5",
66+
"vite-plugin-pwa": "^0.16.7",
6767
"vitest": "^0.30.1",
68-
"vue-tsc": "^1.6.4"
69-
},
70-
"packageManager": "pnpm@9.1.4+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0"
68+
"vue-tsc": "^1.8.27"
69+
}
7170
}

0 commit comments

Comments
 (0)