feat: audit media catalog integrity
This commit is contained in:
@@ -8,7 +8,7 @@ import urllib.error
|
||||
import urllib.request
|
||||
|
||||
from .community_cli import USER_AGENT, _StrictRedirectHandler, _validate_url_before_io, check_and_reserve, fetch_html, fetch_site_key
|
||||
from .media_assets import extract_media_candidates, merge_manifest, reclassify_manifest, review_asset, store_asset
|
||||
from .media_assets import audit_media_catalog, extract_media_candidates, merge_manifest, reclassify_manifest, review_asset, store_asset
|
||||
|
||||
|
||||
DEFAULT_ROOT = Path("data/media")
|
||||
@@ -57,10 +57,15 @@ def main(argv: list[str] | None = None) -> int:
|
||||
parser.add_argument("--entity-type", choices=("fish", "waterbody", "tackle", "reference"))
|
||||
parser.add_argument("--entity-key")
|
||||
parser.add_argument("--note")
|
||||
parser.add_argument("--audit", action="store_true", help="Verify manifest metadata, hashes and local files without network access")
|
||||
parser.add_argument("--root", type=Path, default=DEFAULT_ROOT)
|
||||
parser.add_argument("--state-file", type=Path, default=Path(".cache/community-fetch-state.json"))
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
if args.audit:
|
||||
report = audit_media_catalog(args.root)
|
||||
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||
return 1 if report["issues"] or report["orphaned_files"] else 0
|
||||
if args.review_url:
|
||||
if not args.decision:
|
||||
parser.error("--decision is required with --review-url")
|
||||
|
||||
Reference in New Issue
Block a user