docs: shorten the readme and trim code comments

This commit is contained in:
Steppenstreuner
2026-08-29 16:18:37 +02:00
parent 8a05d2d3c3
commit 551352e838
16 changed files with 132 additions and 229 deletions
+6 -9
View File
@@ -1,9 +1,8 @@
"""MusicBrainz as a fallback for audio dramas Audible does not carry.
"""MusicBrainz, for audio dramas Audible does not carry.
German Hörspiel series are well covered there, often with the episode number in
the title and the *original* release date instead of a later Audible reissue.
The service asks for one request per second and a descriptive user agent; both
are honoured here, which makes it deliberately slower than Audible.
Often has the episode number in the title and the original release date instead
of a later reissue. One request per second and a descriptive user agent are
required, which makes it slower than Audible.
"""
import asyncio
@@ -86,8 +85,7 @@ LUCENE_SPECIAL = re.compile(r'[+\-&|!(){}\[\]^"~*?:\\/]+')
def _terms(query: str) -> str:
"""Words joined with AND - a quoted phrase would miss "Die drei ??? 100:
Toteninsel" when searching for "Die drei ??? Toteninsel"."""
"""Words joined with AND; a quoted phrase would miss "… 100: Toteninsel"."""
words = [w for w in LUCENE_SPECIAL.sub(" ", query).split() if len(w) > 1][:8]
return " AND ".join(f"release:{w}" for w in words)
@@ -102,8 +100,7 @@ async def search(query: str, language: str = "") -> list[MetadataResult]:
async with httpx.AsyncClient(timeout=25, follow_redirects=True) as client:
data = await _get(client, " AND ".join(terms))
# the same audio drama exists as many pressings; keep the oldest of each,
# that is the original release rather than a reissue
# many pressings per drama, keep the oldest: the original release
best: dict[tuple, MetadataResult] = {}
for release in data.get("releases", []):
result = _to_result(release)