import json from InquirerPy import prompt from InquirerPy.base.control import Choice VAULT_FILE = "vault.json" def load_vault(): try: with open(VAULT_FILE, "r") as f: return json.load(f)["channels"] except FileNotFoundError: return [] def main(): channels = load_vault() if not channels: print("No channels found in vault.json") return choices = [ Choice(value=channel, name=f"{channel.get('number', '?')} - {channel.get('name', 'Unknown')}") for channel in channels ] questions = [ { "type": "list", "name": "channel", "message": "Select a channel to generate the streamlink command for:", "choices": choices, } ] result = prompt(questions) selected_channel = result.get("channel") if selected_channel: mpd_url = selected_channel.get("mpd_url", "") keys_list = selected_channel.get("keys", []) keys_str = ",".join(keys_list) command = f'streamlink -l debug --plugin-dirs "./plugin" --dashdrm-mp4ff-use-mp4ff --dashdrm-mp4ff-decryption-key "{keys_str}" "dashdrm://{mpd_url}" best' print(command) if __name__ == "__main__": main()