Skip to content

Instantly share code, notes, and snippets.

@benoit74
Created October 27, 2026 13:49
Show Gist options
  • Select an option

  • Save benoit74/0eed29145cfd7b52d2deaf27e8ac4c75 to your computer and use it in GitHub Desktop.

Select an option

Save benoit74/0eed29145cfd7b52d2deaf27e8ac4c75 to your computer and use it in GitHub Desktop.
List Gutenberg languages from ZF config
#!/usr/bin/env bash
BASE="https://api.farm.openzim.org/v2"
LIMIT=100
for EP in recipes schedules; do
SKIP=0; out=""
while :; do
page=$(curl -s "$BASE/$EP?name=gutenberg&limit=$LIMIT&skip=$SKIP")
if ! jq -e '.items' >/dev/null 2>&1 <<<"$page"; then
echo "[$EP] unexpected response:" >&2
echo "$page" | head -c 500 >&2; echo >&2
continue 2
fi
out+=$(jq -r '.items[].name' <<<"$page")$'\n'
count=$(jq -r '.meta.count // 0' <<<"$page")
SKIP=$((SKIP + LIMIT))
[ "$SKIP" -ge "$count" ] && break
done
printf '%s' "$out" \
| sed -nE 's/^gutenberg_([a-z]{2,3})_.*/\1/p' \
| sort -u | paste -sd, -
exit 0
done
echo "Neither endpoint worked; see responses above." >&2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment