#!/usr/bin/bash set -eu cd "$(dirname "$0")/.." echo echo "-> Applying Metadata" IFS=$'\n' update_metadata() { nummer="$(echo "$2" | jq -r '.Ausgabe')" thema="$(echo "$2" | jq -r '.Thema')" author="$(echo "$2" | jq -r '."Chefredakteur(-e)"')" if [ "$1" == "hertzschlag" ]; then titel="HertzSCHLAG $nummer" else titel="HertzBlatt $nummer" fi if [ "$author" == "null" ]; then author="-Author=" else author="-Author=$author" fi if [ "$thema" == "null" ]; then thema="-Subject=" else thema="-Subject=$thema" fi printf "$titel\r\t\t\t\t\t" exiftool -overwrite_original -Creator="Malte Jürgens" -Producer="hsarch.hhgym.de" -Title="$titel" data/$1/pdf/$nummer.pdf data/$1/pdf/compressed/$nummer.pdf $thema $author } echo echo "-> Retrieving Metadata" tmpfile="$(mktemp)" curl https://gitlab.com/maltejur/hsarch/-/raw/master/assets/data.json >"$tmpfile" if [ "$#" -eq 2 ]; then update_metadata "$1" "$(jq -rc ".$1[] | select(.Ausgabe == \"$2\")" "$tmpfile")" else for ausgabe in $(jq -rc ".hertzschlag[]" "$tmpfile"); do update_metadata hertzschlag "$ausgabe" done for ausgabe in $(jq -rc ".hertzblatt[]" "$tmpfile"); do update_metadata hertzblatt "$ausgabe" done fi