refs: pull the Commons categories for the Masonic Temple and El Capitan
A text search had stopped surfacing new material, so commons_fetch.py gained --category. Category:Hollywood Masonic Temple and Category:El Capitan Theater yielded 32 more frames locally, including 4-5k px frontal façades, a 2019 street-level shot of both buildings together, the 1922 postcard, and the first oblique evidence for the 6806-6822 retail run. 68 local images total, none committed. A clean sidewalk-level frame of the hero entry is still absent.
This commit is contained in:
1 parent
72de657202
commit
b8f5a062ac
2 files changed
+23
-3
No files matched your search
+22
-2
@@ -86,6 +86,20 @@ def search_titles(query: str, limit: int) -> list[str]:
|
||||
return titles, order
|
||||
|
||||
|
||||
def category_titles(category: str, limit: int) -> list[str]:
|
||||
data = api_get(
|
||||
{
|
||||
"action": "query",
|
||||
"list": "categorymembers",
|
||||
"cmtitle": category,
|
||||
"cmtype": "file",
|
||||
"cmlimit": str(max(limit, 50)),
|
||||
}
|
||||
)
|
||||
members = data.get("query", {}).get("categorymembers", [])
|
||||
return [m["title"] for m in members][:limit]
|
||||
|
||||
|
||||
def image_info(titles: list[str], thumb_width: int) -> list[dict]:
|
||||
data = api_get(
|
||||
{
|
||||
@@ -160,6 +174,7 @@ def download(url: str, path: str, retries: int = 3) -> str:
|
||||
def main() -> int:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--query", help="Commons search string")
|
||||
ap.add_argument("--category", help='Commons category, e.g. "Category:Hollywood Masonic Temple"')
|
||||
ap.add_argument("--file", action="append", default=[], help="exact File: title, repeatable")
|
||||
ap.add_argument("--slug", required=True, help="output folder name under the out dir")
|
||||
ap.add_argument("--out", default="Art/reference", help="base output directory")
|
||||
@@ -169,10 +184,14 @@ def main() -> int:
|
||||
ap.add_argument("--delay", type=float, default=2.0, help="seconds between downloads")
|
||||
args = ap.parse_args()
|
||||
|
||||
if not args.query and not args.file:
|
||||
ap.error("need --query or --file")
|
||||
if not args.query and not args.file and not args.category:
|
||||
ap.error("need --query, --category, or --file")
|
||||
|
||||
titles = list(args.file)
|
||||
if args.category:
|
||||
found = category_titles(args.category, args.limit * 4)
|
||||
print(f"{len(found)} file(s) in {args.category}")
|
||||
titles += [t for t in found if t not in titles]
|
||||
if args.query:
|
||||
found, _ = search_titles(args.query, args.limit * 3)
|
||||
titles += [t for t in found if t not in titles]
|
||||
@@ -222,6 +241,7 @@ def main() -> int:
|
||||
"source": "Wikimedia Commons API",
|
||||
"api": API,
|
||||
"query": args.query,
|
||||
"category": args.category,
|
||||
"requested_files": args.file,
|
||||
"slug": args.slug,
|
||||
"thumb_width": args.width,
|
||||
|
||||
Reference in new issue
Block a user