summaryrefslogtreecommitdiffstats
path: root/extra/sitemap/release_url_lists.sh
diff options
context:
space:
mode:
authorbnewbold <bnewbold@archive.org>2020-08-20 21:17:59 +0000
committerbnewbold <bnewbold@archive.org>2020-08-20 21:17:59 +0000
commitdaf91b137483b7345448b597289c78f8fb3f9969 (patch)
tree712c27d902235d8d007763b512c57eaecd8045ad /extra/sitemap/release_url_lists.sh
parent5007ee299ce07b31db6d48cd4ab2587f87af53ab (diff)
parent2a98d10be1cc1368f9510745bff07c343974d4a7 (diff)
downloadfatcat-daf91b137483b7345448b597289c78f8fb3f9969.tar.gz
fatcat-daf91b137483b7345448b597289c78f8fb3f9969.zip
Merge branch 'bnewbold-sitemap' into 'master'
basic sitemap setup See merge request webgroup/fatcat!79
Diffstat (limited to 'extra/sitemap/release_url_lists.sh')
-rwxr-xr-xextra/sitemap/release_url_lists.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/extra/sitemap/release_url_lists.sh b/extra/sitemap/release_url_lists.sh
new file mode 100755
index 00000000..d5c8d4ef
--- /dev/null
+++ b/extra/sitemap/release_url_lists.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+set -e # fail on error
+set -u # fail if variable not set in substitution
+set -o pipefail # fail if part of a '|' command fails
+
+: ${1?' You you did not supply a date argument'}
+: ${2?' You you did not supply an input file (JSON gzip)'}
+if [ ! -f $2 ] ; then
+ echo "Input file not found: $2" && exit 1;
+fi
+
+# eg, 2020-08-19
+DATE="$1"
+# eg, release_export_expanded.json.gz
+EXPORT_FILE_GZ="$2"
+
+# filter to fulltext releases only, then filter to only one hit per work
+zcat $EXPORT_FILE_GZ \
+ | rg '"release_ids"' \
+ | rg 'archive.org/' \
+ | rg -v '"stub"' \
+ | jq -r '[.work_id, .ident] | @tsv' \
+ | uniq -w 26 \
+ | cut -f 2 \
+ | awk '{print "https://fatcat.wiki/release/" $1 }' \
+ | split --lines 20000 - sitemap-releases-$DATE- -d -a 5 --additional-suffix .txt
+
+gzip sitemap-releases-*.txt