feat: config-aware registry gating Qobuz on credentials; wire config into worker

This commit is contained in:
Jonathan
2026-07-10 22:13:11 +02:00
parent 085193aa82
commit 71143dc15d
3 changed files with 33 additions and 12 deletions
+3 -1
View File
@@ -1,6 +1,7 @@
import time
from lyra_worker.claim import claim_next
from lyra_worker.config import get_config
from lyra_worker.db import wait_for_db
from lyra_worker.pipeline import run_pipeline
from lyra_worker.registry import build_adapters
@@ -10,7 +11,8 @@ IDLE_SLEEP = 2.0
def run_forever() -> None:
conn = wait_for_db()
adapters = build_adapters()
adapters = build_adapters(get_config(conn))
print(f"worker: {len(adapters)} adapter(s) enabled: {[a.name for a in adapters]}", flush=True)
print("worker: waiting for jobs", flush=True)
try:
while True:
+11 -5
View File
@@ -1,12 +1,18 @@
from lyra_worker.adapters._streamrip import StreamripClient
from lyra_worker.adapters._ytdlp import YtDlpClient
from lyra_worker.adapters.base import SourceAdapter
from lyra_worker.adapters.qobuz import QobuzAdapter
from lyra_worker.adapters.youtube import YouTubeAdapter
def build_adapters() -> list[SourceAdapter]:
"""The enabled real source adapters, best-tier first.
def build_adapters(config: dict) -> list[SourceAdapter]:
"""Real source adapters, best-tier first, filtered to those that are configured.
Only real, usable adapters are returned. Plan 3c/3d add Qobuz (streamrip)
and Soulseek (slskd), each gated on its config being present via health().
An adapter is included only if its health() is true (e.g. Qobuz requires
credentials in config). Plan 3d adds Soulseek (slskd) the same way.
"""
return [YouTubeAdapter(YtDlpClient())]
candidates: list[SourceAdapter] = [
QobuzAdapter(StreamripClient(config)),
YouTubeAdapter(YtDlpClient()),
]
return [a for a in candidates if a.health()]