feat: add gear provenance models and browser fetcher
This commit is contained in:
@@ -310,6 +310,10 @@ def main(argv: list[str] | None = None) -> int:
|
||||
default=Path(os.environ.get("RF4_COMMUNITY_FETCH_STATE", DEFAULT_STATE_FILE)),
|
||||
help="Persistent per-source cooldown state",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--reserve-only", action="store_true",
|
||||
help="Reserve the shared site cooldown and stop before making an HTTP request",
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
if args.source in DETAIL_SOURCES and not args.url:
|
||||
parser.error(f"--url is required for {args.source}")
|
||||
@@ -319,6 +323,9 @@ def main(argv: list[str] | None = None) -> int:
|
||||
site_key = fetch_site_key(url)
|
||||
# Single atomic check-and-reserve before network I/O: failed attempts count toward the limit too.
|
||||
check_and_reserve(site_key, state_file=args.state_file)
|
||||
if args.reserve_only:
|
||||
print(json.dumps({"reserved": True, "source": args.source, "site_key": site_key}, ensure_ascii=False))
|
||||
return 0
|
||||
html = fetch_html(url)
|
||||
parsed = (
|
||||
parse(html, source_url=url)
|
||||
|
||||
Reference in New Issue
Block a user