#!/bin/bash # Fetch the SHA-1 hashes from an IA item and ensure that they match the local files (i.e. that the upload was successful) identifier="$1"; escapedIdentifier="$(sed 's/[.[\*^$()+?{|]/\\&/g' <<<"${identifier}")"; sha1sum -c <(curl -sL "https://archive.org/download/${identifier}/${identifier}_files.xml" | tr -d '\n' | grep -Po '' | grep 'source="original".*' | sed 's,^.*name=",,; s,".*, ,; s,.*$,,' | grep -Pv "^${escapedIdentifier}"'(\.cdx\.(gz|idx)|_meta\.(sqlite|xml)) ' | awk '{ print $2 " " $1 }');