import os import sys import subprocess def main(): args = sys.argv[1:] savename = None if '--save-name' in args: idx = args.index('--save-name') if idx + 1 < len(args): savename = args[idx + 1] args = args[:idx] + args[idx + 2:] # Execute tasks.py and get the DASH link tasks_result = subprocess.run([sys.executable, 'tasks.py'] + args, capture_output=True, text=True) dash_link = None for line in tasks_result.stdout.splitlines(): if line.startswith("DASH Link:"): dash_link = line[len("DASH Link:"):].strip() break get_result = subprocess.run([sys.executable, 'keys.py'] + args, capture_output=True, text=True) get_output = get_result.stdout.strip() # Extract only the key part from get_output key_part = get_output.split(':', 1)[0] + ':' + get_output.split(':', 1)[1].strip() print(f"Executing command with key: {key_part}") # Prepare the command command = [ 'N_m3u8dl-re', '-M', 'mp4', '-sv', 'best', '-sa', 'best', '--key', key_part, ] # Append the dash_link without additional quotes if dash_link: command.append(dash_link) # Run the N_m3u8dl-re command try: print("Running command...") subprocess.run(command, check=True) except subprocess.CalledProcessError as e: print(f"Error running N_m3u8dl-re: {e}") if __name__ == "__main__": main()