#!/usr/bin/env bash # Re-download the open-access OS-ELM / ELM reference PDFs. # Idempotent: skips files that already exist and are genuine PDFs. # Fails loudly (exit 1) if a download does not yield a real PDF. # # Only papers verified open access in CITATION NOTES (see README.md) are listed. # Paywalled items are deliberately absent - there is nothing to fetch. # # huang_wang_lan_2011_elm_survey.pdf (10.1007/s13042-011-0019-y, IJMLC 2(2):107-122) # is paywalled with no OA copy and is deliberately NOT in this list: adding a # publisher URL here would just curl a bot-challenge page. It was supplied by # hand - see README.md "Manually supplied". This script only ever writes or # removes the filenames listed below, so that file is never touched. set -uo pipefail DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" UA='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0 Safari/537.36' mkdir -p "$DIR" # name|url PAPERS=( "zang_2025_predictive_plasticity_elm_fpga.pdf|https://arxiv.org/pdf/2512.21777" "zang_2025_osos_elm_single_photon.pdf|https://arxiv.org/pdf/2504.09028" "liu_2025_high_order_regularization.pdf|https://arxiv.org/pdf/2505.08129" "lu_2017_adaptive_weight_oselm.pdf|https://mdpi-res.com/d_attachment/applsci/applsci-07-00217/article_deploy/applsci-07-00217.pdf" ) fail=0 for entry in "${PAPERS[@]}"; do name="${entry%%|*}"; url="${entry#*|}"; out="$DIR/$name" if [ -s "$out" ] && file -b "$out" | grep -q '^PDF'; then echo "SKIP $name (already present, $(stat -c%s "$out") bytes)" continue fi # MDPI blocks plain /pdf with a Referer-less request; arXiv does not care. echo "GET $name <- $url" if ! curl -fL -A "$UA" -H 'Referer: https://www.mdpi.com/' -H 'Accept: application/pdf,*/*' \ --retry 3 --retry-delay 2 -o "$out" "$url"; then echo "FAIL $name (curl error)" >&2; rm -f "$out"; fail=1; continue fi if ! file -b "$out" | grep -q '^PDF'; then echo "FAIL $name: not a PDF ($(file -b "$out"))" >&2 rm -f "$out"; fail=1; continue fi echo "OK $name ($(stat -c%s "$out") bytes)" done [ "$fail" -eq 0 ] || { echo "one or more downloads failed" >&2; exit 1; } echo "all open-access papers present in $DIR"