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:
Audiolib
2026-05-26 11:43:35 +02:00
commit 14ffee3051
56 changed files with 3220 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class MatchResult:
source: str # musicbrainz / open_library / google_books
source_id: str
title: str
author: str | None = None
narrator: str | None = None
description: str | None = None
cover_url: str | None = None
publisher: str | None = None
publish_year: int | None = None
series: str | None = None
series_sequence: str | None = None
language: str | None = None
genres: list[str] = field(default_factory=list)
chapters: list[dict] = field(default_factory=list)
confidence: float = 0.0
class BaseMatcherError(Exception):
pass

View File

@@ -0,0 +1,35 @@
"""Google Books-Matching — Phase 5."""
import httpx
from .base import MatchResult
GB_BASE = "https://www.googleapis.com/books/v1"
async def search_google_books(title: str, author: str | None = None) -> list[MatchResult]:
q = f'intitle:"{title}"'
if author:
q += f' inauthor:"{author}"'
async with httpx.AsyncClient(timeout=10) as client:
resp = await client.get(f"{GB_BASE}/volumes", params={"q": q, "maxResults": 5, "langRestrict": "de"})
resp.raise_for_status()
data = resp.json()
results = []
for item in data.get("items", []):
vol = item.get("volumeInfo", {})
authors = vol.get("authors", [])
results.append(
MatchResult(
source="google_books",
source_id=item.get("id", ""),
title=vol.get("title", title),
author=authors[0] if authors else None,
description=vol.get("description"),
publisher=vol.get("publisher"),
publish_year=int(vol.get("publishedDate", "0")[:4]) if vol.get("publishedDate") else None,
language=vol.get("language"),
confidence=0.5,
)
)
return results

View File

@@ -0,0 +1,40 @@
"""MusicBrainz-Matching — Phase 5."""
import httpx
from .base import MatchResult
MB_BASE = "https://musicbrainz.org/ws/2"
HEADERS = {"User-Agent": "audiolib/1.0 (https://github.com/audiolib)"}
async def search_musicbrainz(title: str, artist: str | None = None) -> list[MatchResult]:
query = f'release:"{title}"'
if artist:
query += f' AND artist:"{artist}"'
query += " AND format:Digital"
async with httpx.AsyncClient(headers=HEADERS, timeout=10) as client:
resp = await client.get(
f"{MB_BASE}/release",
params={"query": query, "fmt": "json", "limit": 5},
)
resp.raise_for_status()
data = resp.json()
results = []
for release in data.get("releases", []):
confidence = release.get("score", 0) / 100.0
artist_name = None
credits = release.get("artist-credit", [])
if credits:
artist_name = credits[0].get("name") or credits[0].get("artist", {}).get("name")
results.append(
MatchResult(
source="musicbrainz",
source_id=release.get("id", ""),
title=release.get("title", title),
author=artist_name,
confidence=confidence,
)
)
return results

View File

@@ -0,0 +1,30 @@
"""OpenLibrary-Matching — Phase 5."""
import httpx
from .base import MatchResult
OL_BASE = "https://openlibrary.org"
async def search_open_library(title: str, author: str | None = None) -> list[MatchResult]:
params: dict = {"title": title, "limit": 5}
if author:
params["author"] = author
async with httpx.AsyncClient(timeout=10) as client:
resp = await client.get(f"{OL_BASE}/search.json", params=params)
resp.raise_for_status()
data = resp.json()
results = []
for doc in data.get("docs", []):
results.append(
MatchResult(
source="open_library",
source_id=doc.get("key", ""),
title=doc.get("title", title),
author=doc.get("author_name", [None])[0] if doc.get("author_name") else None,
publish_year=doc.get("first_publish_year"),
confidence=0.6,
)
)
return results