# Rune photo scraper A working collector for photographs of runic inscriptions, with a local gallery, source records, credits, resumable discovery, and duplicate checks. Open `sample-archive/gallery.html` after extracting this folder to browse the included live sample. This does not require Python or an internet connection. The sample is a bounded collection of candidate image records, not an exhaustive or fully authenticated corpus. ## Run it Use Python 3.11 or newer. From this extracted folder, run ```bash python -m runes run --max-pages 20 --downloads 100 ``` Open `archive/gallery.html`. Repeat the command to continue from the saved source cursors. The page budget is **per source per invocation**. The download budget counts attempts, including failed attempts. It does not silently increase a bounded run into an internet-wide crawl. No installation is required for collection and basic image downloads. Installing the optional image dependency enables full image decoding, dimensions, orientation handling, and visual similarity detection. ```bash python -m pip install Pillow ``` The same command works on Windows, macOS, and Linux when `python` is a Python 3.11+ interpreter. Some systems name it `python3`. ## What is implemented | Source | Collection method | Current requirements | | --- | --- | --- | | Swedish heritage collections through K-samsök | Official XML API, paginated searches, every image in each returned record | No API key. Image hosts may restrict retrieval independently. | | Wikimedia Commons photographs | Official image API, recursive categories, pagination, image credits and licences | No API key. Photo metadata remains a source claim. | | Flickr | Official API, albums and multilingual photo searches | Set `FLICKR_API_KEY`. This adapter has fixture tests; no live key was available during development. | | Additional photo websites | A bounded HTML crawler with explicit seeds and directory prefixes | Enable `sources.pages` or change its settings. It respects robots.txt and page directives. No JavaScript execution. | `sources.toml` controls queries, roots, page sizes, category depth, exclusions, request spacing, and additional websites. The default searches target historical Germanic runic writing. Other scripts called “runes” require their own explicit source selection. Flickr is skipped with a recorded explanation when no key is available. On macOS/Linux, a key can be supplied to the current shell with `export FLICKR_API_KEY='your key'`. In Windows PowerShell, use `$env:FLICKR_API_KEY='your key'`. Do not put keys in source files or commits. Christer Hamp's website is supplied as an optional example rather than a bulk source with assumed permission. Its historical index currently declares `noindex,nofollow`. The page adapter records that restriction and stops following it. Its page-level licence is never assigned automatically to third-party images. ## Keep collecting ```bash # Discover records without downloading image files. python -m runes collect --max-pages 20 # Use one source, retaining its pagination state. python -m runes collect --source commons --max-pages 50 # Download original image URLs where an explicit supported image licence is present. python -m runes download --downloads 100 # Build a smaller browsing copy using previews explicitly supplied by each source. python -m runes download --downloads 100 --rendition preview # Recheck discovery from the beginning. Images and human reviews are preserved. python -m runes collect --refresh --max-pages 20 # Re-fetch image bytes, for example when checking an altered source image. python -m runes download --redownload --downloads 30 # Rebuild the gallery and exports after changes. python -m runes export # Inspect progress, failures, and configured scope boundaries. python -m runes status # Check local image hashes and SQLite integrity. python -m runes verify # Find exact duplicates and possible visually similar images. python -m runes duplicates --radius 4 ``` All commands accept `--out FOLDER` and `--config FILE`. For the included sample, use `--out sample-archive`. Source cursors are keyed to the source configuration. Changing a query, root list, or page size starts a new discovery scope while preserving the earlier records. A completed scope does not establish complete coverage of a website or the internet. Refresh records periodically to check for additions, corrections, and current image rights. The default HTTP cache lasts 24 hours. ## Review the actual photographs Every new image record starts as **unreviewed**. Source labels and text rules can identify likely photographs, drawings, modern items, or nonrunic material. They do not authenticate an inscription. False positives and incomplete descriptions remain possible. The gallery can filter by source, review, and a setting checked by a reviewer. “In situ” is a reviewed setting, not a label assigned from an outdoor-looking photograph. A relocated stone, a museum object, and an original findspot are distinct. Photograph geotags are preserved without treating them as archaeological findspots. After inspecting an image and its evidence, use the record ID shown in its detail view. ```bash python -m runes review --id RECORD_ID --decision include --context in_situ --object-id "U 123" --note "Checked against the linked catalogue and image." python -m runes review --id RECORD_ID --decision exclude --note "Drawing rather than a photograph." ``` These commands rebuild the gallery. Changing a decision alone preserves earlier review notes and the assigned identity. Use an explicit empty string to clear an optional text field. Discovery refreshes preserve human reviews. Catalogue identifiers extracted from text remain **candidate matches** until someone checks them. No object identities or translations are invented. `--actor assistant` records an assistant's visual assessment separately from a user's review. The included sample uses that label for obvious maps and drawn charts excluded after inspection. These assessments do not count as human-confirmed inscriptions. A content-selection review is not an archaeological authentication. ## Files produced | File | Contents | | --- | --- | | `gallery.html` | Searchable local photo gallery, detail views, source links, and credits | | `images/` | Content-addressed image files, named by their SHA-256 hashes | | `archive.sqlite3` | Image records, source observations, reviews, HTTP cache, discovery cursors, and run history | | `manifest.jsonl` | Image records with original metadata, URLs, timestamps, downloaded rendition, and review state | | `credits.csv` | Source, photographer, image licence, and downloaded-file attribution | | `run-report.json` | Source progress, bounds, and record/file counts | | `download-report.json` | Most recent download budget results and failures | | `duplicates.json` | Exact byte duplicates and visual similarity candidates | An image may have several source records. Identical bytes share a file, and the gallery can combine their cards without discarding provenance. Visual similarity only flags pairs for inspection. It never deletes a different view of the same object. Source record counts and unique image file counts are not physical inscription counts. Original and preview URLs are both retained. `downloaded_url` identifies the rendition whose bytes were actually saved. Downloading a preview never relabels it as an original. ## Rights and access handling The collector separates image licences from catalogue metadata licences. A CC0 metadata record does not authorize every associated image. Automatic downloads accept explicitly stated CC0, public-domain statements, CC BY, and CC BY-SA. Unspecified rights, noncommercial/no-derivatives terms, and “no known copyright restrictions” statements remain source-linked records rather than automatic downloads. Attribution and licence links stay attached to each record. Source rights statements are preserved rather than independently adjudicated. Documented APIs are used directly. The HTML and image fetcher respects robots.txt, request spacing, retries, and server retry delays. A blocked or unavailable robots endpoint prevents that host's non-API requests in the current run. The failure is recorded. There is no login automation, CAPTCHA bypass, or rotating-proxy evasion. ## Current limits This version is a functioning foundation for a broad rune photograph archive. It has four adapters, not universal coverage. RuneS, Danish and Norwegian museum systems, other national collections, IIIF repositories, and further photo websites need individually verified access routes before they can be described as integrated. There is no global web-search crawler, automatic rune reading, image-based authenticity judgment, or complete historical object reconciliation. The default Commons category traversal skips named categories concerning maps, heraldry, information boards, books, art, tattoos, logos, fonts, and replicas. Individual photographs can still require review. The page crawler is bounded by its configured depth and prefixes; it does not run JavaScript or automatically cross into another website. The sample's original run logs retain failed attempts as well as successful attempts. A run labelled `bounded` stopped at its requested page budget. A missing Flickr key is a separate skipped state. Neither is reported as exhaustive completion. ## Validation ```bash python -m unittest discover -s tests -v ``` The tests check source pagination, continuation tokens, interrupted-page recovery, duplicate preservation, image/metadata licence separation, persistent human reviews, original URL preservation, page crawl restrictions, HTML escaping, proxy compatibility, image hashing, and file verification. See `VALIDATION.md` for the actual packaged sample's results. ## Primary source documentation * K-samsök API documentation. https://www.raa.se/hitta-information/k-samsok/att-anvanda-k-samsok/kom-igang-med-k-samsoks-api/ * K-samsök current terms and image/metadata distinction. https://www.raa.se/museer/digital-omstallning-pa-museiomradet/k-samsok-en-digital-dataformedlingstjanst-for-kulturarv/att-anvanda-data-fran-k-samsok/ * Runor data architecture. https://www.raa.se/hitta-information/runor/vanliga-fragor-runor/ * MediaWiki image API. https://www.mediawiki.org/wiki/API:Imageinfo * MediaWiki category pagination. https://www.mediawiki.org/wiki/API:Categorymembers * Flickr album API. https://www.flickr.com/services/api/flickr.photosets.getPhotos.html * Flickr photo licence API. https://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html