- 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>
31 lines
964 B
Python
31 lines
964 B
Python
"""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
|