refactor(download): remove ProviderCore/download.py, move sanitize_filename to SYS.utils, replace callers to use API.HTTP.HTTPClient

This commit is contained in:
2026-01-06 01:38:59 -08:00
parent 3b363dd536
commit 41c11d39fd
38 changed files with 2640 additions and 526 deletions

60
scripts/README.md Normal file
View File

@@ -0,0 +1,60 @@
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):
```py
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:
```powershell
python - <<'PY'
from tool.playwright import PlaywrightTool
r = PlaywrightTool().download_file("https://vimm.net/vault/48075")
print(r.to_dict())
PY
```
- Unix shell:
```sh
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:
```py
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 `path` field from the returned JSON to pass to `CLI.py add-file`. For example, in Unix:
```sh
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, `ok` is true and `path` contains the saved file path.
- Provider `Provider.vimm` will 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`.