import logging import requests from app.config import YODECK_API_TOKEN, YODECK_API_BASE log = logging.getLogger(__name__) def get_all_screens(): """Fetch all screens/players from the Yodeck API (handles pagination).""" if not YODECK_API_TOKEN: raise RuntimeError("YODECK_API_TOKEN is not configured") headers = {'Authorization': f'Token {YODECK_API_TOKEN}'} players = [] url = f'{YODECK_API_BASE}/screens/' while url: log.debug("GET %s", url) resp = requests.get(url, headers=headers, timeout=30) resp.raise_for_status() data = resp.json() players.extend(data.get('results', [])) url = data.get('next') return players