Skip to content

Commit f41d494

Browse files
committed
remove renamer interval
1 parent fb9d8ce commit f41d494

12 files changed

Lines changed: 62 additions & 49 deletions

File tree

CLAUDE.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,28 @@ This sets up a Python virtual environment, installs dependencies with Tsinghua m
1515
cd backend/src && python main.py
1616
```
1717

18+
**Frontend Development:**
19+
```bash
20+
cd webui && pnpm install && pnpm run dev # Development server
21+
cd webui && pnpm run build # Production build
22+
./build-frontend.sh # Build and move to backend/src/dist
23+
```
24+
1825
**Linting and Formatting:**
1926
```bash
2027
cd backend && ./venv/bin/ruff check .
2128
cd backend && ./venv/bin/ruff format .
2229
cd backend && ./venv/bin/black .
30+
cd webui && pnpm run lint # Frontend linting
31+
cd webui && pnpm run format # Frontend formatting
2332
```
2433

2534
**Testing:**
2635
```bash
2736
cd backend && ./venv/bin/pytest
2837
cd backend && ./venv/bin/pytest test/test_specific_module.py # Run specific test
38+
cd webui && pnpm run test # Frontend tests
39+
cd webui && pnpm run test:build # TypeScript type checking
2940
```
3041

3142
## Architecture
@@ -36,9 +47,9 @@ Auto_Bangumi is an RSS-based automatic anime downloading and organization tool w
3647
- `main.py`: FastAPI application entry point with poster serving and static file mounting
3748
- `module/core/`: Core async application framework
3849
- `aiocore.py`: AsyncApplicationCore manages service lifecycle and task scheduling
39-
- `services.py`: BaseService abstract class and service implementations (RSS, Download, Renamer)
50+
- `services/`: Service implementations extending BaseService (RSS, Download, Renamer)
51+
- `monitors/`: Background monitors for downloads, notifications, and renaming
4052
- `task_manager.py`: TaskManager handles async task scheduling and execution
41-
- `events.py`: Event system for inter-service communication
4253
- `module/api/`: REST API endpoints organized by feature (auth, bangumi, config, etc.)
4354
- `module/parser/`: Content parsing system for RSS feeds, torrents, and metadata
4455
- `module/downloader/`: Download client abstractions (qBittorrent, Aria2, Transmission)
@@ -48,9 +59,12 @@ Auto_Bangumi is an RSS-based automatic anime downloading and organization tool w
4859
- `module/network/`: HTTP client abstractions with proxy and caching support
4960

5061
**Frontend Structure (Vue.js + TypeScript):**
51-
- Located in `webui/` with standard Vue project structure
62+
- Located in `webui/` with Vite build system
63+
- Uses UnoCSS for styling, Naive UI for components
64+
- Auto-import configuration for Vue Composition API
5265
- API client in `src/api/` matching backend endpoints
53-
- Component-based UI with reusable elements in `src/components/`
66+
- Pinia for state management
67+
- Vue Router with file-based routing
5468

5569
**Key Data Flow:**
5670
1. RSS feeds are parsed and analyzed for anime information
@@ -65,8 +79,22 @@ The application uses an async service-based architecture where:
6579
- AsyncApplicationCore manages service lifecycle
6680
- TaskManager schedules periodic service execution
6781
- Services communicate via events system
82+
- Monitors handle background tasks like download tracking
6883

6984
**Configuration:**
7085
- Main config in `config/config.json`
7186
- Search providers in `config/search_provider.json`
72-
- Environment variables for runtime settings
87+
- Environment variables for runtime settings
88+
89+
## Development Guidelines
90+
91+
**Branch Strategy:**
92+
- `main`: Stable releases only
93+
- `<version>-dev`: Development branches for each minor version (e.g., `3.1-dev`)
94+
- Bug fixes go to current version dev branch
95+
- New features go to next version dev branch
96+
97+
**Code Style:**
98+
- Backend: Ruff + Black formatting, Python 3.10+ target
99+
- Frontend: ESLint + Prettier, TypeScript strict mode
100+
- Pre-commit hooks enforce formatting

backend/src/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def html(request: Request, path: str):
101101
return templates.TemplateResponse("index.html", context)
102102

103103
else:
104-
105104
@app.get("/", status_code=302, tags=["html"])
106105
def index():
107106
return RedirectResponse("/docs")

backend/src/module/core/aiocore.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ async def _register_tasks(self) -> None:
7777
async def _register_event_handlers(self) -> None:
7878
"""注册事件处理器"""
7979
try:
80-
# from module.downloader.download_monitor import download_monitor
81-
# from module.manager.rename_monitor import RenameMonitor
82-
# from module.notification import NotificationMonitor
83-
from module.utils.events import EventType
84-
8580
from .monitors import (
8681
NotificationMonitor,
8782
RenameMonitor,

backend/src/module/core/services/base_services.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def __init__(self, name: str | None = None):
2121
# 如果没有指定名称,使用类名自动生成
2222
if name is None:
2323
name = self.__class__.__name__.lower().replace("service", "")
24-
self.name = name
25-
self._initialized = False
24+
self.name:str = name
25+
self._initialized:bool = False
2626

2727
async def initialize(self) -> None:
2828
"""初始化服务"""

backend/src/module/core/services/download_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import TYPE_CHECKING, Any
44
from typing_extensions import override
55

6+
from module.downloader.download_queue import DownloadController
67
from module.utils.events import ServiceException
78
from .base_services import BaseService
89

@@ -12,7 +13,7 @@
1213
class DownloadService(BaseService):
1314
def __init__(self):
1415
super().__init__()
15-
self._download_controller = None
16+
self._download_controller:DownloadController|None = None
1617

1718
async def _setup(self) -> None:
1819
# 预检查下载模块是否可用
@@ -61,7 +62,7 @@ async def cleanup(self) -> None:
6162
from module.downloader import Client
6263

6364
await Client.stop()
64-
self._initialized = False
65+
self._initialized:bool = False
6566
logger.debug("[DownloadService] 下载客户端已重启")
6667
except Exception as e:
6768
logger.error(f"[DownloadService] 清理失败: {e}")

backend/src/module/core/services/renamer_service.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ def __init__(self):
2222
async def _setup(self) -> None:
2323
"""初始化重命名器"""
2424
self._renamer = Renamer()
25-
26-
async def initialize(self) -> None:
27-
await super().initialize()
2825
self.enable = settings.bangumi_manage.enable
2926

3027
def get_task_config(self) -> dict[str, Any]:

backend/src/module/core/services/rss_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from module.rss import RSSEngine
1313
logger = logging.getLogger(__name__)
1414

15+
1516
class RSSService(BaseService):
1617
def __init__(self):
1718
super().__init__()

backend/src/module/downloader/client/qbittorrent/qbittorrent.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,20 @@ class Downloader(BaseDownloader):
3838
def __init__(self): # , host: str, username: str, password: str, ssl: bool
3939
super().__init__()
4040
self._client: httpx.AsyncClient | None = None
41-
self.config: DownloaderConfig | None = None
42-
self.api_interval = 0.2
41+
self.config: DownloaderConfig = get_plugin_config(
42+
DownloaderConfig(), "downloader"
43+
)
44+
self.api_interval: float = 0.2
45+
self.ssl: bool = False
46+
self.host: str = ""
4347

4448
@override
4549
def initialize(self) -> None:
4650
"""初始化下载器"""
4751
# 加载配置
4852
self.config = get_plugin_config(DownloaderConfig(), "downloader")
49-
50-
# 初始化 HTTP 客户端
5153
self._client = httpx.AsyncClient(
52-
base_url=self.config.host, trust_env=settings.downloader.ssl
54+
base_url=self.config.host, verify=settings.downloader.ssl
5355
)
5456

5557
@override
@@ -88,6 +90,8 @@ async def logout(self):
8890
try:
8991
resp = await self._client.post(url=QB_API_URL["logout"], timeout=5)
9092
resp.raise_for_status()
93+
await self._client.aclose()
94+
self._client = None
9195
return True
9296
except httpx.ConnectError or httpx.TimeoutException as e:
9397
logger.error(f"[qbittorrent] Logout error: {e}")

backend/src/module/downloader/download_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def initialize(self):
127127

128128
# 初始化下载器
129129
self.downloader.initialize()
130-
131130
# 更新API间隔
132131
self.api_interval = self.downloader.api_interval
133132

backend/src/module/downloader/download_queue.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def add(self, torrent: Torrent, bangumi: Bangumi):
3232

3333
class DownloadController:
3434
def __init__(self):
35-
self._event_bus = event_bus
35+
self._event_bus:EventBus = event_bus
3636

3737
# 10秒拿5个
3838
async def download(self):
@@ -67,9 +67,6 @@ async def download(self):
6767
with Database(engine) as database:
6868
for torrent in torrents:
6969
database.torrent.add(torrent)
70-
logger.debug(
71-
f"[Download Controller] Torrent {torrent.name} {torrent.url=} 已保存到数据库"
72-
)
7370
for i, result in enumerate(results):
7471
torrent, bangumi = torrent_bangumi_pairs[i]
7572

0 commit comments

Comments
 (0)