From 58bff6cbdc84aefdeb255394fcf00c407905fab9 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Wed, 28 Jun 2023 16:15:17 +0800 Subject: [PATCH 1/8] refactor: refactor folder as 3.1 --- .dockerignore | 8 +- .gitignore | 20 ++--- Dockerfile | 4 +- backend/.pre-commit-config.yaml | 8 ++ backend/pyproject.toml | 63 +++++++++++++++ .../docker/etc/cont-init.d/010-old-compatible | 0 .../src}/docker/etc/cont-init.d/020-fixuser | 0 .../docker/etc/services.d/auto_bangumi/finish | 0 .../services.d/auto_bangumi/notification-fd | 0 .../docker/etc/services.d/auto_bangumi/run | 0 {src => backend/src}/icon | 0 {src => backend/src}/main.py | 0 {src => backend/src}/module/__init__.py | 0 .../src}/module/ab_decorator/__init__.py | 3 +- {src => backend/src}/module/api/__init__.py | 0 {src => backend/src}/module/api/auth.py | 9 +-- {src => backend/src}/module/api/bangumi.py | 5 +- {src => backend/src}/module/api/config.py | 0 {src => backend/src}/module/api/download.py | 0 {src => backend/src}/module/api/log.py | 0 {src => backend/src}/module/api/program.py | 0 {src => backend/src}/module/api/proxy.py | 0 {src => backend/src}/module/api/web.py | 0 .../src}/module/checker/__init__.py | 0 .../src}/module/checker/checker.py | 0 {src => backend/src}/module/conf/__init__.py | 0 {src => backend/src}/module/conf/config.py | 0 {src => backend/src}/module/conf/const.py | 0 {src => backend/src}/module/conf/log.py | 0 {src => backend/src}/module/conf/parse.py | 0 .../src}/module/conf/uvicorn_logging.py | 0 {src => backend/src}/module/core/__init__.py | 0 {src => backend/src}/module/core/program.py | 0 {src => backend/src}/module/core/rss_feed.py | 0 {src => backend/src}/module/core/status.py | 0 .../src}/module/core/sub_thread.py | 0 .../src}/module/database/__init__.py | 0 .../src}/module/database/bangumi.py | 12 ++- .../src}/module/database/connector.py | 25 ++++-- .../src}/module/database/torrent.py | 0 {src => backend/src}/module/database/user.py | 0 .../src}/module/downloader/__init__.py | 0 .../src}/module/downloader/client/__init__.py | 0 .../downloader/client/aria2_downloader.py | 0 .../module/downloader/client/qb_downloader.py | 6 +- .../module/downloader/client/tr_downloader.py | 0 .../src}/module/downloader/exceptions.py | 0 .../src}/module/downloader/path.py | 0 .../src}/module/manager/__init__.py | 0 .../src}/module/manager/collector.py | 10 ++- .../src}/module/manager/renamer.py | 13 ++- .../src}/module/manager/torrent.py | 80 ++++++++++++------- .../src}/module/models/__init__.py | 0 {src => backend/src}/module/models/api.py | 0 {src => backend/src}/module/models/bangumi.py | 0 {src => backend/src}/module/models/config.py | 0 {src => backend/src}/module/models/torrent.py | 0 {src => backend/src}/module/models/user.py | 0 .../src}/module/network/__init__.py | 0 .../src}/module/network/request_contents.py | 6 +- .../src}/module/network/request_url.py | 8 +- backend/src/module/network/site/__init__.py | 1 + .../src}/module/network/site/mikan.py | 2 +- backend/src/module/notification/__init__.py | 1 + .../src}/module/notification/notification.py | 3 +- .../module/notification/plugin/__init__.py | 2 +- .../src}/module/notification/plugin/bark.py | 0 .../module/notification/plugin/server_chan.py | 0 .../src}/module/notification/plugin/slack.py | 2 +- .../module/notification/plugin/telegram.py | 0 .../src}/module/notification/plugin/wecom.py | 8 +- .../src}/module/parser/__init__.py | 0 .../src}/module/parser/analyser/__init__.py | 0 .../src}/module/parser/analyser/bgm_parser.py | 0 .../module/parser/analyser/tmdb_parser.py | 38 ++++++--- .../module/parser/analyser/torrent_parser.py | 0 {src => backend/src}/module/parser/openai.py | 0 .../src}/module/parser/title_parser.py | 0 {src => backend/src}/module/rss/__init__.py | 0 {src => backend/src}/module/rss/analyser.py | 8 +- {src => backend/src}/module/rss/filter.py | 0 {src => backend/src}/module/rss/searcher.py | 0 .../src}/module/searcher/__init__.py | 0 .../src}/module/searcher/plugin/__init__.py | 0 .../src}/module/searcher/plugin/mikan.py | 0 .../src}/module/searcher/searcher.py | 9 ++- .../src}/module/security/__init__.py | 0 {src => backend/src}/module/security/api.py | 0 {src => backend/src}/module/security/jwt.py | 0 .../src}/module/update/__init__.py | 0 .../src}/module/update/data_migration.py | 0 {src => backend/src}/module/utils/__init__.py | 0 .../src}/module/utils/bangumi_data.py | 0 .../src}/module/utils/json_config.py | 0 {src => backend/src}/test/__init__.py | 0 {src => backend/src}/test/test_raw_parser.py | 1 - .../src}/test/test_torrent_parser.py | 0 docs/wiki | 2 +- pyrightconfig.json | 8 ++ src/module/network/site/__init__.py | 1 - src/module/notification/__init__.py | 1 - 101 files changed, 252 insertions(+), 115 deletions(-) create mode 100644 backend/.pre-commit-config.yaml create mode 100644 backend/pyproject.toml rename {src => backend/src}/docker/etc/cont-init.d/010-old-compatible (100%) rename {src => backend/src}/docker/etc/cont-init.d/020-fixuser (100%) rename {src => backend/src}/docker/etc/services.d/auto_bangumi/finish (100%) rename {src => backend/src}/docker/etc/services.d/auto_bangumi/notification-fd (100%) rename {src => backend/src}/docker/etc/services.d/auto_bangumi/run (100%) rename {src => backend/src}/icon (100%) rename {src => backend/src}/main.py (100%) rename {src => backend/src}/module/__init__.py (100%) rename {src => backend/src}/module/ab_decorator/__init__.py (97%) rename {src => backend/src}/module/api/__init__.py (100%) rename {src => backend/src}/module/api/auth.py (90%) rename {src => backend/src}/module/api/bangumi.py (96%) rename {src => backend/src}/module/api/config.py (100%) rename {src => backend/src}/module/api/download.py (100%) rename {src => backend/src}/module/api/log.py (100%) rename {src => backend/src}/module/api/program.py (100%) rename {src => backend/src}/module/api/proxy.py (100%) rename {src => backend/src}/module/api/web.py (100%) rename {src => backend/src}/module/checker/__init__.py (100%) rename {src => backend/src}/module/checker/checker.py (100%) rename {src => backend/src}/module/conf/__init__.py (100%) rename {src => backend/src}/module/conf/config.py (100%) rename {src => backend/src}/module/conf/const.py (100%) rename {src => backend/src}/module/conf/log.py (100%) rename {src => backend/src}/module/conf/parse.py (100%) rename {src => backend/src}/module/conf/uvicorn_logging.py (100%) rename {src => backend/src}/module/core/__init__.py (100%) rename {src => backend/src}/module/core/program.py (100%) rename {src => backend/src}/module/core/rss_feed.py (100%) rename {src => backend/src}/module/core/status.py (100%) rename {src => backend/src}/module/core/sub_thread.py (100%) rename {src => backend/src}/module/database/__init__.py (100%) rename {src => backend/src}/module/database/bangumi.py (95%) rename {src => backend/src}/module/database/connector.py (89%) rename {src => backend/src}/module/database/torrent.py (100%) rename {src => backend/src}/module/database/user.py (100%) rename {src => backend/src}/module/downloader/__init__.py (100%) rename {src => backend/src}/module/downloader/client/__init__.py (100%) rename {src => backend/src}/module/downloader/client/aria2_downloader.py (100%) rename {src => backend/src}/module/downloader/client/qb_downloader.py (96%) rename {src => backend/src}/module/downloader/client/tr_downloader.py (100%) rename {src => backend/src}/module/downloader/exceptions.py (100%) rename {src => backend/src}/module/downloader/path.py (100%) rename {src => backend/src}/module/manager/__init__.py (100%) rename {src => backend/src}/module/manager/collector.py (88%) rename {src => backend/src}/module/manager/renamer.py (95%) rename {src => backend/src}/module/manager/torrent.py (65%) rename {src => backend/src}/module/models/__init__.py (100%) rename {src => backend/src}/module/models/api.py (100%) rename {src => backend/src}/module/models/bangumi.py (100%) rename {src => backend/src}/module/models/config.py (100%) rename {src => backend/src}/module/models/torrent.py (100%) rename {src => backend/src}/module/models/user.py (100%) rename {src => backend/src}/module/network/__init__.py (100%) rename {src => backend/src}/module/network/request_contents.py (93%) rename {src => backend/src}/module/network/request_url.py (92%) create mode 100644 backend/src/module/network/site/__init__.py rename {src => backend/src}/module/network/site/mikan.py (84%) create mode 100644 backend/src/module/notification/__init__.py rename {src => backend/src}/module/notification/notification.py (95%) rename {src => backend/src}/module/notification/plugin/__init__.py (77%) rename {src => backend/src}/module/notification/plugin/bark.py (100%) rename {src => backend/src}/module/notification/plugin/server_chan.py (100%) rename {src => backend/src}/module/notification/plugin/slack.py (95%) rename {src => backend/src}/module/notification/plugin/telegram.py (100%) rename {src => backend/src}/module/notification/plugin/wecom.py (87%) rename {src => backend/src}/module/parser/__init__.py (100%) rename {src => backend/src}/module/parser/analyser/__init__.py (100%) rename {src => backend/src}/module/parser/analyser/bgm_parser.py (100%) rename {src => backend/src}/module/parser/analyser/tmdb_parser.py (69%) rename {src => backend/src}/module/parser/analyser/torrent_parser.py (100%) rename {src => backend/src}/module/parser/openai.py (100%) rename {src => backend/src}/module/parser/title_parser.py (100%) rename {src => backend/src}/module/rss/__init__.py (100%) rename {src => backend/src}/module/rss/analyser.py (93%) rename {src => backend/src}/module/rss/filter.py (100%) rename {src => backend/src}/module/rss/searcher.py (100%) rename {src => backend/src}/module/searcher/__init__.py (100%) rename {src => backend/src}/module/searcher/plugin/__init__.py (100%) rename {src => backend/src}/module/searcher/plugin/mikan.py (100%) rename {src => backend/src}/module/searcher/searcher.py (87%) rename {src => backend/src}/module/security/__init__.py (100%) rename {src => backend/src}/module/security/api.py (100%) rename {src => backend/src}/module/security/jwt.py (100%) rename {src => backend/src}/module/update/__init__.py (100%) rename {src => backend/src}/module/update/data_migration.py (100%) rename {src => backend/src}/module/utils/__init__.py (100%) rename {src => backend/src}/module/utils/bangumi_data.py (100%) rename {src => backend/src}/module/utils/json_config.py (100%) rename {src => backend/src}/test/__init__.py (100%) rename {src => backend/src}/test/test_raw_parser.py (99%) rename {src => backend/src}/test/test_torrent_parser.py (100%) create mode 100644 pyrightconfig.json delete mode 100644 src/module/network/site/__init__.py delete mode 100644 src/module/notification/__init__.py diff --git a/.dockerignore b/.dockerignore index 94a64c67..595cb0a5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -19,8 +19,8 @@ coverage.xml ../.pytest_cache .hypothesis -src/module/tests -src/module/conf/const_dev.py +backend/src/module/tests +backend/src/module/conf/const_dev.py config/bangumi.json/config/bangumi.json /docs /.github @@ -33,8 +33,8 @@ config/bangumi.json/config/bangumi.json dist.zip data config -/src/config -/src/data +/backend/src/config +/backend/src/data .pytest_cache test .env diff --git a/.gitignore b/.gitignore index f6222a65..2fba0a13 100644 --- a/.gitignore +++ b/.gitignore @@ -162,18 +162,18 @@ cython_debug/ #.idea/ # Custom -/src/test.py +/backend/src/test.py -/src/module/run_debug.sh -/src/module/debug_run.sh -/src/module/__version__.py -/src/data/ +/backend/src/module/run_debug.sh +/backend/src/module/debug_run.sh +/backend/src/module/__version__.py +/backend/src/data/ -/src/module/conf/config_dev.ini +/backend/src/module/conf/config_dev.ini test.* .run -/src/templates/ -/src/config/ -/src/debuger.py -/src/dist.zip +/backend/src/templates/ +/backend/src/config/ +/backend/src/debuger.py +/backend/src/dist.zip diff --git a/Dockerfile b/Dockerfile index 7f58121f..dd4d7534 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,8 +45,8 @@ RUN apk add --no-cache \ /root/.cache \ /tmp/* -COPY --chmod=755 src/. . -COPY --chmod=755 src/docker / +COPY --chmod=755 backend/src/. . +COPY --chmod=755 backend/src/docker / ENTRYPOINT [ "/init" ] diff --git a/backend/.pre-commit-config.yaml b/backend/.pre-commit-config.yaml new file mode 100644 index 00000000..daecff1d --- /dev/null +++ b/backend/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: +- repo: https://github.com/psf/black + rev: 22.10.0 + hooks: + - id: black + language: python + +# TODO: add ruff lint check before committing \ No newline at end of file diff --git a/backend/pyproject.toml b/backend/pyproject.toml new file mode 100644 index 00000000..8342c4b9 --- /dev/null +++ b/backend/pyproject.toml @@ -0,0 +1,63 @@ +[tool.ruff] +select = [ + # pycodestyle(E): https://beta.ruff.rs/docs/rules/#pycodestyle-e-w + "E", + # Pyflakes(F): https://beta.ruff.rs/docs/rules/#pyflakes-f + "F", + # isort(I): https://beta.ruff.rs/docs/rules/#isort-i + "I" +] +ignore = [ + # E501: https://beta.ruff.rs/docs/rules/line-too-long/ + 'E501', + # F401: https://beta.ruff.rs/docs/rules/unused-import/ + # avoid unused imports lint in `__init__.py` + 'F401', +] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"] +unfixable = [] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] +per-file-ignores = {} + +# Same as Black. +line-length = 88 + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +# Assume Python 3.10. +target-version = "py310" + +[tool.ruff.mccabe] +# Unlike Flake8, default to a complexity level of 10. +max-complexity = 10 + +[tool.black] +line-length = 88 +target-version = ['py310', 'py311'] diff --git a/src/docker/etc/cont-init.d/010-old-compatible b/backend/src/docker/etc/cont-init.d/010-old-compatible similarity index 100% rename from src/docker/etc/cont-init.d/010-old-compatible rename to backend/src/docker/etc/cont-init.d/010-old-compatible diff --git a/src/docker/etc/cont-init.d/020-fixuser b/backend/src/docker/etc/cont-init.d/020-fixuser similarity index 100% rename from src/docker/etc/cont-init.d/020-fixuser rename to backend/src/docker/etc/cont-init.d/020-fixuser diff --git a/src/docker/etc/services.d/auto_bangumi/finish b/backend/src/docker/etc/services.d/auto_bangumi/finish similarity index 100% rename from src/docker/etc/services.d/auto_bangumi/finish rename to backend/src/docker/etc/services.d/auto_bangumi/finish diff --git a/src/docker/etc/services.d/auto_bangumi/notification-fd b/backend/src/docker/etc/services.d/auto_bangumi/notification-fd similarity index 100% rename from src/docker/etc/services.d/auto_bangumi/notification-fd rename to backend/src/docker/etc/services.d/auto_bangumi/notification-fd diff --git a/src/docker/etc/services.d/auto_bangumi/run b/backend/src/docker/etc/services.d/auto_bangumi/run similarity index 100% rename from src/docker/etc/services.d/auto_bangumi/run rename to backend/src/docker/etc/services.d/auto_bangumi/run diff --git a/src/icon b/backend/src/icon similarity index 100% rename from src/icon rename to backend/src/icon diff --git a/src/main.py b/backend/src/main.py similarity index 100% rename from src/main.py rename to backend/src/main.py diff --git a/src/module/__init__.py b/backend/src/module/__init__.py similarity index 100% rename from src/module/__init__.py rename to backend/src/module/__init__.py diff --git a/src/module/ab_decorator/__init__.py b/backend/src/module/ab_decorator/__init__.py similarity index 97% rename from src/module/ab_decorator/__init__.py rename to backend/src/module/ab_decorator/__init__.py index f25a083b..3c29c227 100644 --- a/src/module/ab_decorator/__init__.py +++ b/backend/src/module/ab_decorator/__init__.py @@ -38,4 +38,5 @@ def locked(func): def wrapper(*args, **kwargs): with lock: return func(*args, **kwargs) - return wrapper \ No newline at end of file + + return wrapper diff --git a/src/module/api/__init__.py b/backend/src/module/api/__init__.py similarity index 100% rename from src/module/api/__init__.py rename to backend/src/module/api/__init__.py diff --git a/src/module/api/auth.py b/backend/src/module/api/auth.py similarity index 90% rename from src/module/api/auth.py rename to backend/src/module/api/auth.py index bbea2090..de255dd3 100644 --- a/src/module/api/auth.py +++ b/backend/src/module/api/auth.py @@ -19,9 +19,7 @@ async def login(form_data: OAuth2PasswordRequestForm = Depends()): username = form_data.username password = form_data.password auth_user(username, password) - token = create_access_token( - data={"sub": username}, expires_delta=timedelta(days=1) - ) + token = create_access_token(data={"sub": username}, expires_delta=timedelta(days=1)) return {"access_token": token, "token_type": "bearer", "expire": 86400} @@ -32,10 +30,7 @@ async def refresh(current_user: User = Depends(get_current_user)): raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token" ) - token = create_access_token( - data = {"sub": current_user.username} - - ) + token = create_access_token(data={"sub": current_user.username}) return {"access_token": token, "token_type": "bearer", "expire": 86400} diff --git a/src/module/api/bangumi.py b/backend/src/module/api/bangumi.py similarity index 96% rename from src/module/api/bangumi.py rename to backend/src/module/api/bangumi.py index 94c77c7f..611e9c43 100644 --- a/src/module/api/bangumi.py +++ b/backend/src/module/api/bangumi.py @@ -11,6 +11,7 @@ from module.security import get_current_user logger = logging.getLogger(__name__) + @router.get( "/api/v1/bangumi/getAll", tags=["bangumi"], response_model=list[BangumiData] ) @@ -50,7 +51,9 @@ async def update_rule(data: BangumiData, current_user=Depends(get_current_user)) @router.delete("/api/v1/bangumi/deleteRule/{bangumi_id}", tags=["bangumi"]) -async def delete_rule(bangumi_id: str, file: bool = False, current_user=Depends(get_current_user)): +async def delete_rule( + bangumi_id: str, file: bool = False, current_user=Depends(get_current_user) +): if not current_user: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token" diff --git a/src/module/api/config.py b/backend/src/module/api/config.py similarity index 100% rename from src/module/api/config.py rename to backend/src/module/api/config.py diff --git a/src/module/api/download.py b/backend/src/module/api/download.py similarity index 100% rename from src/module/api/download.py rename to backend/src/module/api/download.py diff --git a/src/module/api/log.py b/backend/src/module/api/log.py similarity index 100% rename from src/module/api/log.py rename to backend/src/module/api/log.py diff --git a/src/module/api/program.py b/backend/src/module/api/program.py similarity index 100% rename from src/module/api/program.py rename to backend/src/module/api/program.py diff --git a/src/module/api/proxy.py b/backend/src/module/api/proxy.py similarity index 100% rename from src/module/api/proxy.py rename to backend/src/module/api/proxy.py diff --git a/src/module/api/web.py b/backend/src/module/api/web.py similarity index 100% rename from src/module/api/web.py rename to backend/src/module/api/web.py diff --git a/src/module/checker/__init__.py b/backend/src/module/checker/__init__.py similarity index 100% rename from src/module/checker/__init__.py rename to backend/src/module/checker/__init__.py diff --git a/src/module/checker/checker.py b/backend/src/module/checker/checker.py similarity index 100% rename from src/module/checker/checker.py rename to backend/src/module/checker/checker.py diff --git a/src/module/conf/__init__.py b/backend/src/module/conf/__init__.py similarity index 100% rename from src/module/conf/__init__.py rename to backend/src/module/conf/__init__.py diff --git a/src/module/conf/config.py b/backend/src/module/conf/config.py similarity index 100% rename from src/module/conf/config.py rename to backend/src/module/conf/config.py diff --git a/src/module/conf/const.py b/backend/src/module/conf/const.py similarity index 100% rename from src/module/conf/const.py rename to backend/src/module/conf/const.py diff --git a/src/module/conf/log.py b/backend/src/module/conf/log.py similarity index 100% rename from src/module/conf/log.py rename to backend/src/module/conf/log.py diff --git a/src/module/conf/parse.py b/backend/src/module/conf/parse.py similarity index 100% rename from src/module/conf/parse.py rename to backend/src/module/conf/parse.py diff --git a/src/module/conf/uvicorn_logging.py b/backend/src/module/conf/uvicorn_logging.py similarity index 100% rename from src/module/conf/uvicorn_logging.py rename to backend/src/module/conf/uvicorn_logging.py diff --git a/src/module/core/__init__.py b/backend/src/module/core/__init__.py similarity index 100% rename from src/module/core/__init__.py rename to backend/src/module/core/__init__.py diff --git a/src/module/core/program.py b/backend/src/module/core/program.py similarity index 100% rename from src/module/core/program.py rename to backend/src/module/core/program.py diff --git a/src/module/core/rss_feed.py b/backend/src/module/core/rss_feed.py similarity index 100% rename from src/module/core/rss_feed.py rename to backend/src/module/core/rss_feed.py diff --git a/src/module/core/status.py b/backend/src/module/core/status.py similarity index 100% rename from src/module/core/status.py rename to backend/src/module/core/status.py diff --git a/src/module/core/sub_thread.py b/backend/src/module/core/sub_thread.py similarity index 100% rename from src/module/core/sub_thread.py rename to backend/src/module/core/sub_thread.py diff --git a/src/module/database/__init__.py b/backend/src/module/database/__init__.py similarity index 100% rename from src/module/database/__init__.py rename to backend/src/module/database/__init__.py diff --git a/src/module/database/bangumi.py b/backend/src/module/database/bangumi.py similarity index 95% rename from src/module/database/bangumi.py rename to backend/src/module/database/bangumi.py index 1c49938b..0ba1ce92 100644 --- a/src/module/database/bangumi.py +++ b/backend/src/module/database/bangumi.py @@ -160,9 +160,13 @@ class BangumiDatabase(DataConnector): if match_data.get("title_raw") in torrent.name: if rss_link not in match_data.get("rss_link"): match_data["rss_link"] += f",{rss_link}" - self.update_rss(match_data.get("title_raw"), match_data.get("rss_link")) + self.update_rss( + match_data.get("title_raw"), match_data.get("rss_link") + ) if not match_data.get("poster_link"): - self.update_poster(match_data.get("title_raw"), torrent.poster_link) + self.update_poster( + match_data.get("title_raw"), torrent.poster_link + ) torrent_list.pop(i) break else: @@ -217,7 +221,7 @@ class BangumiDatabase(DataConnector): return False -if __name__ == '__main__': +if __name__ == "__main__": with BangumiDatabase() as db: name = "久保" - print(db.match_poster(name)) \ No newline at end of file + print(db.match_poster(name)) diff --git a/src/module/database/connector.py b/backend/src/module/database/connector.py similarity index 89% rename from src/module/database/connector.py rename to backend/src/module/database/connector.py index 751a6355..d4dbea56 100644 --- a/src/module/database/connector.py +++ b/backend/src/module/database/connector.py @@ -100,10 +100,14 @@ class DataConnector: def _delete(self, table_name: str, condition: dict): condition_sql = " AND ".join([f"{key} = :{key}" for key in condition.keys()]) - self._cursor.execute(f"DELETE FROM {table_name} WHERE {condition_sql}", condition) + self._cursor.execute( + f"DELETE FROM {table_name} WHERE {condition_sql}", condition + ) self._conn.commit() - def _search(self, table_name: str, keys: list[str] | None = None, condition: dict = None): + def _search( + self, table_name: str, keys: list[str] | None = None, condition: dict = None + ): if keys is None: select_sql = "*" else: @@ -112,20 +116,25 @@ class DataConnector: self._cursor.execute(f"SELECT {select_sql} FROM {table_name}") else: custom_condition = condition.pop("_custom_condition", None) - condition_sql = " AND ".join([f"{key} = :{key}" for key in condition.keys()]) + ( - f" AND {custom_condition}" if custom_condition else "" - ) + condition_sql = " AND ".join( + [f"{key} = :{key}" for key in condition.keys()] + ) + (f" AND {custom_condition}" if custom_condition else "") self._cursor.execute( - f"SELECT {select_sql} FROM {table_name} WHERE {condition_sql}", condition + f"SELECT {select_sql} FROM {table_name} WHERE {condition_sql}", + condition, ) - def _search_data(self, table_name: str, keys: list[str] | None = None, condition: dict = None) -> dict: + def _search_data( + self, table_name: str, keys: list[str] | None = None, condition: dict = None + ) -> dict: if keys is None: keys = self.__get_table_columns(table_name) self._search(table_name, keys, condition) return dict(zip(keys, self._cursor.fetchone())) - def _search_datas(self, table_name: str, keys: list[str] | None = None, condition: dict = None) -> list[dict]: + def _search_datas( + self, table_name: str, keys: list[str] | None = None, condition: dict = None + ) -> list[dict]: if keys is None: keys = self.__get_table_columns(table_name) self._search(table_name, keys, condition) diff --git a/src/module/database/torrent.py b/backend/src/module/database/torrent.py similarity index 100% rename from src/module/database/torrent.py rename to backend/src/module/database/torrent.py diff --git a/src/module/database/user.py b/backend/src/module/database/user.py similarity index 100% rename from src/module/database/user.py rename to backend/src/module/database/user.py diff --git a/src/module/downloader/__init__.py b/backend/src/module/downloader/__init__.py similarity index 100% rename from src/module/downloader/__init__.py rename to backend/src/module/downloader/__init__.py diff --git a/src/module/downloader/client/__init__.py b/backend/src/module/downloader/client/__init__.py similarity index 100% rename from src/module/downloader/client/__init__.py rename to backend/src/module/downloader/client/__init__.py diff --git a/src/module/downloader/client/aria2_downloader.py b/backend/src/module/downloader/client/aria2_downloader.py similarity index 100% rename from src/module/downloader/client/aria2_downloader.py rename to backend/src/module/downloader/client/aria2_downloader.py diff --git a/src/module/downloader/client/qb_downloader.py b/backend/src/module/downloader/client/qb_downloader.py similarity index 96% rename from src/module/downloader/client/qb_downloader.py rename to backend/src/module/downloader/client/qb_downloader.py index fc5b622e..5ddedec2 100644 --- a/src/module/downloader/client/qb_downloader.py +++ b/backend/src/module/downloader/client/qb_downloader.py @@ -78,7 +78,9 @@ class QbDownloader: @qb_connect_failed_wait def torrents_info(self, status_filter, category, tag=None): - return self._client.torrents_info(status_filter=status_filter, category=category, tag=tag) + return self._client.torrents_info( + status_filter=status_filter, category=category, tag=tag + ) def torrents_add(self, urls, save_path, category, torrent_files=None): resp = self._client.torrents_add( @@ -87,7 +89,7 @@ class QbDownloader: torrent_files=torrent_files, save_path=save_path, category=category, - use_auto_torrent_management=False + use_auto_torrent_management=False, ) return resp == "Ok." diff --git a/src/module/downloader/client/tr_downloader.py b/backend/src/module/downloader/client/tr_downloader.py similarity index 100% rename from src/module/downloader/client/tr_downloader.py rename to backend/src/module/downloader/client/tr_downloader.py diff --git a/src/module/downloader/exceptions.py b/backend/src/module/downloader/exceptions.py similarity index 100% rename from src/module/downloader/exceptions.py rename to backend/src/module/downloader/exceptions.py diff --git a/src/module/downloader/path.py b/backend/src/module/downloader/path.py similarity index 100% rename from src/module/downloader/path.py rename to backend/src/module/downloader/path.py diff --git a/src/module/manager/__init__.py b/backend/src/module/manager/__init__.py similarity index 100% rename from src/module/manager/__init__.py rename to backend/src/module/manager/__init__.py diff --git a/src/module/manager/collector.py b/backend/src/module/manager/collector.py similarity index 88% rename from src/module/manager/collector.py rename to backend/src/module/manager/collector.py index cff45d3f..86524221 100644 --- a/src/module/manager/collector.py +++ b/backend/src/module/manager/collector.py @@ -34,8 +34,12 @@ class SeasonCollector(DownloadClient): torrents = st.get_torrents(link, _filter="|".join(data.filter)) torrent_files = None if proxy: - torrent_files = [st.get_content(torrent.torrent_link) for torrent in torrents] - return self.add_season_torrents(data=data, torrents=torrents, torrent_files=torrent_files) + torrent_files = [ + st.get_content(torrent.torrent_link) for torrent in torrents + ] + return self.add_season_torrents( + data=data, torrents=torrents, torrent_files=torrent_files + ) def subscribe_season(self, data: BangumiData): with BangumiDatabase() as db: @@ -57,5 +61,3 @@ def eps_complete(): sc.collect_season(data) data.eps_collect = True bd.update_list(datas) - - diff --git a/src/module/manager/renamer.py b/backend/src/module/manager/renamer.py similarity index 95% rename from src/module/manager/renamer.py rename to backend/src/module/manager/renamer.py index 6cfc9b8b..9b04d145 100644 --- a/src/module/manager/renamer.py +++ b/backend/src/module/manager/renamer.py @@ -38,9 +38,7 @@ class Renamer(DownloadClient): elif method == "advance": return f"{bangumi_name} S{season}E{episode}{file_info.suffix}" elif method == "normal": - logger.warning( - "[Renamer] Normal rename method is deprecated." - ) + logger.warning("[Renamer] Normal rename method is deprecated.") return file_info.media_path elif method == "subtitle_pn": return f"{file_info.title} S{season}E{episode}.{file_info.language}{file_info.suffix}" @@ -73,10 +71,10 @@ class Renamer(DownloadClient): ) if renamed: n = Notification( - official_title=bangumi_name, - season=ep.season, - episode=ep.episode, - ) + official_title=bangumi_name, + season=ep.season, + episode=ep.episode, + ) return n else: logger.warning(f"[Renamer] {media_path} parse failed") @@ -178,6 +176,7 @@ class Renamer(DownloadClient): if __name__ == "__main__": from module.conf import setup_logger + settings.log.debug_enable = True setup_logger() with Renamer() as renamer: diff --git a/src/module/manager/torrent.py b/backend/src/module/manager/torrent.py similarity index 65% rename from src/module/manager/torrent.py rename to backend/src/module/manager/torrent.py index 6d43be6f..a11bb899 100644 --- a/src/module/manager/torrent.py +++ b/backend/src/module/manager/torrent.py @@ -14,7 +14,9 @@ class TorrentManager(BangumiDatabase): def __match_torrents_list(data: BangumiData) -> list: with DownloadClient() as client: torrents = client.get_torrent_info(status_filter=None) - return [torrent.hash for torrent in torrents if torrent.save_path == data.save_path] + return [ + torrent.hash for torrent in torrents if torrent.save_path == data.save_path + ] def delete_torrents(self, data: BangumiData, client: DownloadClient): hash_list = self.__match_torrents_list(data) @@ -34,17 +36,21 @@ class TorrentManager(BangumiDatabase): self.delete_one(int(_id)) if file: torrent_message = self.delete_torrents(data, client) - return JSONResponse(status_code=200, content={ - "msg": f"Delete {data.official_title} rule. {torrent_message}" - }) + return JSONResponse( + status_code=200, + content={ + "msg": f"Delete {data.official_title} rule. {torrent_message}" + }, + ) logger.info(f"[Manager] Delete rule for {data.official_title}") - return JSONResponse(status_code=200, content={ - "msg": f"Delete rule for {data.official_title}" - }) + return JSONResponse( + status_code=200, + content={"msg": f"Delete rule for {data.official_title}"}, + ) else: - return JSONResponse(status_code=406, content={ - "msg": f"Can't find id {_id}" - }) + return JSONResponse( + status_code=406, content={"msg": f"Can't find id {_id}"} + ) def disable_rule(self, _id: str | int, file: bool = False): data = self.search_id(int(_id)) @@ -55,17 +61,23 @@ class TorrentManager(BangumiDatabase): self.update_one(data) if file: torrent_message = self.delete_torrents(data, client) - return JSONResponse(status_code=200, content={ - "msg": f"Disable {data.official_title} rule. {torrent_message}" - }) + return JSONResponse( + status_code=200, + content={ + "msg": f"Disable {data.official_title} rule. {torrent_message}" + }, + ) logger.info(f"[Manager] Disable rule for {data.official_title}") - return JSONResponse(status_code=200, content={ - "msg": f"Disable {data.official_title} rule.", - }) + return JSONResponse( + status_code=200, + content={ + "msg": f"Disable {data.official_title} rule.", + }, + ) else: - return JSONResponse(status_code=406, content={ - "msg": f"Can't find id {_id}" - }) + return JSONResponse( + status_code=406, content={"msg": f"Can't find id {_id}"} + ) def enable_rule(self, _id: str | int): data = self.search_id(int(_id)) @@ -75,21 +87,24 @@ class TorrentManager(BangumiDatabase): with DownloadClient() as client: client.set_rule(data) logger.info(f"[Manager] Enable rule for {data.official_title}") - return JSONResponse(status_code=200, content={ - "msg": f"Enable {data.official_title} rule.", - }) + return JSONResponse( + status_code=200, + content={ + "msg": f"Enable {data.official_title} rule.", + }, + ) else: - return JSONResponse(status_code=406, content={ - "msg": f"Can't find bangumi id {_id}" - }) + return JSONResponse( + status_code=406, content={"msg": f"Can't find bangumi id {_id}"} + ) def update_rule(self, data: BangumiData): old_data = self.search_id(data.id) if not old_data: logger.error(f"[Manager] Can't find data with {data.id}") - return JSONResponse(status_code=406, content={ - "msg": f"Can't find data with {data.id}" - }) + return JSONResponse( + status_code=406, content={"msg": f"Can't find data with {data.id}"} + ) else: # Move torrent match_list = self.__match_torrents_list(data) @@ -101,9 +116,12 @@ class TorrentManager(BangumiDatabase): client.remove_rule(data.rule_name) client.set_rule(data) self.update_one(data) - return JSONResponse(status_code=200, content={ - "msg": f"Set new path for {data.official_title}", - }) + return JSONResponse( + status_code=200, + content={ + "msg": f"Set new path for {data.official_title}", + }, + ) def search_all_bangumi(self): datas = self.search_all() diff --git a/src/module/models/__init__.py b/backend/src/module/models/__init__.py similarity index 100% rename from src/module/models/__init__.py rename to backend/src/module/models/__init__.py diff --git a/src/module/models/api.py b/backend/src/module/models/api.py similarity index 100% rename from src/module/models/api.py rename to backend/src/module/models/api.py diff --git a/src/module/models/bangumi.py b/backend/src/module/models/bangumi.py similarity index 100% rename from src/module/models/bangumi.py rename to backend/src/module/models/bangumi.py diff --git a/src/module/models/config.py b/backend/src/module/models/config.py similarity index 100% rename from src/module/models/config.py rename to backend/src/module/models/config.py diff --git a/src/module/models/torrent.py b/backend/src/module/models/torrent.py similarity index 100% rename from src/module/models/torrent.py rename to backend/src/module/models/torrent.py diff --git a/src/module/models/user.py b/backend/src/module/models/user.py similarity index 100% rename from src/module/models/user.py rename to backend/src/module/models/user.py diff --git a/src/module/network/__init__.py b/backend/src/module/network/__init__.py similarity index 100% rename from src/module/network/__init__.py rename to backend/src/module/network/__init__.py diff --git a/src/module/network/request_contents.py b/backend/src/module/network/request_contents.py similarity index 93% rename from src/module/network/request_contents.py rename to backend/src/module/network/request_contents.py index 0c2096b6..77c074df 100644 --- a/src/module/network/request_contents.py +++ b/backend/src/module/network/request_contents.py @@ -51,7 +51,11 @@ class RequestContent(RequestURL): torrent_titles, torrent_urls, torrent_homepage ): if re.search(_filter, _title) is None: - torrents.append(TorrentInfo(name=_title, torrent_link=torrent_url, homepage=homepage)) + torrents.append( + TorrentInfo( + name=_title, torrent_link=torrent_url, homepage=homepage + ) + ) return torrents except ConnectionError: return [] diff --git a/src/module/network/request_url.py b/backend/src/module/network/request_url.py similarity index 92% rename from src/module/network/request_url.py rename to backend/src/module/network/request_url.py index 16da3d4c..f4b65e7d 100644 --- a/src/module/network/request_url.py +++ b/backend/src/module/network/request_url.py @@ -23,7 +23,9 @@ class RequestURL: req.raise_for_status() return req except requests.RequestException: - logger.warning(f"[Network] Cannot connect to {url}. Wait for 5 seconds.") + logger.warning( + f"[Network] Cannot connect to {url}. Wait for 5 seconds." + ) try_time += 1 if try_time >= retry: break @@ -45,7 +47,9 @@ class RequestURL: req.raise_for_status() return req except requests.RequestException: - logger.warning(f"[Network] Cannot connect to {url}. Wait for 5 seconds.") + logger.warning( + f"[Network] Cannot connect to {url}. Wait for 5 seconds." + ) try_time += 1 if try_time >= retry: break diff --git a/backend/src/module/network/site/__init__.py b/backend/src/module/network/site/__init__.py new file mode 100644 index 00000000..70f16f74 --- /dev/null +++ b/backend/src/module/network/site/__init__.py @@ -0,0 +1 @@ +from .mikan import mikan_parser diff --git a/src/module/network/site/mikan.py b/backend/src/module/network/site/mikan.py similarity index 84% rename from src/module/network/site/mikan.py rename to backend/src/module/network/site/mikan.py index 5a326925..0ad4314b 100644 --- a/src/module/network/site/mikan.py +++ b/backend/src/module/network/site/mikan.py @@ -6,4 +6,4 @@ def mikan_parser(soup): torrent_titles.append(item.find("title").text) torrent_urls.append(item.find("enclosure").attrib["url"]) torrent_homepage.append(item.find("link").text) - return torrent_titles, torrent_urls, torrent_homepage \ No newline at end of file + return torrent_titles, torrent_urls, torrent_homepage diff --git a/backend/src/module/notification/__init__.py b/backend/src/module/notification/__init__.py new file mode 100644 index 00000000..e6a713ae --- /dev/null +++ b/backend/src/module/notification/__init__.py @@ -0,0 +1 @@ +from .notification import PostNotification diff --git a/src/module/notification/notification.py b/backend/src/module/notification/notification.py similarity index 95% rename from src/module/notification/notification.py rename to backend/src/module/notification/notification.py index a59230b7..a4bd7c72 100644 --- a/src/module/notification/notification.py +++ b/backend/src/module/notification/notification.py @@ -27,8 +27,7 @@ class PostNotification: def __init__(self): Notifier = getClient(settings.notification.type) self.notifier = Notifier( - token=settings.notification.token, - chat_id=settings.notification.chat_id + token=settings.notification.token, chat_id=settings.notification.chat_id ) @staticmethod diff --git a/src/module/notification/plugin/__init__.py b/backend/src/module/notification/plugin/__init__.py similarity index 77% rename from src/module/notification/plugin/__init__.py rename to backend/src/module/notification/plugin/__init__.py index ece03d58..e9acda8f 100644 --- a/src/module/notification/plugin/__init__.py +++ b/backend/src/module/notification/plugin/__init__.py @@ -1,4 +1,4 @@ from .bark import BarkNotification from .server_chan import ServerChanNotification from .telegram import TelegramNotification -from .wecom import WecomNotification \ No newline at end of file +from .wecom import WecomNotification diff --git a/src/module/notification/plugin/bark.py b/backend/src/module/notification/plugin/bark.py similarity index 100% rename from src/module/notification/plugin/bark.py rename to backend/src/module/notification/plugin/bark.py diff --git a/src/module/notification/plugin/server_chan.py b/backend/src/module/notification/plugin/server_chan.py similarity index 100% rename from src/module/notification/plugin/server_chan.py rename to backend/src/module/notification/plugin/server_chan.py diff --git a/src/module/notification/plugin/slack.py b/backend/src/module/notification/plugin/slack.py similarity index 95% rename from src/module/notification/plugin/slack.py rename to backend/src/module/notification/plugin/slack.py index af4a0d83..f4da8a2d 100644 --- a/src/module/notification/plugin/slack.py +++ b/backend/src/module/notification/plugin/slack.py @@ -24,4 +24,4 @@ class SlackNotification(RequestContent): data = {"title": notify.official_title, "body": text, "device_key": self.token} resp = self.post_data(self.notification_url, data) logger.debug(f"Bark notification: {resp.status_code}") - return resp.status_code == 200 \ No newline at end of file + return resp.status_code == 200 diff --git a/src/module/notification/plugin/telegram.py b/backend/src/module/notification/plugin/telegram.py similarity index 100% rename from src/module/notification/plugin/telegram.py rename to backend/src/module/notification/plugin/telegram.py diff --git a/src/module/notification/plugin/wecom.py b/backend/src/module/notification/plugin/wecom.py similarity index 87% rename from src/module/notification/plugin/wecom.py rename to backend/src/module/notification/plugin/wecom.py index 11a63a75..dbd906c4 100644 --- a/src/module/notification/plugin/wecom.py +++ b/backend/src/module/notification/plugin/wecom.py @@ -11,7 +11,7 @@ class WecomNotification(RequestContent): def __init__(self, token, chat_id, **kwargs): super().__init__() - #Chat_id is used as noti_url in this push tunnel + # Chat_id is used as noti_url in this push tunnel self.notification_url = f"{chat_id}" self.token = token @@ -27,15 +27,15 @@ class WecomNotification(RequestContent): title = "【番剧更新】" + notify.official_title msg = self.gen_message(notify) picurl = notify.poster_path - #Default pic to avoid blank in message. Resolution:1068*455 + # Default pic to avoid blank in message. Resolution:1068*455 if picurl == "https://mikanani.me": picurl = "https://article.biliimg.com/bfs/article/d8bcd0408bf32594fd82f27de7d2c685829d1b2e.png" data = { - "key":self.token, + "key": self.token, "type": "news", "title": title, "msg": msg, - "picurl":picurl + "picurl": picurl, } resp = self.post_data(self.notification_url, data) logger.debug(f"Wecom notification: {resp.status_code}") diff --git a/src/module/parser/__init__.py b/backend/src/module/parser/__init__.py similarity index 100% rename from src/module/parser/__init__.py rename to backend/src/module/parser/__init__.py diff --git a/src/module/parser/analyser/__init__.py b/backend/src/module/parser/analyser/__init__.py similarity index 100% rename from src/module/parser/analyser/__init__.py rename to backend/src/module/parser/analyser/__init__.py diff --git a/src/module/parser/analyser/bgm_parser.py b/backend/src/module/parser/analyser/bgm_parser.py similarity index 100% rename from src/module/parser/analyser/bgm_parser.py rename to backend/src/module/parser/analyser/bgm_parser.py diff --git a/src/module/parser/analyser/tmdb_parser.py b/backend/src/module/parser/analyser/tmdb_parser.py similarity index 69% rename from src/module/parser/analyser/tmdb_parser.py rename to backend/src/module/parser/analyser/tmdb_parser.py index b3d206c3..7762c95a 100644 --- a/src/module/parser/analyser/tmdb_parser.py +++ b/backend/src/module/parser/analyser/tmdb_parser.py @@ -16,16 +16,14 @@ class TMDBInfo: year: str -LANGUAGE = { - "zh": "zh-CN", - "jp": "ja-JP", - "en": "en-US" -} +LANGUAGE = {"zh": "zh-CN", "jp": "ja-JP", "en": "en-US"} -search_url = lambda e: \ - f"https://api.themoviedb.org/3/search/tv?api_key={TMDB_API}&page=1&query={e}&include_adult=false" -info_url = lambda e, key: \ - f"https://api.themoviedb.org/3/tv/{e}?api_key={TMDB_API}&language={LANGUAGE[key]}" +search_url = ( + lambda e: f"https://api.themoviedb.org/3/search/tv?api_key={TMDB_API}&page=1&query={e}&include_adult=false" +) +info_url = ( + lambda e, key: f"https://api.themoviedb.org/3/tv/{e}?api_key={TMDB_API}&language={LANGUAGE[key]}" +) def is_animation(tv_id, language) -> bool: @@ -43,7 +41,7 @@ def get_season(seasons: list) -> int: for season in ss: if re.search(r"第 \d 季", season.get("season")) is not None: date = season.get("air_date").split("-") - [year, _ , _] = date + [year, _, _] = date now_year = time.localtime().tm_year if int(year) <= now_year: return int(re.findall(r"\d", season.get("season"))[0]) @@ -64,16 +62,30 @@ def tmdb_parser(title, language) -> TMDBInfo | None: break url_info = info_url(id, language) info_content = req.get_json(url_info) - season = [{"season": s.get("name"), "air_date": s.get("air_date"), "poster_path": s.get("poster_path")} for s in info_content.get("seasons")] + season = [ + { + "season": s.get("name"), + "air_date": s.get("air_date"), + "poster_path": s.get("poster_path"), + } + for s in info_content.get("seasons") + ] last_season = get_season(season) original_title = info_content.get("original_name") official_title = info_content.get("name") year_number = info_content.get("first_air_date").split("-")[0] - return TMDBInfo(id, official_title, original_title, season, last_season, str(year_number)) + return TMDBInfo( + id, + official_title, + original_title, + season, + last_season, + str(year_number), + ) else: return None -if __name__ == '__main__': +if __name__ == "__main__": title = "海盗战记" print(tmdb_parser(title, "zh").last_season) diff --git a/src/module/parser/analyser/torrent_parser.py b/backend/src/module/parser/analyser/torrent_parser.py similarity index 100% rename from src/module/parser/analyser/torrent_parser.py rename to backend/src/module/parser/analyser/torrent_parser.py diff --git a/src/module/parser/openai.py b/backend/src/module/parser/openai.py similarity index 100% rename from src/module/parser/openai.py rename to backend/src/module/parser/openai.py diff --git a/src/module/parser/title_parser.py b/backend/src/module/parser/title_parser.py similarity index 100% rename from src/module/parser/title_parser.py rename to backend/src/module/parser/title_parser.py diff --git a/src/module/rss/__init__.py b/backend/src/module/rss/__init__.py similarity index 100% rename from src/module/rss/__init__.py rename to backend/src/module/rss/__init__.py diff --git a/src/module/rss/analyser.py b/backend/src/module/rss/analyser.py similarity index 93% rename from src/module/rss/analyser.py rename to backend/src/module/rss/analyser.py index 9ae35b37..7cc52083 100644 --- a/src/module/rss/analyser.py +++ b/backend/src/module/rss/analyser.py @@ -61,7 +61,9 @@ class RSSAnalyser: logger.debug(f"[RSS] New title found: {data.official_title}") return new_data - def torrent_to_data(self, torrent: TorrentInfo, rss_link: str | None = None) -> BangumiData: + def torrent_to_data( + self, torrent: TorrentInfo, rss_link: str | None = None + ) -> BangumiData: data = self._title_analyser.raw_parser(raw=torrent.name, rss_link=rss_link) if data: try: @@ -75,7 +77,9 @@ class RSSAnalyser: self.official_title_parser(data, mikan_title) return data - def rss_to_data(self, rss_link: str, database: BangumiDatabase, full_parse: bool = True) -> list[BangumiData]: + def rss_to_data( + self, rss_link: str, database: BangumiDatabase, full_parse: bool = True + ) -> list[BangumiData]: rss_torrents = self.get_rss_torrents(rss_link, full_parse) torrents_to_add = database.match_list(rss_torrents, rss_link) if not torrents_to_add: diff --git a/src/module/rss/filter.py b/backend/src/module/rss/filter.py similarity index 100% rename from src/module/rss/filter.py rename to backend/src/module/rss/filter.py diff --git a/src/module/rss/searcher.py b/backend/src/module/rss/searcher.py similarity index 100% rename from src/module/rss/searcher.py rename to backend/src/module/rss/searcher.py diff --git a/src/module/searcher/__init__.py b/backend/src/module/searcher/__init__.py similarity index 100% rename from src/module/searcher/__init__.py rename to backend/src/module/searcher/__init__.py diff --git a/src/module/searcher/plugin/__init__.py b/backend/src/module/searcher/plugin/__init__.py similarity index 100% rename from src/module/searcher/plugin/__init__.py rename to backend/src/module/searcher/plugin/__init__.py diff --git a/src/module/searcher/plugin/mikan.py b/backend/src/module/searcher/plugin/mikan.py similarity index 100% rename from src/module/searcher/plugin/mikan.py rename to backend/src/module/searcher/plugin/mikan.py diff --git a/src/module/searcher/searcher.py b/backend/src/module/searcher/searcher.py similarity index 87% rename from src/module/searcher/searcher.py rename to backend/src/module/searcher/searcher.py index 621022eb..ad46f664 100644 --- a/src/module/searcher/searcher.py +++ b/backend/src/module/searcher/searcher.py @@ -13,7 +13,9 @@ SEARCH_KEY = [ class SearchTorrent(RequestContent): - def search_torrents(self, keywords: list[str], site: str = "mikan") -> list[TorrentBase]: + def search_torrents( + self, keywords: list[str], site: str = "mikan" + ) -> list[TorrentBase]: url = search_url(site, keywords) # TorrentInfo to TorrentBase torrents = self.get_torrents(url) @@ -25,6 +27,7 @@ class SearchTorrent(RequestContent): "torrent_link": torrent.torrent_link, "homepage": torrent.homepage, } + return [TorrentBase(**d) for d in to_dict()] def search_season(self, data: BangumiData): @@ -33,7 +36,7 @@ class SearchTorrent(RequestContent): return [torrent for torrent in torrents if data.title_raw in torrent.name] -if __name__ == '__main__': +if __name__ == "__main__": with SearchTorrent() as st: for t in st.search_torrents(["魔法科高校の劣等生"]): - print(t) \ No newline at end of file + print(t) diff --git a/src/module/security/__init__.py b/backend/src/module/security/__init__.py similarity index 100% rename from src/module/security/__init__.py rename to backend/src/module/security/__init__.py diff --git a/src/module/security/api.py b/backend/src/module/security/api.py similarity index 100% rename from src/module/security/api.py rename to backend/src/module/security/api.py diff --git a/src/module/security/jwt.py b/backend/src/module/security/jwt.py similarity index 100% rename from src/module/security/jwt.py rename to backend/src/module/security/jwt.py diff --git a/src/module/update/__init__.py b/backend/src/module/update/__init__.py similarity index 100% rename from src/module/update/__init__.py rename to backend/src/module/update/__init__.py diff --git a/src/module/update/data_migration.py b/backend/src/module/update/data_migration.py similarity index 100% rename from src/module/update/data_migration.py rename to backend/src/module/update/data_migration.py diff --git a/src/module/utils/__init__.py b/backend/src/module/utils/__init__.py similarity index 100% rename from src/module/utils/__init__.py rename to backend/src/module/utils/__init__.py diff --git a/src/module/utils/bangumi_data.py b/backend/src/module/utils/bangumi_data.py similarity index 100% rename from src/module/utils/bangumi_data.py rename to backend/src/module/utils/bangumi_data.py diff --git a/src/module/utils/json_config.py b/backend/src/module/utils/json_config.py similarity index 100% rename from src/module/utils/json_config.py rename to backend/src/module/utils/json_config.py diff --git a/src/test/__init__.py b/backend/src/test/__init__.py similarity index 100% rename from src/test/__init__.py rename to backend/src/test/__init__.py diff --git a/src/test/test_raw_parser.py b/backend/src/test/test_raw_parser.py similarity index 99% rename from src/test/test_raw_parser.py rename to backend/src/test/test_raw_parser.py index f09f1aae..b4c3b446 100644 --- a/src/test/test_raw_parser.py +++ b/backend/src/test/test_raw_parser.py @@ -69,4 +69,3 @@ def test_raw_parser(): assert info.resolution == "720P" assert info.episode == 5 assert info.season == 1 - diff --git a/src/test/test_torrent_parser.py b/backend/src/test/test_torrent_parser.py similarity index 100% rename from src/test/test_torrent_parser.py rename to backend/src/test/test_torrent_parser.py diff --git a/docs/wiki b/docs/wiki index d0bb98f0..519e381e 160000 --- a/docs/wiki +++ b/docs/wiki @@ -1 +1 @@ -Subproject commit d0bb98f004fb292519dd56c42238ecb2f034eac9 +Subproject commit 519e381e8a1add62e76a39181ee61bad02816035 diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 00000000..4521b494 --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,8 @@ +{ + "pythonPath": "/opt/homebrew/Caskroom/miniforge/base/envs/auto_bangumi/bin/python", + "root": "backend/src", + "venvPath": "/opt/homebrew/Caskroom/miniforge/base/envs", + "venv": "auto_bangumi", + "typeCheckingMode": "basic", + "reportMissingImports": true +} diff --git a/src/module/network/site/__init__.py b/src/module/network/site/__init__.py deleted file mode 100644 index 04b8a615..00000000 --- a/src/module/network/site/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .mikan import mikan_parser \ No newline at end of file diff --git a/src/module/notification/__init__.py b/src/module/notification/__init__.py deleted file mode 100644 index dbd1ac93..00000000 --- a/src/module/notification/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .notification import PostNotification \ No newline at end of file From ea698f4c5aa12b05fd1c4185d914c83b859b9f4b Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Wed, 28 Jun 2023 16:17:51 +0800 Subject: [PATCH 2/8] refactor: mv file from src to backend/src --- {src => backend/src}/module/downloader/download_client.py | 6 ++++-- {src => backend/src}/module/parser/analyser/raw_parser.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) rename {src => backend/src}/module/downloader/download_client.py (97%) rename {src => backend/src}/module/parser/analyser/raw_parser.py (99%) diff --git a/src/module/downloader/download_client.py b/backend/src/module/downloader/download_client.py similarity index 97% rename from src/module/downloader/download_client.py rename to backend/src/module/downloader/download_client.py index c30c1cd3..ca7cfbd9 100644 --- a/src/module/downloader/download_client.py +++ b/backend/src/module/downloader/download_client.py @@ -99,7 +99,9 @@ class DownloadClient(TorrentPath): logger.debug("[Downloader] Finished.") def get_torrent_info(self, category="Bangumi", status_filter="completed", tag=None): - return self.client.torrents_info(status_filter=status_filter, category=category, tag=tag) + return self.client.torrents_info( + status_filter=status_filter, category=category, tag=tag + ) def rename_torrent_file(self, _hash, old_path, new_path) -> bool: logger.info(f"{old_path} >> {new_path}") @@ -116,7 +118,7 @@ class DownloadClient(TorrentPath): urls=torrent.get("urls"), torrent_files=torrent.get("torrent_files"), save_path=torrent.get("save_path"), - category="Bangumi" + category="Bangumi", ): logger.debug(f"[Downloader] Add torrent: {torrent.get('save_path')}") return True diff --git a/src/module/parser/analyser/raw_parser.py b/backend/src/module/parser/analyser/raw_parser.py similarity index 99% rename from src/module/parser/analyser/raw_parser.py rename to backend/src/module/parser/analyser/raw_parser.py index 22ab8a38..5de06089 100644 --- a/src/module/parser/analyser/raw_parser.py +++ b/backend/src/module/parser/analyser/raw_parser.py @@ -181,6 +181,6 @@ def raw_parser(raw: str) -> Episode | None: ) -if __name__ == '__main__': +if __name__ == "__main__": title = "[动漫国字幕组&LoliHouse] THE MARGINAL SERVICE - 08 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕]" print(raw_parser(title)) From f28195eb609754b3076171b9148ac43f265127c8 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Wed, 28 Jun 2023 16:19:47 +0800 Subject: [PATCH 3/8] fix: ci --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 110b0185..fdd527da 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -22,7 +22,7 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install pytest - name: Test - working-directory: ./src + working-directory: ./backend/src run: | mkdir -p config pytest @@ -35,7 +35,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Create Version info - working-directory: ./src + working-directory: ./backend/src run: | echo "VERSION = '$GITHUB_REF_NAME'" > module/__version__.py From 8ab42bf3c9423dce45b9c00c05e10dcd7c16796f Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Thu, 29 Jun 2023 14:40:10 +0800 Subject: [PATCH 4/8] fix: fix #354 --- backend/src/module/parser/analyser/tmdb_parser.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/backend/src/module/parser/analyser/tmdb_parser.py b/backend/src/module/parser/analyser/tmdb_parser.py index 7762c95a..879dae68 100644 --- a/backend/src/module/parser/analyser/tmdb_parser.py +++ b/backend/src/module/parser/analyser/tmdb_parser.py @@ -37,7 +37,8 @@ def is_animation(tv_id, language) -> bool: def get_season(seasons: list) -> int: - ss = sorted(seasons, key=lambda e: e.get("air_date"), reverse=True) + ss = [s for s in seasons if s["air_date"] is not None] + ss = sorted(ss, key=lambda e: e.get("air_date"), reverse=True) for season in ss: if re.search(r"第 \d 季", season.get("season")) is not None: date = season.get("air_date").split("-") @@ -84,8 +85,3 @@ def tmdb_parser(title, language) -> TMDBInfo | None: ) else: return None - - -if __name__ == "__main__": - title = "海盗战记" - print(tmdb_parser(title, "zh").last_season) From cf8cd87de7787034a37d37da161ed89192bbcaf6 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Thu, 29 Jun 2023 14:46:04 +0800 Subject: [PATCH 5/8] fix: fix #345 --- backend/src/module/security/api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/module/security/api.py b/backend/src/module/security/api.py index 14282171..810ff15e 100644 --- a/backend/src/module/security/api.py +++ b/backend/src/module/security/api.py @@ -3,6 +3,7 @@ from fastapi.security import OAuth2PasswordBearer from .jwt import verify_token + from module.database.user import AuthDB from module.models.user import User @@ -14,7 +15,12 @@ async def get_current_user(token: str = Depends(oauth2_scheme)): raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token" ) - payload = verify_token(token) + try: + payload = verify_token(token) + except Exception: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token" + ) if not payload: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token" From 32a2f8bf03eb7d1e8c0e6d9a4e878bdbb6080aae Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Thu, 29 Jun 2023 17:38:03 +0800 Subject: [PATCH 6/8] change: update issue template --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/ISSUE_TEMPLATE/discussion.yml | 2 +- .github/ISSUE_TEMPLATE/feature_request.yml | 2 +- .github/ISSUE_TEMPLATE/rfc.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 14514ac3..3c4253bb 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,6 +1,6 @@ name: 问题反馈 description: File a bug report -title: "[错误报告] 请在此处简单描述你的问题" +title: "[错误报告]请在此处简单描述你的问题" labels: ["bug"] body: - type: markdown diff --git a/.github/ISSUE_TEMPLATE/discussion.yml b/.github/ISSUE_TEMPLATE/discussion.yml index 26f18ef6..6c50712c 100644 --- a/.github/ISSUE_TEMPLATE/discussion.yml +++ b/.github/ISSUE_TEMPLATE/discussion.yml @@ -1,6 +1,6 @@ name: 项目讨论 description: discussion -title: "[Discussion]: " +title: "[Discussion] " labels: ["discussion"] body: - type: markdown diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index bec710d0..c1572144 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,6 +1,6 @@ name: 功能改进 description: Feature Request -title: "[Feature Request]: " +title: "[Feature Request]" labels: ["feature request"] body: - type: markdown diff --git a/.github/ISSUE_TEMPLATE/rfc.yml b/.github/ISSUE_TEMPLATE/rfc.yml index 9df703ac..78b4790c 100644 --- a/.github/ISSUE_TEMPLATE/rfc.yml +++ b/.github/ISSUE_TEMPLATE/rfc.yml @@ -2,7 +2,7 @@ name: 功能提案 description: Request for Comments -title: "[RFC]: " +title: "[RFC]" labels: ["RFC"] body: - type: markdown From 8a990830b2b54debb2125e0719af0548f2ff255f Mon Sep 17 00:00:00 2001 From: Estrella Pan <33726646+EstrellaXD@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:29:01 +0800 Subject: [PATCH 7/8] Merge pull request #363 from zthxxx/main docs: add contributing docs (cherry picked from commit def02fb53e9096845bf3615e8c00c9a48e295f6c) --- .github/ISSUE_TEMPLATE/rfc.yml | 7 +- CONTRIBUTING.md | 180 +++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE/rfc.yml b/.github/ISSUE_TEMPLATE/rfc.yml index 78b4790c..6b3b8aad 100644 --- a/.github/ISSUE_TEMPLATE/rfc.yml +++ b/.github/ISSUE_TEMPLATE/rfc.yml @@ -9,13 +9,12 @@ body: attributes: value: | 一份提案(RFC)定位为 **「在某功能/重构的具体开发前,用于开发者间 review 技术设计/方案的文档」**, - 目的是让协作的开发者间清晰的知道「要做什么」和「具体会怎么做」, + 目的是让协作的开发者间清晰的知道「要做什么」和「具体会怎么做」,以及所有的开发者都能公开透明的参与讨论; 以便评估和讨论产生的影响 (遗漏的考虑、向后兼容性、与现有功能的冲突), 因此提案侧重在对解决问题的 **方案、设计、步骤** 的描述上。 - 如果仅希望讨论是否添加或 - 改进某功能本身,请使用 -> [Issue: 功能改进](https://github.com/EstrellaXD/Auto_Bangumi/issues/new?labels=feature+request&template=feature_request.yml&title=%5BFeature+Request%5D+) - + 如果仅希望讨论是否添加或改进某功能本身,请使用 -> [Issue: 功能改进](https://github.com/EstrellaXD/Auto_Bangumi/issues/new?labels=feature+request&template=feature_request.yml&title=%5BFeature+Request%5D+) + - type: textarea id: background attributes: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..3fa9266d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,180 @@ +# 贡献指南 Contributing + +我们欢迎各位 Contributors 参与贡献帮助 AutoBangumi 更好的解决大家遇到的问题, + +这篇指南会指导你如何为 AutoBangumi 贡献功能修复代码,可以在你要提出 Pull Request 之前花几分钟来阅读一遍这篇指南。 + +这篇文章包含什么? + +- [项目规划 Roadmap](#项目规划-roadmap) + - [提案寻求共识 Request for Comments](#提案寻求共识-request-for-comments) +- [分支管理 Git Branch](#分支管理-git-branch) + - [版本号](#版本号) + - [分支开发,主干发布](#分支开发主干发布) + - [Branch 生命周期](#branch-生命周期) + - [Git Workflow 一览](#git-workflow-一览) +- [Pull Request](#pull-request) +- [版本发布介绍](#版本发布介绍) + + +## 项目规划 Roadmap + +AutoBangumi 开发组使用 [GitHub Project](https://github.com/EstrellaXD/Auto_Bangumi/projects?query=is%3Aopen) 看板来管理预计开发的规划、在修复中的问题,以及它们处理的进度; + +这将帮助你更好的了解 +- 开发团队在做什么? +- 有什么和你想贡献的方向一致的,可以直接参与实现与优化 +- 有什么已经在进行中的,避免自己重复不必要的工作 + +在 [Project](https://github.com/EstrellaXD/Auto_Bangumi/projects?query=is%3Aopen) 中你可以看到除通常的 `[Feature Request]`, `[BUG]`, 一些小优化项以外,还有一类 **`[RFC]`**; + +### 提案寻求共识 Request for Comments + +> 在 issue 中通过 `RFC` label 能找到到现有的 [AutoBangumi RFCs](https://github.com/EstrellaXD/Auto_Bangumi/issues?q=is%3Aissue+label%3ARFC) + +对于一些小的优化项或者 bug 修复,你大可以直接帮忙调整代码然后提出 Pull Request,只需要简单阅读下 [分支管理](#分支管理-Git-Branch) 章节以基于正确的版本分支修复、以及通过 [Pull Request](#Pull-Request) 章节了解 PR 将如何被合并。 + +
+ +而如果你打算做的是一项**较大的**功能重构,改动范围大而涉及的方面比较多,那么希望你能通过 [Issue: 功能提案](https://github.com/EstrellaXD/Auto_Bangumi/issues/new?assignees=&labels=RFC&projects=&template=rfc.yml&title=%5BRFC%5D%3A+) 先写一份 RFC 提案来简单阐述「你打算怎么做」的简短方案,来寻求开发者的讨论和共识。 + +因为有些方案可能是开发团队原本讨论并且认为不要做的事,而上一步可以避免你浪费大量精力。 + +> 如果仅希望讨论是否添加或改进某功能本身,而非「要如何实现」,请使用 -> [Issue: 功能改进](https://github.com/EstrellaXD/Auto_Bangumi/issues/new?labels=feature+request&template=feature_request.yml&title=%5BFeature+Request%5D+) + + +
+ +一份 [提案(RFC)](https://github.com/EstrellaXD/Auto_Bangumi/issues?q=is%3Aissue+is%3Aopen+label%3ARFC) 定位为 **「在某功能/重构的具体开发前,用于开发者间 review 技术设计/方案的文档」**, + +目的是让协作的开发者间清晰的知道「要做什么」和「具体会怎么做」,以及所有的开发者都能公开透明的参与讨论; + +以便评估和讨论产生的影响 (遗漏的考虑、向后兼容性、与现有功能的冲突), + +因此提案侧重在对解决问题的 **方案、设计、步骤** 的描述上。 + + +## 分支管理 Git Branch + +### 版本号 + +AutoBangumi 项目中的 Git 分支使用与发布版本规则密切相关,因此先介绍版本规范; + +AutoBangumi 发布的版本号遵循 [「语义化版本 SemVer」](https://semver.org/lang/zh-CN/) 的规范, + +使用 `..` 三位版本的格式,每一位版本上的数字更新含义如下: + +- **Major**: 大版本更新,很可能有不兼容的 配置/API 修改 +- **Minor**: 向下兼容的功能性新增 +- **Patch**: 向下兼容的 Bug 修复 / 小优化修正 + +### 分支开发,主干发布 + +AutoBangumi 项目使用「分支开发,主干发布」的模式, + +[**`main`**](https://github.com/EstrellaXD/Auto_Bangumi/commits/main) 分支是稳定版本的 **「主干分支」**,只用于发布版本,不用于直接开发新功能或修复。 + +每一个 Minor 版本都有一个对应的 **「开发分支」** 用于开发新功能、与发布后维护修复问题, + +开发分支的名字为 `.-dev`,如 `3.1-dev`, `3.0-dev`, `2.6-dev`, 你可以在仓库的 [All Branches 中搜索到它们](https://github.com/EstrellaXD/Auto_Bangumi/branches/all?query=-dev)。 + + +### Branch 生命周期 + +当一个 Minor 开发分支(以 `3.1-dev` 为例) 完成新功能开发,**首次**合入 main 分支后, +- 发布 Minor 版本 (如 `3.1.0`) +- 同时拉出**下一个** Minor 开发分支(`3.2-dev`),用于下一个版本新功能开发 + - 而**上一个**版本开发分支(`3.0-dev`)进入归档不再维护 +- 且这个 Minor 分支(`3.1-dev`)进入维护阶段,不再增加新功能/重构,只维护 Bugs 修复 + - Bug 修复到维护阶段的 Minor 分支(`3.1-dev`)后,会再往 main 分支合并,并发布 `Patch` 版本 + +根据这个流程,对于各位 Contributors 在开发贡献时选择 Git Branch 来说,则是: +- 若「修复 Bug」,则基于**当前发布版本**的 Minor 分支开发修复,并 PR 到这个分支 +- 若「添加新功能/重构」,则基于**还未发布的下一个版本** Minor 分支开发,并 PR 到这个分支 + +> 「当前发布版本」为 [[Releases 页面]](https://github.com/EstrellaXD/Auto_Bangumi/releases) 最新版本,这也与 [[GitHub Container Registry]](https://github.com/EstrellaXD/Auto_Bangumi/pkgs/container/auto_bangumi) 中最新版本相同 + + +### Git Workflow 一览 + +> 图中 commit timeline 从左到右 ---> + +```mermaid +%%{init: {'theme': 'base', 'gitGraph': {'showCommitLabel': true}}}%% + +gitGraph: + checkout main + commit id: "." + branch 3.0-dev + commit id: "feat 1" + commit id: "feat 2" + commit id: "feat 3" + + checkout main + merge 3.0-dev tag: "3.0.9" + commit id: ".." + + branch 3.1-dev + commit id: "feat 4" + + checkout 3.0-dev + commit id: "PR merge (fix)" + checkout main + merge 3.0-dev tag: "3.0.10" + + checkout 3.1-dev + commit id: "feat 5" + commit id: "feat 6" + + checkout main + merge 3.1-dev tag: "3.1.0" + commit id: "..." + + branch 3.2-dev + commit id: "feat 7" + commit id: "feat 8" + + checkout 3.1-dev + commit id: "PR merge (fix) " + checkout main + merge 3.1-dev tag: "3.1.1" + + checkout 3.2-dev + commit id: "PR merge (feat)" +``` + + +## Pull Request + +请确保你根据上文的 Git 分支管理 章节选择了正确的 PR 目标分支, +> - 若「修复 Bug」,则 PR 到**当前发布版本**的 Minor 维护分支 +> - 若「添加新功能/重构」,则 PR **下一个版本** Minor 开发分支 + +
+ +- 一个 PR 应该只对应一件事,而不应引入不相关的更改; + + 对于不同的事情可以拆分提多个 PR,这能帮助开发组每次 review 只专注一个问题。 + +- 在提 PR 的标题与描述中,最好对修改内容做简短的说明,包括原因和意图, + + 如果有相关的 issue 或 RFC,应该把它们链接到 PR 描述中, + + 这将帮助开发组 code review 时能最快了解上下文。 + +- 确保勾选了「允许维护者编辑」(`Allow edits from maintainers`) 选项。这使我们可以直接进行较小的编辑/重构并节省大量时间。 + +- 请确保本地通过了「单元测试」和「代码风格 Lint」,这也会在 PR 的 GitHub CI 上检查 + - 对于 bug fix 和新功能,通常开发组也会请求你添加对应改动的单元测试覆盖 + + +开发组会在有时间的最快阶段 Review 贡献者提的 PR 并讨论或批准合并(Approve Merge)。 + +## 版本发布介绍 + +版本发布目前由开发组通过手动合并「特定发版 PR」后自动触发打包与发布。 + +通常 Bug 修复的 PR 合并后会很快发版,通常不到一周; + +而新功能的发版时间则会更长而且不定,你可以在我们的 [GitHub Project](https://github.com/EstrellaXD/Auto_Bangumi/projects?query=is%3Aopen) 看板中看到开发进度,一个版本规划的新功能都开发完备后就会发版。 + From a287b58770c4cf0961463f3341d1497f422f9699 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Fri, 30 Jun 2023 12:48:20 +0800 Subject: [PATCH 8/8] fix: poster match problem --- backend/src/module/database/bangumi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/module/database/bangumi.py b/backend/src/module/database/bangumi.py index 0ba1ce92..9d2a530c 100644 --- a/backend/src/module/database/bangumi.py +++ b/backend/src/module/database/bangumi.py @@ -132,7 +132,7 @@ class BangumiDatabase(DataConnector): data = self._cursor.execute( """ SELECT poster_link FROM bangumi - WHERE INSTR(official_title, :official_title) > 0 + WHERE INSTR(:official_title, official_title) > 0 """, {"official_title": bangumi_name}, ).fetchone() @@ -223,5 +223,5 @@ class BangumiDatabase(DataConnector): if __name__ == "__main__": with BangumiDatabase() as db: - name = "久保" + name = "久保同学不放过我(2023)" print(db.match_poster(name))