Fix SeriesApp: Add missing class variable and clean up unused imports
This commit is contained in:
parent
4c9076af19
commit
00a68deb7b
@ -14,6 +14,7 @@ FastAPI automatically generates interactive API documentation that you can acces
|
||||
- **ReDoc**: `http://localhost:8000/redoc`
|
||||
|
||||
These interfaces allow you to:
|
||||
|
||||
- Browse all available endpoints
|
||||
- View request/response schemas
|
||||
- Test API endpoints directly from the browser
|
||||
@ -22,6 +23,7 @@ These interfaces allow you to:
|
||||
### OpenAPI Schema
|
||||
|
||||
The complete OpenAPI 3.0 schema is available at:
|
||||
|
||||
- **JSON Format**: `http://localhost:8000/openapi.json`
|
||||
|
||||
## Authentication
|
||||
@ -44,6 +46,7 @@ AniWorld uses a simple master password authentication system with JWT tokens.
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
@ -143,6 +146,7 @@ Currently, no rate limiting is implemented, but it may be added in future versio
|
||||
## WebSocket Support
|
||||
|
||||
Real-time updates are available through WebSocket connections for:
|
||||
|
||||
- Download progress updates
|
||||
- Scan progress updates
|
||||
- System status changes
|
||||
|
||||
26
README.md
26
README.md
@ -5,6 +5,7 @@ A powerful anime series management system that helps you track, organize, and do
|
||||
## 🚀 Features
|
||||
|
||||
### Core Functionality
|
||||
|
||||
- **Series Tracking**: Automatically detect missing episodes in your anime collection
|
||||
- **Smart Downloads**: Queue-based download system with progress tracking
|
||||
- **File Organization**: Automatic file scanning and folder structure management
|
||||
@ -12,12 +13,14 @@ A powerful anime series management system that helps you track, organize, and do
|
||||
- **Real-time Updates**: Live progress updates via WebSocket connections
|
||||
|
||||
### Web Interface
|
||||
|
||||
- **Modern UI**: Clean, responsive web interface with dark/light theme support
|
||||
- **Download Queue**: Visual download queue management
|
||||
- **Progress Tracking**: Real-time download and scan progress
|
||||
- **Mobile Support**: Fully responsive design for mobile devices
|
||||
|
||||
### API & Integration
|
||||
|
||||
- **FastAPI Backend**: High-performance async API with automatic documentation
|
||||
- **RESTful API**: Complete REST API for programmatic access
|
||||
- **OpenAPI Documentation**: Interactive API documentation at `/docs`
|
||||
@ -28,17 +31,20 @@ A powerful anime series management system that helps you track, organize, and do
|
||||
This project has been successfully migrated from Flask to FastAPI, bringing significant improvements:
|
||||
|
||||
### Performance Benefits
|
||||
|
||||
- **Async Support**: Native async/await for better concurrency
|
||||
- **Faster Response Times**: Up to 2-3x performance improvement
|
||||
- **Better Resource Utilization**: More efficient handling of concurrent requests
|
||||
|
||||
### Developer Experience
|
||||
|
||||
- **Automatic Documentation**: Built-in OpenAPI/Swagger documentation
|
||||
- **Type Safety**: Full request/response validation with Pydantic
|
||||
- **Modern Standards**: OpenAPI 3.0 compliance and JSON Schema validation
|
||||
- **Better Error Handling**: Structured error responses with detailed information
|
||||
|
||||
### API Improvements
|
||||
|
||||
- **Interactive Documentation**: Test API endpoints directly from `/docs`
|
||||
- **Schema Validation**: Automatic request/response validation
|
||||
- **Better Error Messages**: Detailed validation errors with field-level feedback
|
||||
@ -46,6 +52,7 @@ This project has been successfully migrated from Flask to FastAPI, bringing sign
|
||||
## 🛠️ Installation & Setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Python 3.11+
|
||||
- Conda package manager
|
||||
- Windows OS (currently optimized for Windows)
|
||||
@ -53,29 +60,34 @@ This project has been successfully migrated from Flask to FastAPI, bringing sign
|
||||
### Quick Start
|
||||
|
||||
1. **Clone the Repository**
|
||||
|
||||
```bash
|
||||
git clone <repository-url>
|
||||
cd Aniworld
|
||||
```
|
||||
|
||||
2. **Create and Activate Conda Environment**
|
||||
|
||||
```bash
|
||||
conda create -n AniWorld python=3.11
|
||||
conda activate AniWorld
|
||||
```
|
||||
|
||||
3. **Install Dependencies**
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
4. **Set Environment Variables**
|
||||
|
||||
```bash
|
||||
# Set your master password (will be hashed automatically)
|
||||
set MASTER_PASSWORD=your_secure_password
|
||||
```
|
||||
|
||||
5. **Start the FastAPI Server**
|
||||
|
||||
```bash
|
||||
# Development mode with auto-reload
|
||||
uvicorn src.server.fastapi_app:app --host 127.0.0.1 --port 8000 --reload
|
||||
@ -91,17 +103,20 @@ This project has been successfully migrated from Flask to FastAPI, bringing sign
|
||||
### Alternative: Using VS Code Tasks
|
||||
|
||||
If you're using VS Code, you can use the pre-configured tasks:
|
||||
|
||||
- `Ctrl+Shift+P` → "Tasks: Run Task" → "Run FastAPI Server"
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `MASTER_PASSWORD` - Your master password (will be hashed automatically)
|
||||
- `MASTER_PASSWORD_HASH` - Pre-hashed password (alternative to MASTER_PASSWORD)
|
||||
- `JWT_SECRET_KEY` - Secret key for JWT token signing (auto-generated if not set)
|
||||
- `LOG_LEVEL` - Logging level (DEBUG, INFO, WARNING, ERROR)
|
||||
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
Aniworld/
|
||||
├── src/
|
||||
@ -123,6 +138,7 @@ Aniworld/
|
||||
### Authentication
|
||||
|
||||
1. **Login to get JWT token**:
|
||||
|
||||
```bash
|
||||
curl -X POST "http://localhost:8000/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
@ -148,13 +164,16 @@ For complete API documentation, visit `/docs` when the server is running.
|
||||
## 🖥️ Web Interface
|
||||
|
||||
### Main Features
|
||||
|
||||
- **Dashboard**: Overview of your anime collection and missing episodes
|
||||
- **Search**: Find and add new anime series to track
|
||||
- **Downloads**: Manage download queue and monitor progress
|
||||
- **Settings**: Configure application preferences
|
||||
|
||||
### Responsive Design
|
||||
|
||||
The web interface is fully responsive and supports:
|
||||
|
||||
- Desktop browsers (Chrome, Firefox, Edge, Safari)
|
||||
- Mobile devices (iOS Safari, Android Chrome)
|
||||
- Tablet devices
|
||||
@ -165,11 +184,13 @@ The web interface is fully responsive and supports:
|
||||
### Common Issues
|
||||
|
||||
1. **Server won't start**
|
||||
|
||||
- Check that the AniWorld conda environment is activated
|
||||
- Verify all dependencies are installed: `pip install -r requirements.txt`
|
||||
- Check for port conflicts (default: 8000)
|
||||
|
||||
2. **Authentication errors**
|
||||
|
||||
- Verify the master password is set correctly
|
||||
- Check environment variables are properly configured
|
||||
- Clear browser cache/cookies
|
||||
@ -180,7 +201,9 @@ The web interface is fully responsive and supports:
|
||||
- Verify conda environment is activated
|
||||
|
||||
### Logs
|
||||
|
||||
Application logs are stored in the `logs/` directory:
|
||||
|
||||
- `aniworld.log` - General application logs
|
||||
- `errors.log` - Error-specific logs
|
||||
- `auth_failures.log` - Authentication failure logs
|
||||
@ -188,12 +211,14 @@ Application logs are stored in the `logs/` directory:
|
||||
## 🚦 Development
|
||||
|
||||
### Running in Development Mode
|
||||
|
||||
```bash
|
||||
# With auto-reload for development
|
||||
uvicorn src.server.fastapi_app:app --host 127.0.0.1 --port 8000 --reload --log-level debug
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
python -m pytest tests/ -v
|
||||
@ -203,6 +228,7 @@ python -m pytest tests/ --cov=src --cov-report=html
|
||||
```
|
||||
|
||||
### Code Quality
|
||||
|
||||
```bash
|
||||
# Format code
|
||||
black src/
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
from src.core.SerieScanner import SerieScanner
|
||||
from src.core.entities.SerieList import SerieList
|
||||
from src.core.providers.provider_factory import Loaders
|
||||
|
||||
|
||||
class SeriesApp:
|
||||
_initialization_count = 0
|
||||
|
||||
def __init__(self, directory_to_search: str):
|
||||
|
||||
# Only show initialization message for the first instance
|
||||
SeriesApp._initialization_count += 1 # Only show initialization message for the first instance
|
||||
if SeriesApp._initialization_count <= 1:
|
||||
print("Please wait while initializing...")
|
||||
|
||||
@ -27,7 +23,7 @@ class SeriesApp:
|
||||
def __InitList__(self):
|
||||
self.series_list = self.List.GetMissingEpisode()
|
||||
|
||||
def search(self, words :str) -> list:
|
||||
def search(self, words: str) -> list:
|
||||
return self.loader.Search(words)
|
||||
|
||||
def download(self, serieFolder: str, season: int, episode: int, key: str, callback) -> bool:
|
||||
|
||||
@ -36,8 +36,10 @@ from pydantic_settings import BaseSettings
|
||||
|
||||
# Import our custom middleware
|
||||
from src.server.web.middleware.fastapi_auth_middleware import AuthMiddleware
|
||||
from src.server.web.middleware.fastapi_logging_middleware import (
|
||||
EnhancedLoggingMiddleware,
|
||||
)
|
||||
from src.server.web.middleware.fastapi_validation_middleware import ValidationMiddleware
|
||||
from src.server.web.middleware.fastapi_logging_middleware import EnhancedLoggingMiddleware
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
|
||||
@ -6,8 +6,9 @@ using FastAPI patterns and dependency injection.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import Callable, Optional, Dict, Any
|
||||
from fastapi import Request, Response, HTTPException, status
|
||||
from typing import Any, Callable, Dict, Optional
|
||||
|
||||
from fastapi import HTTPException, Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
|
||||
|
||||
@ -12,10 +12,11 @@ import json
|
||||
import logging
|
||||
import time
|
||||
import traceback
|
||||
from typing import Callable, Dict, Any, Optional
|
||||
from fastapi import Request, Response, HTTPException, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, Callable, Dict, Optional
|
||||
|
||||
from fastapi import HTTPException, Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
|
||||
class EnhancedLoggingMiddleware:
|
||||
|
||||
@ -5,13 +5,14 @@ This module provides middleware for handling request validation logic
|
||||
using FastAPI patterns and dependency injection.
|
||||
"""
|
||||
|
||||
import html
|
||||
import json
|
||||
import logging
|
||||
from typing import Callable, Dict, Any, Optional, Union
|
||||
from fastapi import Request, Response, HTTPException, status
|
||||
from fastapi.responses import JSONResponse
|
||||
import html
|
||||
import re
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
|
||||
from fastapi import HTTPException, Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
|
||||
class ValidationMiddleware:
|
||||
|
||||
@ -6,12 +6,13 @@ This script provides a convenient way to start the AniWorld FastAPI server
|
||||
with proper configuration for both development and production environments.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import uvicorn
|
||||
from pathlib import Path
|
||||
|
||||
import uvicorn
|
||||
|
||||
# Add the project root to Python path
|
||||
project_root = Path(__file__).parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user