Improve scripts for downloading testfiles
* Download only required files so it is < 400 MiB * Download everything from the same server rather than relying on multiple sources
This commit is contained in:
parent
403df73c1c
commit
42d4d5ec5a
|
@ -1,82 +1,30 @@
|
|||
#!/bin/sh
|
||||
#!/bin/sh -e
|
||||
|
||||
testfilespath="$1"
|
||||
|
||||
# determine sequences for formatted output
|
||||
# define helper for colorful output
|
||||
red=$(tput setaf 1)
|
||||
green=$(tput setaf 2)
|
||||
yellow=$(tput setaf 3)
|
||||
blue=$(tput setaf 4)
|
||||
bold=$(tput bold)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
inform() {
|
||||
echo "${bold}==> ${blue}INFO:${normal} ${bold}${1}${normal}"
|
||||
}
|
||||
|
||||
success() {
|
||||
echo "${bold}==> ${green}SUCCESS:${normal} ${bold}${1}${normal}"
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo "${bold}==> ${red}FAILURE:${normal} ${bold}${1}${normal}"
|
||||
}
|
||||
|
||||
skipping() {
|
||||
echo 'archive/files already exist -> skipping download'
|
||||
}
|
||||
|
||||
download() {
|
||||
title="$1" url="$2" filename="$3" destdir="$4"
|
||||
|
||||
inform "Downloading \"$title\" ..."
|
||||
if [[ ! -d $destdir ]]; then
|
||||
# actual download
|
||||
pushd '/tmp'
|
||||
if [[ ! -f $filename ]]; then
|
||||
wget --output-document="$filename" "$url"
|
||||
if [[ $? != 0 ]]; then
|
||||
fail "unable to download: \"$url\""
|
||||
return
|
||||
fi
|
||||
else
|
||||
skipping
|
||||
fi
|
||||
popd
|
||||
|
||||
# extraction
|
||||
mkdir "$destdir"
|
||||
pushd "$destdir"
|
||||
case "$filename" in
|
||||
*.zip) unzip "/tmp/$filename";;
|
||||
*) fail "unable to extract archive: format \"${filename#*.}\" not supported"
|
||||
return;;
|
||||
esac
|
||||
if [[ $? != 0 ]]; then
|
||||
fail "unable to extract \"/tmp/$filename\""
|
||||
return
|
||||
fi
|
||||
popd
|
||||
else
|
||||
skipping
|
||||
fi
|
||||
}
|
||||
|
||||
download_custom() {
|
||||
title="$1" cmd="$2"
|
||||
|
||||
inform "Downloading \"$title\" ..."
|
||||
if [[ ! -d $destdir ]]; then
|
||||
# actual download
|
||||
$cmd
|
||||
if [[ $? != 0 ]]; then
|
||||
fail "unable to download \"$title\" with rsync"
|
||||
return
|
||||
fi
|
||||
else
|
||||
skipping
|
||||
fi
|
||||
}
|
||||
# read args
|
||||
testfilespath="$1"
|
||||
testfileurl="$2"
|
||||
if [[ -z $testfilespath ]] || [[ -z $testfileurl ]]; then
|
||||
echo "Usage: testfilepath testfileurl"
|
||||
echo " testfilepath specifies the directory to store the downloaded files"
|
||||
echo " testfileurl specifies the URL to the server hosting the test files"
|
||||
fi
|
||||
|
||||
# enter testfiles directory
|
||||
if [[ -d $testfilespath ]]; then
|
||||
|
@ -86,29 +34,74 @@ else
|
|||
exit -1
|
||||
fi
|
||||
|
||||
download \
|
||||
'Matroska Test Suite - Wave 1' \
|
||||
'http://downloads.sourceforge.net/project/matroska/test_files/matroska_test_w1_1.zip?r=&ts=1454982254&use_mirror=netix' \
|
||||
'matroska_test_w1_1.zip' \
|
||||
'matroska_wave1'
|
||||
# define list of testfiles to be downloaded
|
||||
testfiles=(
|
||||
'matroska_wave1/logo3_256x256.png'
|
||||
'matroska_wave1/test1.mkv'
|
||||
'matroska_wave1/test2.mkv'
|
||||
'matroska_wave1/test3.mkv'
|
||||
'matroska_wave1/test4.mkv'
|
||||
'matroska_wave1/test5.mkv'
|
||||
'matroska_wave1/test6.mkv'
|
||||
'matroska_wave1/test7.mkv'
|
||||
'matroska_wave1/test8.mkv'
|
||||
'mtx-test-data/mkv/handbrake-chapters-2.mkv'
|
||||
'mtx-test-data/mkv/tags.mkv'
|
||||
'mp4/test1.m4a'
|
||||
'mtx-test-data/aac/he-aacv2-ps.m4a'
|
||||
'mtx-test-data/alac/othertest-itunes.m4a'
|
||||
'mtx-test-data/mp3/id3-tag-and-xing-header.mp3'
|
||||
'mtx-test-data/mp4/10-DanseMacabreOp.40.m4a'
|
||||
'mtx-test-data/mp4/1080p-DTS-HD-7.1.mp4'
|
||||
'mtx-test-data/mp4/dash/dragon-age-inquisition-H1LkM6IVlm4-video.mp4'
|
||||
'mtx-test-data/ogg/qt4dance_medium.ogg'
|
||||
'mtx-test-data/opus/v-opus.ogg'
|
||||
'misc/multiple_id3v2_4_values.mp3'
|
||||
)
|
||||
|
||||
destdir='mtx-test-data'
|
||||
download_custom \
|
||||
'MTX Test Data' \
|
||||
'rsync -rv --links --delete belgarath.bunkus.org::mtx-test-data mtx-test-data'
|
||||
# download the files
|
||||
missing=()
|
||||
for file in "${testfiles[@]}"; do
|
||||
if [[ -f $file ]]; then
|
||||
inform "Skipping already existing $file"
|
||||
continue
|
||||
fi
|
||||
|
||||
destdir='samples.mplayerhq.hu'
|
||||
download_custom \
|
||||
'MPlayer samples' \
|
||||
'wget -r -np -R index.html* http://samples.mplayerhq.hu/A-codecs/lossless'
|
||||
dir=${file%/*}
|
||||
name=${file##*/}
|
||||
url=$testfileurl/$file
|
||||
|
||||
mkdir -p misc && pushd misc
|
||||
download_custom \
|
||||
'ID3v2.4 with multiple strings' \
|
||||
'wget https://trac.ffmpeg.org/raw-attachment/ticket/6949/multiple_id3v2_4_values.mp3'
|
||||
popd
|
||||
inform "Downloading file $file from $url"
|
||||
mkdir -p "$dir"
|
||||
pushd "$dir"
|
||||
if ! wget --output-document="$name" "$url"; then
|
||||
rm "$name"
|
||||
missing+=("$file")
|
||||
fail "Unable to download $file"
|
||||
fi
|
||||
popd
|
||||
done
|
||||
|
||||
# summarize missing files
|
||||
if [[ ! -z $missing ]]; then
|
||||
echo
|
||||
fail "The following files could not be downloaded:"
|
||||
for file in "${missing[@]}"; do
|
||||
echo "$file"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# convert FLAC files for FLAC tests with ffmpeg
|
||||
inform "Creating further testfiles with ffmpeg"
|
||||
mkdir -p flac
|
||||
[[ ! -f flac/test.flac ]] && ffmpeg -i mtx-test-data/alac/othertest-itunes.m4a -c:a flac flac/test.flac # raw FLAC stream
|
||||
[[ ! -f flac/test.ogg ]] && ffmpeg -i flac/test.flac -c:a copy flac/test.ogg # FLAC in Ogg
|
||||
# raw FLAC stream
|
||||
[[ ! -f flac/test.flac ]] \
|
||||
&& ffmpeg -i mtx-test-data/alac/othertest-itunes.m4a -c:a flac flac/test.flac \
|
||||
|| inform "Skipping already existing flac/test.flac"
|
||||
# FLAC in Ogg
|
||||
[[ ! -f flac/test.ogg ]] \
|
||||
&& ffmpeg -i flac/test.flac -c:a copy flac/test.ogg \
|
||||
|| inform "Skipping already existing flac/test.ogg"
|
||||
|
||||
success "All testfiles downloaded/converted!"
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
#!/bin/sh
|
||||
|
||||
# downloads various test files from other projects which are re-used in the tagparser testsuite
|
||||
# note: only a small amount of those files is actually used by the tagparser testsuite
|
||||
# (to download only required files, see download_testfiles.sh)
|
||||
|
||||
# define helper for colorful output
|
||||
red=$(tput setaf 1)
|
||||
green=$(tput setaf 2)
|
||||
yellow=$(tput setaf 3)
|
||||
blue=$(tput setaf 4)
|
||||
bold=$(tput bold)
|
||||
normal=$(tput sgr0)
|
||||
inform() {
|
||||
echo "${bold}==> ${blue}INFO:${normal} ${bold}${1}${normal}"
|
||||
}
|
||||
success() {
|
||||
echo "${bold}==> ${green}SUCCESS:${normal} ${bold}${1}${normal}"
|
||||
}
|
||||
fail() {
|
||||
echo "${bold}==> ${red}FAILURE:${normal} ${bold}${1}${normal}"
|
||||
}
|
||||
skipping() {
|
||||
echo 'archive/files already exist -> skipping download'
|
||||
}
|
||||
|
||||
# read args
|
||||
testfilespath="$1"
|
||||
|
||||
# define helper for downloads
|
||||
download() {
|
||||
title="$1" url="$2" filename="$3" destdir="$4"
|
||||
|
||||
inform "Downloading \"$title\" ..."
|
||||
if [[ ! -d $destdir ]]; then
|
||||
# actual download
|
||||
pushd '/tmp'
|
||||
if [[ ! -f $filename ]]; then
|
||||
wget --output-document="$filename" "$url"
|
||||
if [[ $? != 0 ]]; then
|
||||
fail "unable to download: \"$url\""
|
||||
return
|
||||
fi
|
||||
else
|
||||
skipping
|
||||
fi
|
||||
popd
|
||||
|
||||
# extraction
|
||||
mkdir "$destdir"
|
||||
pushd "$destdir"
|
||||
case "$filename" in
|
||||
*.zip) unzip "/tmp/$filename";;
|
||||
*) fail "unable to extract archive: format \"${filename#*.}\" not supported"
|
||||
return;;
|
||||
esac
|
||||
if [[ $? != 0 ]]; then
|
||||
fail "unable to extract \"/tmp/$filename\""
|
||||
return
|
||||
fi
|
||||
popd
|
||||
else
|
||||
skipping
|
||||
fi
|
||||
}
|
||||
download_custom() {
|
||||
title="$1" cmd="$2"
|
||||
|
||||
inform "Downloading \"$title\" ..."
|
||||
if [[ ! -d $destdir ]]; then
|
||||
# actual download
|
||||
$cmd
|
||||
if [[ $? != 0 ]]; then
|
||||
fail "unable to download \"$title\" with rsync"
|
||||
return
|
||||
fi
|
||||
else
|
||||
skipping
|
||||
fi
|
||||
}
|
||||
|
||||
# enter testfiles directory
|
||||
if [[ -d $testfilespath ]]; then
|
||||
cd "$testfilespath"
|
||||
else
|
||||
fail "specified testfiles directory does not exist"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
download \
|
||||
'Matroska Test Suite - Wave 1' \
|
||||
'http://downloads.sourceforge.net/project/matroska/test_files/matroska_test_w1_1.zip?r=&ts=1454982254&use_mirror=netix' \
|
||||
'matroska_test_w1_1.zip' \
|
||||
'matroska_wave1'
|
||||
|
||||
destdir='mtx-test-data'
|
||||
download_custom \
|
||||
'MTX Test Data' \
|
||||
'rsync -rv --links --delete belgarath.bunkus.org::mtx-test-data mtx-test-data'
|
||||
|
||||
destdir='samples.mplayerhq.hu'
|
||||
download_custom \
|
||||
'MPlayer samples' \
|
||||
'wget -r -np -R index.html* http://samples.mplayerhq.hu/A-codecs/lossless'
|
||||
|
||||
mkdir -p misc && pushd misc
|
||||
download_custom \
|
||||
'ID3v2.4 with multiple strings' \
|
||||
'wget https://trac.ffmpeg.org/raw-attachment/ticket/6949/multiple_id3v2_4_values.mp3'
|
||||
popd
|
Loading…
Reference in New Issue