"""read_wiring.py — Part D2: what the box wired by itself, read from each app's OWN API inside its container (keys read from the app's config at use, never printed) and from the controller's log. Read only.""" import json, shlex, n100 w = n100.w def arr(app, port, path, ver="v3"): script = ("K=$(sed -n 's:.*\\(.*\\).*:\\1:p' /config/config.xml); " f"curl -s -H \"X-Api-Key: $K\" http://127.0.0.1:{port}/api/{ver}{path}") out = w.guest(f"docker exec {app} sh -c {shlex.quote(script)}") try: return json.loads(out) except Exception: return out[:200] print("== the controller's wiring runs:") print(w.guest("docker logs --since 10m felhom-controller 2>&1 | grep -E '\\[media\\] wiring|\\[mediawire\\]|media_library .*binds' | cut -c1-330")) print("== per-drive binds (docker's own view):") for a in ("qbittorrent", "sonarr", "radarr", "prowlarr"): print(f" {a}:", w.guest(f"docker inspect {a} -f '{{{{range .Mounts}}}}{{{{.Source}}}} -> {{{{.Destination}}}}; {{{{end}}}}'").strip()) for a, port in (("sonarr", 8989), ("radarr", 7878)): rf = arr(a, port, "/rootfolder"); tags = arr(a, port, "/tag"); dc = arr(a, port, "/downloadclient") print(f"== {a}: root folders {[r.get('path') for r in rf] if isinstance(rf, list) else rf}") print(f" tags {[t.get('label') for t in tags] if isinstance(tags, list) else tags}") print(f" download clients {[(c.get('name'), c.get('implementation'), [f.get('value') for f in c.get('fields', []) if f.get('name') in ('host', 'tvCategory', 'movieCategory')], c.get('tags')) for c in dc] if isinstance(dc, list) else dc}") apps = arr("prowlarr", 9696, "/applications", "v1") print(f"== prowlarr: apps {[(a.get('name'), a.get('syncLevel'), next((f.get('value') for f in a.get('fields', []) if f.get('name') == 'baseUrl'), None)) for a in apps] if isinstance(apps, list) else apps}") print("== qbittorrent categories:", w.guest("docker exec qbittorrent sh -c 'curl -s http://127.0.0.1:8080/api/v2/torrents/categories'").strip()[:600])