| 98 | |
| 99 | |
| 100 | def parse_args(argv: list[str]) -> argparse.Namespace: |
| 101 | parser = argparse.ArgumentParser(description=__doc__) |
| 102 | parser.add_argument("--site", choices=sorted(SITE_PROFILES), default="medium", |
| 103 | help="Which target site to capture a session for (default: medium).") |
| 104 | parser.add_argument("--output", default=None, |
| 105 | help="Path to write the storage state JSON (default: <site>-storage-state.json)") |
| 106 | parser.add_argument("--no-base64", action="store_true", |
| 107 | help="Skip printing the base64 blob (just write the JSON file).") |
| 108 | parser.add_argument("--timeout", type=int, default=DEFAULT_TIMEOUT_SECONDS, |
| 109 | help="Maximum seconds to wait for login completion (default: 600).") |
| 110 | parser.add_argument("--interactive", action="store_true", |
| 111 | help="Wait for Enter on stdin instead of polling for auth cookies.") |
| 112 | parser.add_argument("--browser", default="chrome", choices=["chrome", "chromium", "firefox", "msedge"], |
| 113 | help="Which Playwright browser to launch (default: chrome).") |
| 114 | parser.add_argument("--from-firefox-profile", nargs="?", const="auto", default=None, |
| 115 | help=("Skip launching a browser and instead read medium.com cookies from an " |
| 116 | "existing Firefox profile's cookies.sqlite. Pass a path or omit for auto-detect.")) |
| 117 | return parser.parse_args(argv) |
| 118 | |
| 119 | |
| 120 | def _locate_firefox_profile(explicit: str | None) -> Path: |