planes: wikidata/wikipedia import, commons photos and refresh script

This commit is contained in:
2026-10-24 20:10:36 +00:00
parent cc6c7c8ede
commit 2259965a28
5 changed files with 2346 additions and 0 deletions

27
scripts/planes-refresh.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Refresh of the plane pokedex (/trackers/planes) on stan-ovh.
#
# ssh stan@37.187.157.191 'cd ~/dev/website-planes && git fetch -q && git checkout -q --detach origin/main \
# && bun install --frozen-lockfile >/dev/null && scripts/planes-refresh.sh'
#
# 1. bun scripts/planes-import.ts --report-new rebuilds makers/types from Wikidata + English
# Wikipedia (infobox + specs) and notes which makers/types did not exist before. Dex numbers
# are stable (types are matched by Wikidata id).
# 2. bun scripts/planes-photos.ts --missing finds Wikimedia Commons photos for types that
# have none yet (new ones included) and maker logos that are missing.
# stdout: one JSON report {generatedAt, totals, newMakers, newTypes[] (with photo)}.
# Progress goes to stderr. DB_URL is read from the running app container and never printed.
set -euo pipefail
cd "$(dirname "$0")/.."
if [ -z "${DB_URL:-}" ]; then
DB_URL=$(sudo docker inspect personal-website-app-1 --format '{{range .Config.Env}}{{println .}}{{end}}' |
sed -n 's/^DB_URL=//p' | sed 's/@db:5432/@127.0.0.1:5440/')
export DB_URL
fi
report=$(mktemp /tmp/planes-report.XXXXXX.json)
trap 'rm -f "$report"' EXIT
bun scripts/planes-import.ts --report-new "$@" >"$report"
bun scripts/planes-photos.ts --missing --enrich "$report" --fetch