1.9 KiB
Playwright fetch helper
This helper uses Playwright to drive a browser to click the download button on a Vimm detail page and save the resulting file to disk.
Usage examples
Programmatic usage
-
Basic example (Python):
from tool.playwright import PlaywrightTool tool = PlaywrightTool({}) result = tool.download_file("https://vimm.net/vault/48075", selector="form#dl_form button[type=submit]", out_dir=None, timeout_sec=60) if result.ok: print(result.path) else: print("Download failed:", result.error) -
Shell one-liners (PowerShell / Unix compatible):
-
PowerShell:
python - <<'PY' from tool.playwright import PlaywrightTool r = PlaywrightTool().download_file("https://vimm.net/vault/48075") print(r.to_dict()) PY -
Unix shell:
python -c "from tool.playwright import PlaywrightTool; import json; r=PlaywrightTool().download_file('https://vimm.net/vault/48075'); print(json.dumps(r.to_dict()))"
-
-
Download to a specific directory:
tool.download_file("https://vimm.net/vault/48075", out_dir="C:\\tmp") -
Pipe the result into
add-file:Use one of the shell one-liners above and extract the
pathfield from the returned JSON to pass toCLI.py add-file. For example, in Unix:python -c "from tool.playwright import PlaywrightTool, json; r=PlaywrightTool().download_file('https://vimm.net/vault/48075'); print(r.to_dict())" | jq -r .path | xargs -I{} python CLI.py add-file -store default -path "{}"
Notes
-
The script prints a single JSON line to stdout on completion. On success,
okis true andpathcontains the saved file path. -
Provider
Provider.vimmwill use Playwright when HTTP GET fails (4xx/5xx) or on network errors. Playwright is a required runtime dependency for these flows. -
Playwright must be available in the current Python environment; install with
pip install playwright && playwright install.