feat: expand RF4 media inventory

This commit is contained in:
ik
2026-09-13 08:06:48 +07:00
parent 4042c80f00
commit 674bc5627f
9 changed files with 5054 additions and 19 deletions
+5 -4
View File
@@ -15,12 +15,12 @@ DEFAULT_ROOT = Path("data/media")
MAX_ASSET_BYTES = 15 * 1024 * 1024
def _download_one(root: Path, state_file: Path) -> str:
def _download_one(root: Path, state_file: Path, asset_url: str | None = None) -> str:
manifest_path = root / "manifest.json"
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
queued = next((item for item in manifest["assets"] if item.get("status") == "queued"), None)
queued = next((item for item in manifest["assets"] if item.get("status") == "queued" and (asset_url is None or item["asset_url"] == asset_url)), None)
if queued is None:
return "queue is empty"
return "queue is empty" if asset_url is None else "asset is not queued"
url = queued["asset_url"]
_validate_url_before_io(url)
check_and_reserve(fetch_site_key(url), state_file=state_file)
@@ -51,6 +51,7 @@ def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="Index authorized RF4 media without hotlinking")
parser.add_argument("url", nargs="?")
parser.add_argument("--download-one", action="store_true", help="Store one queued asset while respecting site cooldown")
parser.add_argument("--asset-url", help="Download this exact queued asset instead of the first queue item")
parser.add_argument("--reclassify", action="store_true", help="Reapply current conservative classifier without network access")
parser.add_argument("--review-url", help="Review an asset already present in the manifest")
parser.add_argument("--decision", choices=("approved", "rejected"))
@@ -77,7 +78,7 @@ def main(argv: list[str] | None = None) -> int:
print(f"reclassified {len(manifest['assets'])} candidates")
return 0
if args.download_one:
print(_download_one(args.root, args.state_file))
print(_download_one(args.root, args.state_file, args.asset_url))
return 0
if not args.url:
parser.error("url is required unless --download-one is used")