import argparse import sys from src.logic import clear_bacon_history def main(): parser = argparse.ArgumentParser(description="Clear BACON history for YouTube video IDs.") parser.add_argument("--ids", required=True, help="Comma-delimited YouTube video ID(s)") # argparse treats values starting with '-' as optional flags; rewrite '--ids ' # as '--ids=' so it works even when video IDs start with '-' or '--'. argv = sys.argv[1:] fixed = [] i = 0 while i < len(argv): if argv[i] == "--ids" and i + 1 < len(argv): fixed.append(f"--ids={argv[i + 1]}") i += 2 else: fixed.append(argv[i]) i += 1 args = parser.parse_args(fixed) ids = [v.strip() for v in args.ids.split(",") if v.strip()] if len(ids) > 1000: raise ValueError("Youtube video IDs should not be more than 1000") clear_bacon_history(ids) if __name__ == "__main__": main()