Initial commit: Phase 1 – Projektstruktur, DB-Schema, Core-API
- FastAPI-Backend mit vollständiger ABS v2.x API-Kompatibilität - SQLAlchemy-Models: User, Library, LibraryItem, BookFile, Chapter, Podcast, PodcastEpisode, MediaProgress, Bookmark, PlaybackSession - Auth: JWT-Login (/login, /logout, /api/authorize) - Library + Items Endpoints inkl. camelCase ABS-Response-Format - HLS-Streaming via FFmpeg (POST /api/items/:id/play, Session-Sync) - Me/Progress Endpoints + Lesezeichen - User-Management + Server-Settings (Admin) - Library-Scanner (MP3/WAV Discovery, Hintergrund-Task) - File Watcher (watchdog, 30s Debounce) - Matching-Skelett (MusicBrainz, OpenLibrary, Google Books – Phase 5) - Docker-Setup: backend (Python 3.12+FFmpeg), frontend (React/Vite), nginx Reverse-Proxy auf Port 3000 - setup.sh: Installiert Docker auf Debian/Ubuntu, richtet .env ein Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
0
backend/app/schemas/__init__.py
Normal file
0
backend/app/schemas/__init__.py
Normal file
26
backend/app/schemas/auth.py
Normal file
26
backend/app/schemas/auth.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from pydantic.alias_generators import to_camel
|
||||
from .user import UserOut, ServerSettingsOut
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
|
||||
|
||||
class LoginResponse(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
user: UserOut
|
||||
user_default_library_id: str | None = None
|
||||
server_settings: ServerSettingsOut
|
||||
source: str = "local"
|
||||
|
||||
|
||||
class AuthorizeResponse(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
user: UserOut
|
||||
libraries: list
|
||||
user_default_library_id: str | None = None
|
||||
server_settings: ServerSettingsOut
|
||||
67
backend/app/schemas/library.py
Normal file
67
backend/app/schemas/library.py
Normal file
@@ -0,0 +1,67 @@
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from pydantic.alias_generators import to_camel
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class LibraryFolder(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
id: str
|
||||
full_path: str
|
||||
library_id: str = ""
|
||||
added_at: int = 0
|
||||
|
||||
|
||||
class LibrarySettings(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
cover_aspect_ratio: int = 1
|
||||
disable_watcher: bool = False
|
||||
skip_matching_media_with_asin: bool = False
|
||||
skip_matching_media_with_isbn: bool = False
|
||||
auto_scan_cron_expression: str = ""
|
||||
audio_files_global_include: list[str] = []
|
||||
audio_files_global_exclude: list[str] = []
|
||||
metadata_precision: int = 10
|
||||
hide_single_book_series: bool = False
|
||||
only_show_later_books_in_continue_series: bool = False
|
||||
metadata_providers: list[str] = ["google", "audible"]
|
||||
prefer_matched_metadata: bool = False
|
||||
disable_embed_covers: bool = False
|
||||
best_books_matching: bool = False
|
||||
|
||||
|
||||
class LibraryOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
id: str
|
||||
name: str
|
||||
folders: list[LibraryFolder] = []
|
||||
display_order: int = 1
|
||||
icon: str = "database"
|
||||
media_type: str = "book"
|
||||
provider: str = "google"
|
||||
settings: LibrarySettings = LibrarySettings()
|
||||
created_at: int = 0 # ABS nutzt Unix-Timestamps in ms
|
||||
last_update: int = 0
|
||||
|
||||
|
||||
class LibraryCreate(BaseModel):
|
||||
name: str
|
||||
folders: list[dict]
|
||||
media_type: str = "book"
|
||||
icon: str = "database"
|
||||
provider: str = "google"
|
||||
|
||||
|
||||
class LibraryUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
folders: list[dict] | None = None
|
||||
settings: dict | None = None
|
||||
|
||||
|
||||
class LibraryItemsResponse(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
results: list
|
||||
total: int
|
||||
limit: int
|
||||
page: int
|
||||
115
backend/app/schemas/media_item.py
Normal file
115
backend/app/schemas/media_item.py
Normal file
@@ -0,0 +1,115 @@
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from pydantic.alias_generators import to_camel
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
|
||||
class AudioFileMetadata(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
filename: str
|
||||
ext: str
|
||||
path: str
|
||||
rel_path: str = ""
|
||||
size: int = 0
|
||||
|
||||
|
||||
class AudioFileOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
index: int
|
||||
ino: str = ""
|
||||
metadata: AudioFileMetadata
|
||||
added_at: int = 0
|
||||
updated_at: int = 0
|
||||
track_num_from_meta: int | None = None
|
||||
disc_num_from_meta: int | None = None
|
||||
format: str = ""
|
||||
duration: float = 0.0
|
||||
bitrate: int = 0
|
||||
language: str | None = None
|
||||
codec: str = ""
|
||||
time_base: str = "1/44100"
|
||||
channels: int = 2
|
||||
channel_layout: str = "stereo"
|
||||
chapters: list = []
|
||||
embedded_cover_art: str | None = None
|
||||
mime_type: str = "audio/mpeg"
|
||||
|
||||
|
||||
class ChapterOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
id: int
|
||||
start: float
|
||||
end: float
|
||||
title: str
|
||||
|
||||
|
||||
class BookMetadata(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
title: str | None = None
|
||||
subtitle: str | None = None
|
||||
authors: list[dict] = [] # [{"id": null, "name": "..."}]
|
||||
narrators: list[str] = []
|
||||
series: list[dict] = [] # [{"id": null, "name": "...", "sequence": "..."}]
|
||||
genres: list[str] = []
|
||||
published_year: str | None = None
|
||||
published_date: str | None = None
|
||||
publisher: str | None = None
|
||||
description: str | None = None
|
||||
isbn: str | None = None
|
||||
asin: str | None = None
|
||||
language: str | None = None
|
||||
explicit: bool = False
|
||||
abridged: bool = False
|
||||
|
||||
|
||||
class BookOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
library_item_id: str
|
||||
metadata: BookMetadata
|
||||
cover_path: str | None = None
|
||||
tags: list[str] = []
|
||||
audio_files: list[AudioFileOut] = []
|
||||
chapters: list[ChapterOut] = []
|
||||
missing_parts: list = []
|
||||
ebookFile: Any = None
|
||||
duration: float = 0.0
|
||||
size: int = 0
|
||||
tracks: list[AudioFileOut] = []
|
||||
num_tracks: int = 0
|
||||
num_audio_files: int = 0
|
||||
num_chapters: int = 0
|
||||
num_missing_parts: int = 0
|
||||
num_invalid_audio_files: int = 0
|
||||
is_missing: bool = False
|
||||
is_invalid: bool = False
|
||||
|
||||
|
||||
class LibraryItemOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
id: str
|
||||
ino: str = ""
|
||||
library_id: str
|
||||
folder_id: str = ""
|
||||
path: str
|
||||
rel_path: str = ""
|
||||
is_file: bool = False
|
||||
mtime_ms: int = 0
|
||||
ctime_ms: int = 0
|
||||
birth_time_ms: int = 0
|
||||
added_at: int = 0
|
||||
updated_at: int = 0
|
||||
last_scan: int | None = None
|
||||
scan_version: str | None = None
|
||||
is_missing: bool = False
|
||||
is_invalid: bool = False
|
||||
media_type: str = "book"
|
||||
media: BookOut | None = None
|
||||
num_files: int = 0
|
||||
size: int = 0
|
||||
|
||||
|
||||
class LibraryItemUpdateRequest(BaseModel):
|
||||
metadata: dict | None = None
|
||||
tags: list[str] | None = None
|
||||
chapters: list[dict] | None = None
|
||||
cover_path: str | None = None
|
||||
55
backend/app/schemas/podcast.py
Normal file
55
backend/app/schemas/podcast.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from pydantic.alias_generators import to_camel
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class PodcastEpisodeOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
id: str
|
||||
index: int = 0
|
||||
season: str | None = None
|
||||
episode: str | None = None
|
||||
episode_type: str = "full"
|
||||
title: str | None = None
|
||||
subtitle: str | None = None
|
||||
description: str | None = None
|
||||
enclosure: dict | None = None
|
||||
pub_date: str | None = None
|
||||
audio_file: dict | None = None
|
||||
published_at: int | None = None
|
||||
added_at: int = 0
|
||||
updated_at: int = 0
|
||||
duration: float = 0.0
|
||||
size: int = 0
|
||||
|
||||
|
||||
class PodcastMetadata(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
title: str | None = None
|
||||
author: str | None = None
|
||||
description: str | None = None
|
||||
release_date: str | None = None
|
||||
genres: list[str] = []
|
||||
feed_url: str | None = None
|
||||
image_url: str | None = None
|
||||
itunes_page_url: str | None = None
|
||||
itunes_id: int | None = None
|
||||
itunes_artist_id: int | None = None
|
||||
explicit: bool = False
|
||||
language: str | None = None
|
||||
type: str = "episodic"
|
||||
|
||||
|
||||
class PodcastOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
library_item_id: str
|
||||
metadata: PodcastMetadata
|
||||
cover_path: str | None = None
|
||||
tags: list[str] = []
|
||||
episodes: list[PodcastEpisodeOut] = []
|
||||
auto_download_episodes: bool = False
|
||||
auto_download_schedule: str = "0 * * * *"
|
||||
last_episode_check: int | None = None
|
||||
max_episodes_to_keep: int = 0
|
||||
max_new_episodes_to_download: int = 3
|
||||
num_episodes: int = 0
|
||||
72
backend/app/schemas/user.py
Normal file
72
backend/app/schemas/user.py
Normal file
@@ -0,0 +1,72 @@
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from pydantic.alias_generators import to_camel
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
|
||||
class ServerSettingsOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
id: str = "server-settings"
|
||||
token_secret: str = ""
|
||||
items_per_page: int = 10
|
||||
metadata_provider: str = "google"
|
||||
store_covers_with_item: bool = False
|
||||
ratio_cover_book_name: bool = False
|
||||
cover_aspect_ratio: int = 1
|
||||
disable_opds: bool = False
|
||||
log_level: int = 2
|
||||
scanner_parse_same_author_name: bool = False
|
||||
auth_active_users: list = []
|
||||
auth_local_users: list = []
|
||||
|
||||
|
||||
class UserSettings(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
muted_badge_notifications: bool = False
|
||||
show_remaining_time: bool = False
|
||||
display_remaining_time: bool = False
|
||||
library_filters: dict = {}
|
||||
playback_rate: float = 1.0
|
||||
bookmarks_list_collapsed: bool = False
|
||||
sleep_timer_duration: int = 900
|
||||
sleep_timer_podcast_chapters: bool = False
|
||||
language: str = "de"
|
||||
|
||||
|
||||
class UserOut(BaseModel):
|
||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||
|
||||
id: str
|
||||
username: str
|
||||
email: str | None = None
|
||||
type: str = "user"
|
||||
is_active: bool = True
|
||||
is_locked: bool = False
|
||||
last_seen: datetime | None = None
|
||||
created_at: datetime
|
||||
token: str | None = None
|
||||
media_progress: list = []
|
||||
bookmarks: list = []
|
||||
is_admin: bool = False
|
||||
libraries_accessible: list[str] = []
|
||||
item_tags_accessible: list[str] = []
|
||||
permissions: dict = {}
|
||||
series_hide_from_continue_listening: list = []
|
||||
settings: UserSettings = UserSettings()
|
||||
|
||||
|
||||
class UserCreate(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
email: str | None = None
|
||||
is_admin: bool = False
|
||||
|
||||
|
||||
class UserUpdate(BaseModel):
|
||||
email: str | None = None
|
||||
password: str | None = None
|
||||
is_admin: bool | None = None
|
||||
is_active: bool | None = None
|
||||
settings: dict | None = None
|
||||
Reference in New Issue
Block a user