at master 1.0 kB view raw
1#!/usr/bin/env bash 2 3set -o errexit 4set -o nounset 5 6if test "$#" != 1; then 7 printf >&2 'usage: update-test-samples.bash /path/to/PyAV/source\n' 8 exit 2 9fi 10 11pyav_source=$1 12 13exec > "$(dirname "$(readlink -f "$0")")/test-samples.toml" 14 15fetch() { 16 path=$1 17 url=$2 18 prefetch_json=$(nix store prefetch-file --json "${url}") 19 sri_hash=$(jq -r .hash <<< "${prefetch_json}") 20 printf '"%s" = { url = "%s", hash = "%s" }\n' "${path}" "${url}" "${sri_hash}" 21} 22 23fetch_all() { 24 function=$1 25 base_path=$2 26 base_url=$3 27 28 samples=$( 29 rg \ 30 --only-matching \ 31 --no-filename \ 32 "\\b${function}\\([\"']([^\"']+)[\"']\\)" \ 33 --replace '$1' \ 34 "${pyav_source}" 35 ) 36 unique_samples=$(sort -u <<< "${samples}") 37 38 while IFS= read -r sample; do 39 fetch "${base_path}/${sample}" "${base_url}/${sample}" 40 done <<< "${unique_samples}" 41} 42 43fetch_all fate_suite fate-suite "http://fate.ffmpeg.org/fate-suite" 44fetch_all curated pyav-curated "https://pyav.org/datasets"