Skip to content

Commit

Permalink
Merge pull request #849 from EstrellaXD/3.1-dev
Browse files Browse the repository at this point in the history
3.1.15
  • Loading branch information
EstrellaXD authored Sep 23, 2024
2 parents 7913061 + d5b84b9 commit 07bb7f2
Show file tree
Hide file tree
Showing 38 changed files with 5,386 additions and 6,424 deletions.
2 changes: 1 addition & 1 deletion backend/src/module/api/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@router.on_event("startup")
async def startup():
program.startup()
await program.startup()


@router.on_event("shutdown")
Expand Down
44 changes: 20 additions & 24 deletions backend/src/module/core/program.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import asyncio

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

def startup(self):
async def startup(self):
self.__start_info()
if not self.database:
first_run()
Expand All @@ -49,32 +50,27 @@ def startup(self):
if not self.img_cache:
logger.info("[Core] No image cache exists, create image cache.")
cache_image()
self.start()
await self.start()

def start(self):
async def start(self):
self.stop_event.clear()
settings.load()
if self.downloader_status:
if self.enable_renamer:
self.rename_start()
if self.enable_rss:
self.rss_start()
logger.info("Program running.")
return ResponseModel(
status=True,
status_code=200,
msg_en="Program started.",
msg_zh="程序启动成功。",
)
else:
self.stop_event.set()
logger.warning("Program failed to start.")
return ResponseModel(
status=False,
status_code=406,
msg_en="Program failed to start.",
msg_zh="程序启动失败。",
)
while not self.downloader_status:
logger.warning("Downloader is not running.")
logger.info("Waiting for downloader to start.")
await asyncio.sleep(30)
if self.enable_renamer:
self.rename_start()
if self.enable_rss:
self.rss_start()
logger.info("Program running.")
return ResponseModel(
status=True,
status_code=200,
msg_en="Program started.",
msg_zh="程序启动成功。",
)


def stop(self):
if self.is_running:
Expand Down
4 changes: 2 additions & 2 deletions backend/src/module/models/torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EpisodeFile(BaseModel):
group: str | None = Field(None)
title: str = Field(...)
season: int = Field(...)
episode: int = Field(None)
episode: int | float = Field(None)
suffix: str = Field(..., regex=r"\.(mkv|mp4|MKV|MP4)$")


Expand All @@ -32,6 +32,6 @@ class SubtitleFile(BaseModel):
group: str | None = Field(None)
title: str = Field(...)
season: int = Field(...)
episode: int = Field(None)
episode: int | float = Field(None)
language: str = Field(..., regex=r"(zh|zh-tw)")
suffix: str = Field(..., regex=r"\.(ass|srt|ASS|SRT)$")
4 changes: 3 additions & 1 deletion backend/src/module/network/request_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ class RequestContent(RequestURL):
def get_torrents(
self,
_url: str,
_filter: str = "|".join(settings.rss_parser.filter),
_filter: str = None,
limit: int = None,
retry: int = 3,
) -> list[Torrent]:
soup = self.get_xml(_url, retry)
if soup:
torrent_titles, torrent_urls, torrent_homepage = rss_parser(soup)
torrents: list[Torrent] = []
if _filter is None:
_filter = "|".join(settings.rss_parser.filter)
for _title, torrent_url, homepage in zip(
torrent_titles, torrent_urls, torrent_homepage
):
Expand Down
1 change: 1 addition & 0 deletions backend/src/module/parser/analyser/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def _prepare_params(self, text: str, prompt: str) -> dict[str, Any]:
dict(role="system", content=prompt),
dict(role="user", content=text),
],

# set temperature to 0 to make results be more stable and reproducible.
temperature=0,
)
Expand Down
2 changes: 1 addition & 1 deletion backend/src/module/parser/analyser/raw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def clean_sub(sub: str | None) -> str | None:


def process(raw_title: str):
raw_title = raw_title.strip().replace("\n", "")
raw_title = raw_title.strip().replace("\n", " ")
content_title = pre_process(raw_title)
# 预处理标题
group = get_group(content_title)
Expand Down
30 changes: 24 additions & 6 deletions backend/src/module/parser/analyser/torrent_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
PLATFORM = "Unix"

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

SUBTITLE_LANG = {
Expand Down Expand Up @@ -81,7 +81,7 @@ def torrent_parser(
title, season = get_season_and_title(title)
else:
title, _ = get_season_and_title(title)
episode = int(match_obj.group(2))
episode = match_obj.group(2)
suffix = Path(torrent_path).suffix
if file_type == "media":
return EpisodeFile(
Expand All @@ -103,3 +103,21 @@ def torrent_parser(
episode=episode,
suffix=suffix,
)


if __name__ == "__main__":
ep = torrent_parser(
"/不时用俄语小声说真心话的邻桌艾莉同学/Season 1/不时用俄语小声说真心话的邻桌艾莉同学 S01E02.mp4"
)
print(ep)

ep = torrent_parser(
"/downloads/Bangumi/关于我转生变成史莱姆这档事 (2018)/Season 3/[ANi] 關於我轉生變成史萊姆這檔事 第三季 - 48.5 [1080P][Baha][WEB-DL][AAC AVC][CHT].mp4"
)
print(ep)

ep = torrent_parser(
"/downloads/Bangumi/关于我转生变成史莱姆这档事 (2018)/Season 3/[ANi] 關於我轉生變成史萊姆這檔事 第三季 - 48.5 [1080P][Baha][WEB-DL][AAC AVC][CHT].srt",
file_type="subtitle",
)
print(ep)
20 changes: 20 additions & 0 deletions backend/src/test/test_raw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@


def test_raw_parser():
# Issue #794, RSS link: https://mikanani.me/RSS/Bangumi?bangumiId=3367&subgroupid=370
content = "[喵萌奶茶屋&LoliHouse] 鹿乃子乃子乃子虎视眈眈 / Shikanoko Nokonoko Koshitantan\n- 01 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕]"
info = raw_parser(content)
assert info.group == "喵萌奶茶屋&LoliHouse"
assert info.title_zh == "鹿乃子乃子乃子虎视眈眈"
assert info.title_en == "Shikanoko Nokonoko Koshitantan"
assert info.resolution == "1080p"
assert info.episode == 1
assert info.season == 1

# Issue #679, RSS link: https://mikanani.me/RSS/Bangumi?bangumiId=3225&subgroupid=370
content = "[LoliHouse] 轮回七次的反派大小姐,在前敌国享受随心所欲的新婚生活\n / 7th Time Loop - 12 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕][END]"
info = raw_parser(content)
assert info.group == "LoliHouse"
assert info.title_zh == "轮回七次的反派大小姐,在前敌国享受随心所欲的新婚生活"
assert info.title_en == "7th Time Loop"
assert info.resolution == "1080p"
assert info.episode == 12
assert info.season == 1

content = "【幻樱字幕组】【4月新番】【古见同学有交流障碍症 第二季 Komi-san wa, Komyushou Desu. S02】【22】【GB_MP4】【1920X1080】"
info = raw_parser(content)
assert info.title_en == "Komi-san wa, Komyushou Desu."
Expand Down
19 changes: 19 additions & 0 deletions backend/src/test/test_torrent_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ def test_torrent_parser():
assert bf.season == 1
assert bf.episode == 6

file_name = "不时用俄语小声说真心话的邻桌艾莉同学 S01E02.mp4"
bf = torrent_parser(file_name)
assert bf.title == "不时用俄语小声说真心话的邻桌艾莉同学"
assert bf.season == 1
assert bf.episode == 2

file_name = "[ANi] 關於我轉生變成史萊姆這檔事 第三季 - 48.5 [1080P][Baha][WEB-DL][AAC AVC][CHT].mp4"
bf = torrent_parser(file_name, season=3)
assert bf.title == "關於我轉生變成史萊姆這檔事 第三季"
assert bf.season == 3
assert bf.episode == 48.5

file_name = "[ANi] 關於我轉生變成史萊姆這檔事 第三季 - 48.5 [1080P][Baha][WEB-DL][AAC AVC][CHT].srt"
sf = torrent_parser(file_name, season=3, file_type="subtitle")
assert sf.title == "關於我轉生變成史萊姆這檔事 第三季"
assert sf.episode == 48.5
assert sf.season == 3
assert sf.language == "zh-tw"


class TestGetPathBasename:
def test_regular_path(self):
Expand Down
2 changes: 1 addition & 1 deletion webui/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"i18n-ally.localesPaths": ["src/i18n"],
"commentTranslate.targetLanguage": "zh-CN",
"i18n-ally.sourceLanguage": "en",
"i18n-ally.sourceLanguage": "zh-CN",
"typescript.tsdk": "node_modules/typescript/lib",
"i18n-ally.keystyle": "nested"
}
59 changes: 29 additions & 30 deletions webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "module",
"version": "0.0.0",
"private": true,
"packageManager": "[email protected]+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
"scripts": {
"prepare": "cd .. && husky install ./webui/.husky",
"test:build": "vue-tsc --noEmit",
Expand All @@ -19,53 +20,51 @@
"generate-pwa-assets": "pwa-assets-generator --preset minimal public/images/logo.svg"
},
"dependencies": {
"@headlessui/vue": "^1.7.13",
"@vueuse/components": "^10.4.1",
"@vueuse/core": "^8.9.4",
"@headlessui/vue": "^1.7.23",
"@vueuse/components": "^10.11.1",
"@vueuse/core": "^10.11.1",
"axios": "^0.27.2",
"naive-ui": "^2.34.4",
"pinia": "^2.1.3",
"rxjs": "^7.8.1",
"vue": "^3.3.4",
"vue-i18n": "^9.2.2",
"vue-inline-svg": "^3.1.2",
"vue-router": "^4.2.1"
"naive-ui": "^2.39.0",
"pinia": "^2.2.2",
"vue": "^3.5.8",
"vue-i18n": "^9.14.0",
"vue-inline-svg": "^3.1.4",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@antfu/eslint-config": "^0.38.6",
"@icon-park/vue-next": "^1.4.2",
"@intlify/unplugin-vue-i18n": "^0.11.0",
"@storybook/addon-essentials": "^7.0.12",
"@storybook/addon-interactions": "^7.0.12",
"@storybook/addon-links": "^7.0.12",
"@storybook/blocks": "^7.0.12",
"@storybook/addon-essentials": "^7.6.20",
"@storybook/addon-interactions": "^7.6.20",
"@storybook/addon-links": "^7.6.20",
"@storybook/blocks": "^7.6.20",
"@storybook/testing-library": "0.0.14-next.2",
"@storybook/vue3": "^7.0.12",
"@storybook/vue3-vite": "^7.0.12",
"@types/node": "^18.16.14",
"@unocss/preset-attributify": "^0.55.3",
"@storybook/vue3": "^7.6.20",
"@storybook/vue3-vite": "^7.6.20",
"@types/node": "^18.19.50",
"@unocss/preset-attributify": "^0.55.7",
"@unocss/preset-rem-to-px": "^0.51.13",
"@unocss/reset": "^0.51.13",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue": "^4.6.2",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/runtime-dom": "^3.3.4",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-storybook": "^0.6.12",
"@vue/runtime-dom": "^3.5.8",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-storybook": "^0.6.15",
"husky": "^8.0.3",
"prettier": "^2.8.8",
"radash": "^12.1.0",
"sass": "^1.62.1",
"storybook": "^7.0.12",
"sass-embedded": "^1.79.3",
"storybook": "^7.6.20",
"typescript": "^4.9.5",
"unocss": "^0.51.13",
"unplugin-auto-import": "^0.10.3",
"unplugin-vue-components": "^0.24.1",
"unplugin-vue-router": "^0.6.4",
"vite": "^4.3.5",
"vite-plugin-pwa": "^0.16.4",
"vite": "^4.5.5",
"vite-plugin-pwa": "^0.16.7",
"vitest": "^0.30.1",
"vue-tsc": "^1.6.4"
},
"packageManager": "[email protected]+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0"
"vue-tsc": "^1.8.27"
}
}
Loading

0 comments on commit 07bb7f2

Please sign in to comment.