mirror of
https://github.com/amiaopensource/ffmprovisr.git
synced 2025-02-25 16:34:18 +01:00
Argh! Ugly error
- hope this works also on Windows (otherwise please open an issue)
This commit is contained in:
parent
937061e354
commit
588482ff3b
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
SCRIPT=$(basename "${0}")
|
SCRIPT=$(basename "${0}")
|
||||||
VERSION='2016-10-02'
|
VERSION='2016-10-08'
|
||||||
AUTHOR='ffmprovisr'
|
AUTHOR='ffmprovisr'
|
||||||
RED='\033[1;31m'
|
RED='\033[1;31m'
|
||||||
BLUE='\033[1;34m'
|
BLUE='\033[1;34m'
|
||||||
@ -13,7 +13,7 @@ fi
|
|||||||
|
|
||||||
_output_prompt(){
|
_output_prompt(){
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: ${SCRIPT} [-h | <av_file> <md5_file>]
|
Usage: ${SCRIPT} [-h | -i <av_file> -m <md5_file>]
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ Syntax:
|
|||||||
Prompts a short help message.
|
Prompts a short help message.
|
||||||
${SCRIPT} -h
|
${SCRIPT} -h
|
||||||
This help.
|
This help.
|
||||||
${SCRIPT} <av_file> <md5_file>
|
${SCRIPT} -i <av_file> -m <md5_file>
|
||||||
Pass to the script the audio-visual file and the corresponding MD5
|
Pass to the script the audio-visual file and the corresponding MD5
|
||||||
file to check.
|
file to check.
|
||||||
Dependency:
|
Dependency:
|
||||||
@ -37,29 +37,93 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts ":hi:c:" opt; do
|
while getopts ":hi:m:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
h) output_help ;;
|
h) _output_help ;;
|
||||||
i) input_file=$OPTARG ;;
|
i) input_file=$OPTARG ;;
|
||||||
c) input_hash=$OPTARG ;;
|
m) input_hash=$OPTARG ;;
|
||||||
*) echo "bad option -${OPTARG}" ; output_prompt ;;
|
*) echo "bad option -${OPTARG}" ; _output_prompt ;;
|
||||||
:) echo "Option -${OPTARG} requires an argument" ; output_prompt ;;
|
:) echo "Option -${OPTARG} requires an argument" ; _output_prompt ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z "$@" ] && output_prompt
|
[ -z "$@" ] && _output_prompt
|
||||||
|
|
||||||
echo -e "${BLUE}Please wait...${NC}"
|
echo -e "${BLUE}Please wait...${NC}"
|
||||||
unset md5_tmp
|
unset md5_tmp
|
||||||
if [[ $OSTYPE = "cygwin" ]]; then
|
if [[ $OSTYPE = "cygwin" ]]; then
|
||||||
md5_tmp=""${USERPROFILE}/$(basename ${input_hash}).tmp""
|
md5_tmp=""${USERPROFILE}/$(basename ${input_hash}).tmp""
|
||||||
else
|
else
|
||||||
md5_tmp="${HOME}/$(basename ${input_hash}).tmp"
|
md5_tmp="${HOME}/$(basename ${input_hash}).tmp"
|
||||||
fi
|
fi
|
||||||
$(ffmpeg -i ${input_file} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
$(ffmpeg -i ${input_file} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
||||||
if [[ ! -f ${md5_tmp} ]]; then
|
if [[ ! -f ${md5_tmp} ]]; then
|
||||||
echo -e "${RED}ERROR:${NC} '$(basename ${input_file})' is not an audio-visual file."
|
echo -e "${RED}ERROR:${NC} '$(basename ${input_file})' is not an audio-visual file."
|
||||||
output_prompt
|
_output_prompt
|
||||||
|
fi
|
||||||
|
old_file=$(grep -v '^#' ${input_hash})
|
||||||
|
tmp_file=$(grep -v '^#' ${md5_tmp})
|
||||||
|
if [[ "${old_file}" = "${tmp_file}" ]]; then
|
||||||
|
echo -e "${BLUE}OK${NC} '$(basename ${input_file})' matches '$(basename ${input_hash})'."
|
||||||
|
rm "${md5_tmp}"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo -e "${RED}ERROR:${NC} The following differences were detected between '$(basename ${input_file})' and '$(basename ${input_hash})':"
|
||||||
|
diff "${input_hash}" "${md5_tmp}"
|
||||||
|
rm "${md5_tmp}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${old_file}" = "${tmp_file}" ]]; then
|
||||||
|
echo -e "${BLUE}OK${NC} '$(basename ${input_file})' matches '$(basename ${input_hash})'."
|
||||||
|
rm "${md5_tmp}"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo -e "${RED}ERROR:${NC} The following differences were detected between '$(basename ${input_file})' and '$(basename ${input_hash})':"
|
||||||
|
diff "${input_hash}" "${md5_tmp}"
|
||||||
|
rm "${md5_tmp}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
$(ffmpeg -i ${input_file} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
||||||
|
if [[ ! -f ${md5_tmp} ]]; then
|
||||||
|
echo -e "${RED}ERROR:${NC} '$(basename ${input_file})' is not an audio-visual file."
|
||||||
|
_output_prompt
|
||||||
|
fi
|
||||||
|
old_file=$(grep -v '^#' ${input_hash})
|
||||||
|
tmp_file=$(grep -v '^#' ${md5_tmp})
|
||||||
|
if [[ "${old_file}" = "${tmp_file}" ]]; then
|
||||||
|
echo -e "${BLUE}OK${NC} '$(basename ${input_file})' matches '$(basename ${input_hash})'."
|
||||||
|
rm "${md5_tmp}"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo -e "${RED}ERROR:${NC} The following differences were detected between '$(basename ${input_file})' and '$(basename ${input_hash})':"
|
||||||
|
diff "${input_hash}" "${md5_tmp}"
|
||||||
|
rm "${md5_tmp}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
i) input_file=$OPTARG ;;
|
||||||
|
c) input_hash=$OPTARG ;;
|
||||||
|
m) echo "bad option -${OPTARG}" ; _output_prompt ;;
|
||||||
|
:) echo "Option -${OPTARG} requires an argument" ; _output_prompt ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -z "$@" ] && _output_prompt
|
||||||
|
|
||||||
|
echo -e "${BLUE}Please wait...${NC}"
|
||||||
|
unset md5_tmp
|
||||||
|
if [[ $OSTYPE = "cygwin" ]]; then
|
||||||
|
md5_tmp=""${USERPROFILE}/$(basename ${input_hash}).tmp""
|
||||||
|
else
|
||||||
|
md5_tmp="${HOME}/$(basename ${input_hash}).tmp"
|
||||||
|
fi
|
||||||
|
$(ffmpeg -i ${input_file} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
||||||
|
if [[ ! -f ${md5_tmp} ]]; then
|
||||||
|
echo -e "${RED}ERROR:${NC} '$(basename ${input_file})' is not an audio-visual file."
|
||||||
|
_output_prompt
|
||||||
fi
|
fi
|
||||||
old_file=$(grep -v '^#' ${input_hash})
|
old_file=$(grep -v '^#' ${input_hash})
|
||||||
tmp_file=$(grep -v '^#' ${md5_tmp})
|
tmp_file=$(grep -v '^#' ${md5_tmp})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user