biome: 1.9.2 -> 1.9.3 (#349335)
[NixPkgs.git] / pkgs / development / python-modules / av / update-test-samples.bash
blob5b0b1966d43b2f08f3f22649a717a62b7cbac49e
1 #!/usr/bin/env bash
3 set -o errexit
4 set -o nounset
6 if test "$#" != 1; then
7 printf >&2 'usage: update-test-samples.bash /path/to/PyAV/source\n'
8 exit 2
9 fi
11 pyav_source=$1
13 exec > "$(dirname "$(readlink -f "$0")")/test-samples.toml"
15 fetch() {
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}"
23 fetch_all() {
24 function=$1
25 base_path=$2
26 base_url=$3
28 samples=$(
29 rg \
30 --only-matching \
31 --no-filename \
32 "\\b${function}\\([\"']([^\"']+)[\"']\\)" \
33 --replace '$1' \
34 "${pyav_source}"
36 unique_samples=$(sort -u <<< "${samples}")
38 while IFS= read -r sample; do
39 fetch "${base_path}/${sample}" "${base_url}/${sample}"
40 done <<< "${unique_samples}"
43 fetch_all fate_suite fate-suite "http://fate.ffmpeg.org/fate-suite"
44 fetch_all curated pyav-curated "https://pyav.org/datasets"