@kinloom/cli 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/cached-ocr.py +556 -0
- package/dist/assets/ocr.md +52 -0
- package/dist/assets/prep-scan.md +59 -0
- package/dist/assets/prep-scan.py +891 -0
- package/dist/bundled-skills/acpl-persi/SKILL.md +94 -0
- package/dist/bundled-skills/acpl-persi/scripts/persi +268 -0
- package/dist/bundled-skills/archive-org/SKILL.md +129 -0
- package/dist/bundled-skills/archive-org/scripts/archive-org +879 -0
- package/dist/bundled-skills/blm-glo/SKILL.md +54 -0
- package/dist/bundled-skills/california-archives/SKILL.md +120 -0
- package/dist/bundled-skills/california-archives/scripts/ca-archives +373 -0
- package/dist/bundled-skills/chronicling-america/SKILL.md +100 -0
- package/dist/bundled-skills/chronicling-america/scripts/chronam +250 -0
- package/dist/bundled-skills/cyndis-list/SKILL.md +53 -0
- package/dist/bundled-skills/findagrave/SKILL.md +116 -0
- package/dist/bundled-skills/findagrave/scripts/findagrave +520 -0
- package/dist/bundled-skills/hathitrust/SKILL.md +110 -0
- package/dist/bundled-skills/hathitrust/scripts/hathi +194 -0
- package/dist/bundled-skills/kentucky-archives/SKILL.md +123 -0
- package/dist/bundled-skills/kentucky-archives/scripts/ky-archives +358 -0
- package/dist/bundled-skills/library-of-michigan/SKILL.md +111 -0
- package/dist/bundled-skills/library-of-michigan/scripts/michiganology +346 -0
- package/dist/bundled-skills/missouri-archives/SKILL.md +100 -0
- package/dist/bundled-skills/missouri-archives/scripts/mo-archives +528 -0
- package/dist/bundled-skills/nara-catalog-search/SKILL.md +118 -0
- package/dist/bundled-skills/nara-catalog-search/scripts/nara +934 -0
- package/dist/bundled-skills/narrative-audio/SKILL.md +103 -0
- package/dist/bundled-skills/narrative-audio/references/script-rules.md +109 -0
- package/dist/bundled-skills/narrative-audio/scripts/narrative-audio +290 -0
- package/dist/bundled-skills/new-jersey-archives/SKILL.md +118 -0
- package/dist/bundled-skills/new-jersey-archives/scripts/nj-archives +585 -0
- package/dist/bundled-skills/openarchieven/SKILL.md +90 -0
- package/dist/bundled-skills/openarchieven/scripts/openarchieven +432 -0
- package/dist/bundled-skills/texas-archives/SKILL.md +93 -0
- package/dist/bundled-skills/texas-archives/scripts/texas-archives +441 -0
- package/dist/bundled-skills/uk-archives/SKILL.md +101 -0
- package/dist/bundled-skills/uk-archives/scripts/uk-archives +391 -0
- package/dist/bundled-skills/usgs-gnis/SKILL.md +89 -0
- package/dist/bundled-skills/usgs-gnis/scripts/gnis +254 -0
- package/dist/bundled-skills/virginia-archives/SKILL.md +104 -0
- package/dist/bundled-skills/virginia-archives/scripts/va-archives +466 -0
- package/dist/bundled-skills/wikitree/SKILL.md +148 -0
- package/dist/bundled-skills/wikitree/scripts/wikitree +219 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +383 -26
- package/dist/cli.js.map +1 -1
- package/dist/client.js +1 -1
- package/dist/commands/init.js +3 -3
- package/dist/commands/ops/audit.d.ts +138 -0
- package/dist/commands/ops/audit.d.ts.map +1 -0
- package/dist/commands/ops/audit.js +867 -0
- package/dist/commands/ops/audit.js.map +1 -0
- package/dist/commands/ops/context.d.ts +100 -0
- package/dist/commands/ops/context.d.ts.map +1 -0
- package/dist/commands/ops/context.js +917 -0
- package/dist/commands/ops/context.js.map +1 -0
- package/dist/commands/ops/help.d.ts +6 -0
- package/dist/commands/ops/help.d.ts.map +1 -0
- package/dist/commands/ops/help.js +74 -0
- package/dist/commands/ops/help.js.map +1 -0
- package/dist/commands/ops/index.d.ts +6 -0
- package/dist/commands/ops/index.d.ts.map +1 -0
- package/dist/commands/ops/index.js +6 -0
- package/dist/commands/ops/index.js.map +1 -0
- package/dist/commands/ops/integrate.d.ts +56 -0
- package/dist/commands/ops/integrate.d.ts.map +1 -0
- package/dist/commands/ops/integrate.js +872 -0
- package/dist/commands/ops/integrate.js.map +1 -0
- package/dist/commands/ops/sync.d.ts +177 -0
- package/dist/commands/ops/sync.d.ts.map +1 -0
- package/dist/commands/ops/sync.js +1078 -0
- package/dist/commands/ops/sync.js.map +1 -0
- package/dist/commands/ops/telemetry.d.ts +79 -0
- package/dist/commands/ops/telemetry.d.ts.map +1 -0
- package/dist/commands/ops/telemetry.js +249 -0
- package/dist/commands/ops/telemetry.js.map +1 -0
- package/dist/commands/records/help.d.ts +18 -0
- package/dist/commands/records/help.d.ts.map +1 -0
- package/dist/commands/records/help.js +174 -0
- package/dist/commands/records/help.js.map +1 -0
- package/dist/commands/records/index.d.ts +5 -0
- package/dist/commands/records/index.d.ts.map +1 -0
- package/dist/commands/records/index.js +5 -0
- package/dist/commands/records/index.js.map +1 -0
- package/dist/commands/records/registry.d.ts +32 -0
- package/dist/commands/records/registry.d.ts.map +1 -0
- package/dist/commands/records/registry.js +227 -0
- package/dist/commands/records/registry.js.map +1 -0
- package/dist/commands/records/resolve.d.ts +14 -0
- package/dist/commands/records/resolve.d.ts.map +1 -0
- package/dist/commands/records/resolve.js +61 -0
- package/dist/commands/records/resolve.js.map +1 -0
- package/dist/commands/records/runner.d.ts +25 -0
- package/dist/commands/records/runner.d.ts.map +1 -0
- package/dist/commands/records/runner.js +224 -0
- package/dist/commands/records/runner.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
#!/usr/bin/env -S uv run --script
|
|
2
|
+
# /// script
|
|
3
|
+
# requires-python = ">=3.11"
|
|
4
|
+
# dependencies = [
|
|
5
|
+
# "click>=8.1",
|
|
6
|
+
# "httpx>=0.27",
|
|
7
|
+
# ]
|
|
8
|
+
# ///
|
|
9
|
+
"""ky-archives: search Kentucky archives from the command line.
|
|
10
|
+
|
|
11
|
+
Verified live 2026-11-24. No account or API key is needed
|
|
12
|
+
for any command. Three real machine interfaces:
|
|
13
|
+
|
|
14
|
+
- KHS Digital Collections (CONTENTdm dmwebservices API, key-free):
|
|
15
|
+
``cdm`` and ``cdm-item`` hit https://www.kyhistory.com/digital/api/...
|
|
16
|
+
- KY Secretary of State Land Office, County Court Orders patents
|
|
17
|
+
(ASP.NET form POST with VIEWSTATE): ``land`` and ``land-patent``.
|
|
18
|
+
- KDLA Preservica e-archives (WordPress search RSS feed):
|
|
19
|
+
``preservica`` fetches https://kdla.access.preservica.com/search/<term>/feed/rss2/
|
|
20
|
+
and lists the matching record pages. Viewing a packet itself needs the browser.
|
|
21
|
+
|
|
22
|
+
What has NO machine interface (browser only, use the ``urls`` command
|
|
23
|
+
to get the links): the Virginia / Old Kentucky Patent Series browser
|
|
24
|
+
(series + patent dropdowns, no name search), Pass the Word oral
|
|
25
|
+
histories, and the UK Kentucky Vital Records Index (its old
|
|
26
|
+
ukcc.uky.edu/vitalrec URL did not resolve live 2026-11-24).
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
import html as htmlmod
|
|
32
|
+
import json
|
|
33
|
+
import re
|
|
34
|
+
from urllib.parse import quote
|
|
35
|
+
|
|
36
|
+
import click
|
|
37
|
+
import httpx
|
|
38
|
+
|
|
39
|
+
CDM_BASE = "https://www.kyhistory.com"
|
|
40
|
+
CDM_API = CDM_BASE + "/digital/api"
|
|
41
|
+
LAND_URL = "https://web.sos.ky.gov/land/ccorders.aspx"
|
|
42
|
+
PRESERVICA_BASE = "https://kdla.access.preservica.com"
|
|
43
|
+
# The KHS web UI returns 403 to a bare Linux-Chrome UA; a Windows Chrome
|
|
44
|
+
# UA returns 200. The CONTENTdm API accepts either; use one UA everywhere.
|
|
45
|
+
UA = (
|
|
46
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
|
47
|
+
"(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
|
48
|
+
)
|
|
49
|
+
TIMEOUT = 30.0
|
|
50
|
+
|
|
51
|
+
LAND_BY = {
|
|
52
|
+
"grantee": "GrantHR",
|
|
53
|
+
"patent": "Patent",
|
|
54
|
+
"grant-book": "GRNTBKPG",
|
|
55
|
+
"county": "County",
|
|
56
|
+
"watercourse": "Water",
|
|
57
|
+
"survey-name": "SurName",
|
|
58
|
+
"survey-year": "Sur_Date",
|
|
59
|
+
"grant-year": "GrantDte",
|
|
60
|
+
"warrant": "Warrant",
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _client() -> httpx.Client:
|
|
65
|
+
return httpx.Client(headers={"User-Agent": UA}, timeout=TIMEOUT, follow_redirects=True)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _get(client: httpx.Client, url: str) -> httpx.Response:
|
|
69
|
+
try:
|
|
70
|
+
resp = client.get(url)
|
|
71
|
+
except httpx.HTTPError as exc:
|
|
72
|
+
raise click.ClickException(f"request failed: {exc}")
|
|
73
|
+
if resp.status_code != 200:
|
|
74
|
+
raise click.ClickException(f"{url} returned HTTP {resp.status_code}")
|
|
75
|
+
return resp
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _clean(text: str) -> str:
|
|
79
|
+
text = re.sub(r"<script.*?</script>", " ", text, flags=re.S | re.I)
|
|
80
|
+
text = re.sub(r"<style.*?</style>", " ", text, flags=re.S | re.I)
|
|
81
|
+
text = re.sub(r"<[^>]+>", " ", text)
|
|
82
|
+
text = htmlmod.unescape(text)
|
|
83
|
+
return re.sub(r"\s+", " ", text).strip()
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# ---------------------------------------------------------------- CONTENTdm
|
|
87
|
+
@click.command("cdm")
|
|
88
|
+
@click.argument("query")
|
|
89
|
+
@click.option("--collection", "alias", default="all",
|
|
90
|
+
help="CONTENTdm collection alias (default: all). See `collections`.")
|
|
91
|
+
@click.option("--field", default="all",
|
|
92
|
+
help="Search field: all, title, descri, date, subjec, publis, source (default: all).")
|
|
93
|
+
@click.option("--limit", default=10, type=int, show_default=True)
|
|
94
|
+
@click.option("--json", "as_json", is_flag=True, help="Print raw trimmed JSON.")
|
|
95
|
+
def cdm_cmd(query: str, alias: str, field: str, limit: int, as_json: bool) -> None:
|
|
96
|
+
"""Search KHS Digital Collections (CONTENTdm API)."""
|
|
97
|
+
url = (
|
|
98
|
+
f"{CDM_API}/search/collection/{alias}/searchterm/{quote(query)}/"
|
|
99
|
+
f"field/{field}/maxRecords/{limit}"
|
|
100
|
+
)
|
|
101
|
+
with _client() as client:
|
|
102
|
+
data = _get(client, url).json()
|
|
103
|
+
total = data.get("totalResults", 0)
|
|
104
|
+
items = data.get("items", [])
|
|
105
|
+
if as_json:
|
|
106
|
+
click.echo(json.dumps(
|
|
107
|
+
{"totalResults": total,
|
|
108
|
+
"items": [{k: it.get(k) for k in
|
|
109
|
+
("collectionAlias", "itemId", "title", "filetype", "itemLink")
|
|
110
|
+
} | {"fields": {f["field"]: f["value"]
|
|
111
|
+
for f in it.get("metadataFields", [])}}
|
|
112
|
+
for it in items]},
|
|
113
|
+
indent=2))
|
|
114
|
+
return
|
|
115
|
+
click.echo(f"{total} result(s) for {query!r} in KHS Digital Collections")
|
|
116
|
+
for it in items:
|
|
117
|
+
fields = {f["field"]: f["value"] for f in it.get("metadataFields", [])}
|
|
118
|
+
date = fields.get("date", "")
|
|
119
|
+
click.echo(f"- [{it.get('collectionAlias')}:{it.get('itemId')}] "
|
|
120
|
+
f"{it.get('title')}" + (f" ({date})" if date else ""))
|
|
121
|
+
click.echo(f" {CDM_BASE}/digital{it.get('itemLink', '')}")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@click.command("cdm-item")
|
|
125
|
+
@click.argument("alias")
|
|
126
|
+
@click.argument("item_id")
|
|
127
|
+
@click.option("--json", "as_json", is_flag=True, help="Print raw JSON.")
|
|
128
|
+
def cdm_item_cmd(alias: str, item_id: str, as_json: bool) -> None:
|
|
129
|
+
"""Show full metadata for one CONTENTdm item: ALIAS ITEM_ID."""
|
|
130
|
+
url = f"{CDM_API}/singleitem/collection/{alias}/id/{item_id}"
|
|
131
|
+
with _client() as client:
|
|
132
|
+
data = _get(client, url).json()
|
|
133
|
+
if as_json:
|
|
134
|
+
click.echo(json.dumps(data, indent=2))
|
|
135
|
+
return
|
|
136
|
+
click.echo(f"{CDM_BASE}/digital/singleitem/collection/{alias}/id/{item_id}")
|
|
137
|
+
for f in data.get("fields", []):
|
|
138
|
+
click.echo(f"{f.get('label', f.get('key'))}: {f.get('value')}")
|
|
139
|
+
if data.get("contentType"):
|
|
140
|
+
click.echo(f"Content-Type: {data['contentType']}")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@click.command("collections")
|
|
144
|
+
@click.option("--json", "as_json", is_flag=True, help="Print raw JSON.")
|
|
145
|
+
def collections_cmd(as_json: bool) -> None:
|
|
146
|
+
"""List the KHS Digital Collections (CONTENTdm aliases)."""
|
|
147
|
+
with _client() as client:
|
|
148
|
+
data = _get(client, f"{CDM_API}/collections").json()
|
|
149
|
+
cards = data.get("cards", [])
|
|
150
|
+
if as_json:
|
|
151
|
+
click.echo(json.dumps(cards, indent=2))
|
|
152
|
+
return
|
|
153
|
+
click.echo(f"{data.get('totalCollections', len(cards))} collections")
|
|
154
|
+
for c in cards:
|
|
155
|
+
click.echo(f"- {c.get('alias')}: {c.get('title')}")
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@click.command("cdm-url")
|
|
159
|
+
@click.argument("query")
|
|
160
|
+
def cdm_url_cmd(query: str) -> None:
|
|
161
|
+
"""Print the verified KHS catalog web search URL for QUERY."""
|
|
162
|
+
click.echo(f"{CDM_BASE}/cdm/search/searchterm/{quote(query)}/mode/exact")
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
# ---------------------------------------------------------------- Land Office
|
|
166
|
+
def _asp_state(html_text: str) -> dict[str, str]:
|
|
167
|
+
def grab(name: str) -> str:
|
|
168
|
+
m = re.search(r'name="' + re.escape(name) + r'"[^>]*value="([^"]*)"', html_text)
|
|
169
|
+
return m.group(1) if m else ""
|
|
170
|
+
return {
|
|
171
|
+
"__VIEWSTATE": grab("__VIEWSTATE"),
|
|
172
|
+
"__VIEWSTATEGENERATOR": grab("__VIEWSTATEGENERATOR"),
|
|
173
|
+
"__EVENTVALIDATION": grab("__EVENTVALIDATION"),
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _land_post(client: httpx.Client, data: dict[str, str]) -> str:
|
|
178
|
+
try:
|
|
179
|
+
resp = client.post(LAND_URL, data=data)
|
|
180
|
+
except httpx.HTTPError as exc:
|
|
181
|
+
raise click.ClickException(f"Land Office request failed: {exc}")
|
|
182
|
+
if resp.status_code != 200:
|
|
183
|
+
raise click.ClickException(f"Land Office returned HTTP {resp.status_code}")
|
|
184
|
+
return resp.text
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _parse_land_results(page_html: str) -> tuple[int, list[dict[str, str]]]:
|
|
188
|
+
text = _clean(page_html)
|
|
189
|
+
m = re.search(r"(\d+) Results found", text)
|
|
190
|
+
total = int(m.group(1)) if m else 0
|
|
191
|
+
body = text[m.end():] if m else text
|
|
192
|
+
entries = re.split(r"\d+\) Patent #", body)
|
|
193
|
+
results: list[dict[str, str]] = []
|
|
194
|
+
field_re = re.compile(
|
|
195
|
+
r"\s*([\d.]+)\s+Grantee:\s*(.*?)\s+Grant Book & Pg:\s*(.*?)\s+"
|
|
196
|
+
r"Acreage:\s*(.*?)\s+County:\s*(.*?)\s+WaterCourse:\s*(.*?)\s+"
|
|
197
|
+
r"Survey Name:\s*(.*?)\s+Survey Date:\s*(.*?)\s+Grant Date:\s*(.*?)\s+"
|
|
198
|
+
r"Grant Note:\s*(.*?)\s*$",
|
|
199
|
+
re.S)
|
|
200
|
+
for chunk in entries[1:]:
|
|
201
|
+
fm = field_re.match(chunk)
|
|
202
|
+
if not fm:
|
|
203
|
+
continue
|
|
204
|
+
keys = ("patent", "grantee", "grant_book_page", "acreage", "county",
|
|
205
|
+
"watercourse", "survey_name", "survey_date", "grant_date",
|
|
206
|
+
"grant_note")
|
|
207
|
+
results.append(dict(zip(keys, (g.strip() for g in fm.groups()))))
|
|
208
|
+
return total, results
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _print_land(total: int, results: list[dict[str, str]], as_json: bool) -> None:
|
|
212
|
+
if as_json:
|
|
213
|
+
click.echo(json.dumps({"totalResults": total, "results": results}, indent=2))
|
|
214
|
+
return
|
|
215
|
+
click.echo(f"{total} patent(s) found")
|
|
216
|
+
for r in results:
|
|
217
|
+
click.echo(f"- Patent #{r['patent']}: {r['grantee']} "
|
|
218
|
+
f"({r['county']} Co., grant {r['grant_date']}, "
|
|
219
|
+
f"survey {r['survey_date']}, {r['acreage']} acres)")
|
|
220
|
+
click.echo(f" Grant Book & Pg: {r['grant_book_page']}; "
|
|
221
|
+
f"watercourse: {r['watercourse']}; "
|
|
222
|
+
f"survey name: {r['survey_name']}")
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@click.command("land")
|
|
226
|
+
@click.argument("term")
|
|
227
|
+
@click.option("--by", "by", default="grantee", type=click.Choice(sorted(LAND_BY)),
|
|
228
|
+
show_default=True, help="Advanced-search field.")
|
|
229
|
+
@click.option("--limit", default=10, type=click.Choice(["10", "25", "50", "100"]),
|
|
230
|
+
show_default=True, help="Results per page.")
|
|
231
|
+
@click.option("--json", "as_json", is_flag=True, help="Print JSON.")
|
|
232
|
+
def land_cmd(term: str, by: str, limit: str, as_json: bool) -> None:
|
|
233
|
+
"""Advanced search of County Court Orders patents (1835-2000).
|
|
234
|
+
|
|
235
|
+
Example: ky-archives land Lincoln --by grantee
|
|
236
|
+
"""
|
|
237
|
+
with _client() as client:
|
|
238
|
+
page = _get(client, LAND_URL).text
|
|
239
|
+
# Open the advanced-search panel (postback), then search from it.
|
|
240
|
+
adv = _land_post(client, _asp_state(page) | {
|
|
241
|
+
"__EVENTTARGET": "ctl00$ContentPlaceHolder1$LbAdvSearch",
|
|
242
|
+
"__EVENTARGUMENT": ""})
|
|
243
|
+
results_html = _land_post(client, _asp_state(adv) | {
|
|
244
|
+
"__EVENTTARGET": "", "__EVENTARGUMENT": "",
|
|
245
|
+
"ctl00$ContentPlaceHolder1$DdlAdvSearchBy": LAND_BY[by],
|
|
246
|
+
"ctl00$ContentPlaceHolder1$TxtAdvSearchFor": term,
|
|
247
|
+
"ctl00$ContentPlaceHolder1$ddlMatch": "All",
|
|
248
|
+
"ctl00$ContentPlaceHolder1$ddlShow": limit,
|
|
249
|
+
"ctl00$ContentPlaceHolder1$ddlSortBy": "",
|
|
250
|
+
"ctl00$ContentPlaceHolder1$ddlSortDir": "ASC",
|
|
251
|
+
"ctl00$ContentPlaceHolder1$BtnAdvSearch": "Search"})
|
|
252
|
+
total, results = _parse_land_results(results_html)
|
|
253
|
+
_print_land(total, results, as_json)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
@click.command("land-patent")
|
|
257
|
+
@click.argument("number")
|
|
258
|
+
@click.option("--book", default=None, help="Grant book number (quick search).")
|
|
259
|
+
@click.option("--page", default=None, help="Grant book page (quick search).")
|
|
260
|
+
@click.option("--json", "as_json", is_flag=True, help="Print JSON.")
|
|
261
|
+
def land_patent_cmd(number: str, book: str | None, page: str | None, as_json: bool) -> None:
|
|
262
|
+
"""Quick search of County Court Orders patents by patent number.
|
|
263
|
+
|
|
264
|
+
Example: ky-archives land-patent <patent-number>
|
|
265
|
+
"""
|
|
266
|
+
with _client() as client:
|
|
267
|
+
state = _asp_state(_get(client, LAND_URL).text)
|
|
268
|
+
data = state | {
|
|
269
|
+
"__EVENTTARGET": "", "__EVENTARGUMENT": "",
|
|
270
|
+
"ctl00$ContentPlaceHolder1$TxtSPatent": number,
|
|
271
|
+
"ctl00$ContentPlaceHolder1$TxtSBook": book or "",
|
|
272
|
+
"ctl00$ContentPlaceHolder1$TxtSPage": page or "",
|
|
273
|
+
"ctl00$ContentPlaceHolder1$BtnSearch": "Search"}
|
|
274
|
+
results_html = _land_post(client, data)
|
|
275
|
+
total, results = _parse_land_results(results_html)
|
|
276
|
+
_print_land(total, results, as_json)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
# ---------------------------------------------------------------- Preservica
|
|
280
|
+
@click.command("preservica")
|
|
281
|
+
@click.argument("query")
|
|
282
|
+
@click.option("--limit", default=10, type=int, show_default=True)
|
|
283
|
+
@click.option("--json", "as_json", is_flag=True, help="Print JSON.")
|
|
284
|
+
def preservica_cmd(query: str, limit: int, as_json: bool) -> None:
|
|
285
|
+
"""Search the KDLA Preservica e-archives (WordPress search RSS feed).
|
|
286
|
+
|
|
287
|
+
Returns the matching record pages (title + URL). The site's search
|
|
288
|
+
is full-text (titles, descriptions, creators, document contents),
|
|
289
|
+
so open a hit to confirm why it matched. Opening a packet and
|
|
290
|
+
viewing its scans needs the browser; there is no public Preservica
|
|
291
|
+
search API on this host (verified 2026-11-24).
|
|
292
|
+
"""
|
|
293
|
+
url = f"{PRESERVICA_BASE}/search/{quote(query)}/feed/rss2/"
|
|
294
|
+
with _client() as client:
|
|
295
|
+
feed = _get(client, url).text
|
|
296
|
+
results: list[dict[str, str]] = []
|
|
297
|
+
seen: set[str] = set()
|
|
298
|
+
for block in re.findall(r"<item>(.*?)</item>", feed, re.S):
|
|
299
|
+
title_m = re.search(r"<title>(.*?)</title>", block, re.S)
|
|
300
|
+
link_m = re.search(r"<link>(.*?)</link>", block, re.S)
|
|
301
|
+
if not title_m or not link_m:
|
|
302
|
+
continue
|
|
303
|
+
link = link_m.group(1).strip()
|
|
304
|
+
if link in seen:
|
|
305
|
+
continue
|
|
306
|
+
seen.add(link)
|
|
307
|
+
title = _clean(title_m.group(1))
|
|
308
|
+
if title:
|
|
309
|
+
results.append({"title": title, "url": link})
|
|
310
|
+
if len(results) >= limit:
|
|
311
|
+
break
|
|
312
|
+
if as_json:
|
|
313
|
+
click.echo(json.dumps(
|
|
314
|
+
{"search_url": f"{PRESERVICA_BASE}/?s={quote(query)}",
|
|
315
|
+
"feed_url": url, "results": results}, indent=2))
|
|
316
|
+
return
|
|
317
|
+
click.echo(f"KDLA Preservica search: {PRESERVICA_BASE}/?s={quote(query)}")
|
|
318
|
+
if not results:
|
|
319
|
+
click.echo("No results in the search feed.")
|
|
320
|
+
return
|
|
321
|
+
for r in results:
|
|
322
|
+
click.echo(f"- {r['title']}")
|
|
323
|
+
click.echo(f" {r['url']}")
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
# ---------------------------------------------------------------- URLs
|
|
327
|
+
@click.command("urls")
|
|
328
|
+
@click.argument("query")
|
|
329
|
+
def urls_cmd(query: str) -> None:
|
|
330
|
+
"""Print every verified Kentucky search URL for QUERY (no requests)."""
|
|
331
|
+
click.echo("KHS Digital Collections (CONTENTdm web search):")
|
|
332
|
+
click.echo(f" {CDM_BASE}/cdm/search/searchterm/{quote(query)}/mode/exact")
|
|
333
|
+
click.echo("KDLA Preservica e-archives (WordPress search):")
|
|
334
|
+
click.echo(f" {PRESERVICA_BASE}/?s={quote(query)}")
|
|
335
|
+
click.echo("Land Office, County Court Orders patents (form search, no GET URL):")
|
|
336
|
+
click.echo(f" {LAND_URL}")
|
|
337
|
+
click.echo("Pass the Word oral histories (browse/search in browser):")
|
|
338
|
+
click.echo(" https://passtheword.ky.gov/")
|
|
339
|
+
click.echo("KHS research starting page:")
|
|
340
|
+
click.echo(" https://history.ky.gov/research-genealogy")
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
@click.group()
|
|
344
|
+
def cli() -> None:
|
|
345
|
+
"""Search Kentucky archives: KHS, KDLA Preservica, Land Office."""
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
cli.add_command(cdm_cmd)
|
|
349
|
+
cli.add_command(cdm_item_cmd)
|
|
350
|
+
cli.add_command(collections_cmd)
|
|
351
|
+
cli.add_command(cdm_url_cmd)
|
|
352
|
+
cli.add_command(land_cmd)
|
|
353
|
+
cli.add_command(land_patent_cmd)
|
|
354
|
+
cli.add_command(preservica_cmd)
|
|
355
|
+
cli.add_command(urls_cmd)
|
|
356
|
+
|
|
357
|
+
if __name__ == "__main__":
|
|
358
|
+
cli()
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: library-of-michigan
|
|
3
|
+
description: Research Michigan branches at the Library of Michigan (Lansing) and its Michiganology digital portal via the bundled `michiganology` CLI or the website. Covers CLI search, the searchable digital collections (death certificates 1897-1952, Michigan state census, naturalization, WWI service cards, surveyor notebooks and maps, photographs, maps), what is online vs in-person only (tax rolls, plat maps, state census schedules, Abrams Foundation Historical Collection), and planning a Lansing visit. Use when family lines touch Michigan or neighboring Midwest migration routes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Library of Michigan
|
|
7
|
+
|
|
8
|
+
This skill includes a standalone executable Python CLI at `skills/library-of-michigan/scripts/michiganology` using a PEP 723 `#!/usr/bin/env -S uv run --script` shebang with inline dependency (`click`). It shells out to system `curl` for fetches, because Preservica's front door 403s Python httpx requests while curl succeeds; curl must be installed. No virtualenv setup or API key is required.
|
|
9
|
+
|
|
10
|
+
Two institutions share one building and one research mission in Lansing, and the skill covers both:
|
|
11
|
+
|
|
12
|
+
- **Library of Michigan**, 702 W. Kalamazoo St., Lansing, MI 48915. Reference desk 517-335-1477, librarian@michigan.gov. Open Mon-Fri 10 am to 5 pm, Sat 10 am to 4 pm; free admission. Its Abrams Foundation Historical Collection (2nd floor) is one of the largest genealogy collections in the US: census records, cemetery transcriptions, city directories, county and family histories, newspapers from all 83 Michigan counties, land records, vital records, and military indexes.
|
|
13
|
+
- **Archives of Michigan**, same building. Open Mon-Fri 1 to 5 pm, Sat 10 am to 4 pm, phone 517-335-2576. Holds state government records, including the collections digitized on Michiganology.
|
|
14
|
+
|
|
15
|
+
## Bundled CLI (`scripts/michiganology`)
|
|
16
|
+
|
|
17
|
+
Path: `skills/library-of-michigan/scripts/michiganology`
|
|
18
|
+
|
|
19
|
+
### Search all digital collections
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Search a surname across every Michiganology collection
|
|
23
|
+
skills/library-of-michigan/scripts/michiganology search Lincoln
|
|
24
|
+
|
|
25
|
+
# JSON output, 20 hits
|
|
26
|
+
skills/library-of-michigan/scripts/michiganology search Lincoln --limit 20 --json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Note on multi-word queries: Preservica simple search treats unquoted multi-word queries (such as `"Abraham Lincoln"`) as broad OR matches across collections, so a broad search can return county tax rolls or unrelated files. Inspect individual hits with `get` or narrow with Advanced Search on the website.
|
|
30
|
+
|
|
31
|
+
### Inspect an item (`get`) and download the scan (`download`)
|
|
32
|
+
|
|
33
|
+
Search output prints only the item title (often just a surname or certificate number) and URL. Use `get` to read the full Preservica `Item Data` fields (given name, death date, county, city, parents) and `download` to pull the full-resolution JPEG or PDF directly via `curl`:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Read parsed Item Data metadata and direct download link
|
|
37
|
+
skills/library-of-michigan/scripts/michiganology get IO_<uuid>
|
|
38
|
+
skills/library-of-michigan/scripts/michiganology get "https://michigan.access.preservica.com/uncategorized/IO_<uuid>/" --json
|
|
39
|
+
|
|
40
|
+
# Download the full-resolution file (filename inferred from Content-Disposition)
|
|
41
|
+
skills/library-of-michigan/scripts/michiganology download IO_<uuid> --out ./downloads/michiganology
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### List the digital collections
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
skills/library-of-michigan/scripts/michiganology collections
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Shareable search URL
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
skills/library-of-michigan/scripts/michiganology url Lincoln
|
|
54
|
+
# https://michigan.access.preservica.com/?s=Lincoln
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Michiganology: what is searchable online (verified live 2026-11-24)
|
|
58
|
+
|
|
59
|
+
Michiganology (`https://michiganology.org/`) is the Michigan History Center portal; its searchable collections live on Preservica Universal Access at `https://michigan.access.preservica.com/`. Simple search is a stable GET, `/?s=<query>`, and results are server-rendered, so plain HTTP works with no browser, no key, and no sign-in. The CLI shows the first page only; use the website (with its sort and filter sidebar) to page through large result sets.
|
|
60
|
+
|
|
61
|
+
Collections and their live URLs:
|
|
62
|
+
|
|
63
|
+
| Collection | URL |
|
|
64
|
+
|---|---|
|
|
65
|
+
| Death Certificates, 1897-1952 | `https://michigan.access.preservica.com/death-certificates-1897-1952/` |
|
|
66
|
+
| Michigan State Census, 1827-1894 | `https://michigan.access.preservica.com/michigan-state-census/` |
|
|
67
|
+
| Naturalization Records | `https://michigan.access.preservica.com/naturalization-records/` |
|
|
68
|
+
| World War I, Service Cards | `https://michigan.access.preservica.com/world-war-i-service-cards/` |
|
|
69
|
+
| Surveyor Field Notebooks, 1815-1918 | `https://michigan.access.preservica.com/surveyor-field-notebooks/` |
|
|
70
|
+
| Surveyor Maps, 1816-1860 | `https://michigan.access.preservica.com/surveyor-maps/` |
|
|
71
|
+
| General Photograph Collection, ca. 1860-1990 | `https://michigan.access.preservica.com/general-photograph-collection/` |
|
|
72
|
+
| Archives of Michigan Map Collection, ca. 1810-1970 | `https://michigan.access.preservica.com/archives-of-michigan-map-collection/` |
|
|
73
|
+
| Corporation Annual Reports, 1997-2006 | `https://michigan.access.preservica.com/corporation-annual-reports/` |
|
|
74
|
+
|
|
75
|
+
Collection notes:
|
|
76
|
+
|
|
77
|
+
- Death certificates: the index covers 1897-1952. Per library guides (reported, not verified live), digitized certificate images are viewable for records older than 75 years; newer entries are index-only. Michigan death records 1867-1897 predate this collection; use FamilySearch for those.
|
|
78
|
+
- Michigan state census schedules (1827-1894) fill gaps between federal censuses and are a strong online source for pre-1900 Michigan households.
|
|
79
|
+
- Naturalization indexes cover 29 counties (per library guides); the actual records may need an in-person or copy request.
|
|
80
|
+
- The website also has an Advanced Search page with fielded filters (Family Name, Given Name, County, Birth/Death Date, Place, and more), but it is JavaScript-driven with no stable GET pattern verified, so the CLI covers simple search only. Use the website for fielded searches.
|
|
81
|
+
|
|
82
|
+
## What is in-person only
|
|
83
|
+
|
|
84
|
+
Not everything is digitized. Expect to visit Lansing (or order copies) for:
|
|
85
|
+
|
|
86
|
+
- County-level tax rolls and plat maps in physical form; some plat maps and atlases are digitized through the Michigan County Histories and Atlases project (University of Michigan), not Michiganology.
|
|
87
|
+
- State census schedules beyond what Michiganology has digitized, and manuscript census material.
|
|
88
|
+
- Most newspapers: the library holds microfilm newspapers from all 83 counties, but only a subset is online (see the Digital Michigan Newspaper Portal at Central Michigan University's Clarke Historical Library).
|
|
89
|
+
- Vital records on microfilm, probate and court records, and manuscript collections in the Archives.
|
|
90
|
+
- The library catalog (ANSWER) is searchable online before a visit; use it to pull call numbers in advance so reading-room time is spent reading, not searching.
|
|
91
|
+
|
|
92
|
+
## Subscription databases (Michigan residents, library card required)
|
|
93
|
+
|
|
94
|
+
Michigan residents can use the Library of Michigan's subscription databases remotely with a Library of Michigan library card and PIN, via `michigan.gov/libraryofmichigan` online resources. This includes Ancestry Library Edition style resources and MyHeritage Library Edition. These need a personal library card; the CLI does not touch them and no credentials belong in this repo.
|
|
95
|
+
|
|
96
|
+
## Research workflow
|
|
97
|
+
|
|
98
|
+
1. `michiganology search <Surname>` for the broad sweep; note the total count and the strongest first-page hits.
|
|
99
|
+
2. Narrow on the website with Advanced Search: Family Name plus County (for example Wayne, Ingham, or Washtenaw), and filter to the Death Certificates collection for 1897-1952 deaths.
|
|
100
|
+
3. Combine surname and locality (for example `michiganology search "Lincoln Detroit"`) when the surname alone is too noisy; simple search matches either word anywhere, so quote exact names to narrow.
|
|
101
|
+
4. For pre-1897 Michigan deaths and marriages, cross-check FamilySearch Michigan collections; Michiganology's death run starts in 1897.
|
|
102
|
+
5. For land and neighborhood context, pair surveyor maps and the map collection with county plat maps and atlases held in Lansing or digitized at the University of Michigan.
|
|
103
|
+
6. Record every hit in `data/` with its Michiganology item URL; item URLs are stable (`michigan.access.preservica.com/uncategorized/SO_<uuid>` or `IO_<uuid>`).
|
|
104
|
+
|
|
105
|
+
## Environment variables
|
|
106
|
+
|
|
107
|
+
None. No key or account is needed for Michiganology search.
|
|
108
|
+
|
|
109
|
+
## Verified-live note
|
|
110
|
+
|
|
111
|
+
The Michiganology homepage, the Preservica search (`/?s=<query>`), the collections list, and the Library of Michigan address, hours, and phone were verified live on 2026-11-24. Items marked "per library guides" or "reported" were not re-verified live and are labeled as such.
|