mirror of
https://github.com/amiaopensource/ffmprovisr.git
synced 2025-02-25 16:34:18 +01:00
Merge pull request #100 from amiaopensource/retokromer-patch-1
housekeeping
This commit is contained in:
commit
3ac0e21659
@ -1,25 +1,31 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
SCRIPT=$(basename "${0}")
|
SCRIPT=$(basename "${0}")
|
||||||
VERSION='2016-07-25'
|
VERSION='2016-10-08'
|
||||||
AUTHOR='ffmprovisr'
|
AUTHOR='ffmprovisr'
|
||||||
RED='\033[1;31m'
|
RED='\033[1;31m'
|
||||||
BLUE='\033[1;34m'
|
BLUE='\033[1;34m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
_output_prompt() {
|
if [[ $OSTYPE = "cygwin" ]] || [ ! $(which diff) ]; then
|
||||||
cat <<END_OF_MSG
|
echo -e "${RED}ERROR:${NC} 'diff' is not installed by default. Please install 'diffutils' from Cygwin."
|
||||||
Usage: ${SCRIPT} [-h | <av_file> <md5_file>]
|
exit 1
|
||||||
END_OF_MSG
|
fi
|
||||||
|
|
||||||
|
_output_prompt(){
|
||||||
|
cat <<EOF
|
||||||
|
Usage: ${SCRIPT} [-h | -i <av_file> -m <md5_file>]
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
_output_help() {
|
_output_help(){
|
||||||
cat <<END_OF_MSG
|
cat <<EOF
|
||||||
Syntax:
|
Syntax:
|
||||||
${SCRIPT}
|
${SCRIPT}
|
||||||
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:
|
||||||
@ -27,58 +33,43 @@ Dependency:
|
|||||||
About:
|
About:
|
||||||
Version: ${VERSION}
|
Version: ${VERSION}
|
||||||
Website: https://github.com/amiaopensource/ffmprovisr/blob/gh-pages/check_framemd5.sh
|
Website: https://github.com/amiaopensource/ffmprovisr/blob/gh-pages/check_framemd5.sh
|
||||||
END_OF_MSG
|
EOF
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $OSTYPE == "cygwin" ]] || [ ! $(which diff) ] ; then
|
while getopts ":hi:m:" opt; do
|
||||||
echo -e "${RED}ERROR:${NC} diff is not installed by default. Please install diffutils from Cygwin."
|
case $opt in
|
||||||
exit 1
|
h) _output_help ;;
|
||||||
fi
|
i) input_file=$OPTARG ;;
|
||||||
|
m) input_hash=$OPTARG ;;
|
||||||
|
*) echo "bad option -${OPTARG}" ; _output_prompt ;;
|
||||||
|
:) echo "Option -${OPTARG} requires an argument" ; _output_prompt ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ "${#}" -eq 0 ]; then
|
[ -z "$@" ] && _output_prompt
|
||||||
_output_prompt
|
|
||||||
exit 0
|
echo -e "${BLUE}Please wait...${NC}"
|
||||||
elif [ "${#}" -eq 1 ]; then
|
unset md5_tmp
|
||||||
if [ "${1}" == '-h' ]; then
|
if [[ $OSTYPE = "cygwin" ]]; then
|
||||||
_output_help
|
md5_tmp=""${USERPROFILE}/$(basename ${input_hash}).tmp""
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo -e "${RED}ERROR:${NC} '$1' is an invalid argument."
|
|
||||||
_output_prompt
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif [ "${#}" -eq 2 ]; then
|
|
||||||
if ! [ -f "${1}" ]; then
|
|
||||||
echo -e "${RED}ERROR:${NC} There is no file '$(basename ${1})'."
|
|
||||||
_output_prompt
|
|
||||||
exit 1
|
|
||||||
elif ! [ -f "${2}" ]; then
|
|
||||||
echo -e "${RED}ERROR:${NC} There is no file '$(basename ${2})'."
|
|
||||||
_output_prompt
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
unset md5_tmp
|
|
||||||
if [[ $OSTYPE == "cygwin" ]]; then
|
|
||||||
md5_tmp=""${USERPROFILE}/$(basename ${2}).tmp""
|
|
||||||
else
|
|
||||||
md5_tmp="${HOME}/$(basename ${2}).tmp"
|
|
||||||
fi
|
|
||||||
echo "Please wait..."
|
|
||||||
$(ffmpeg -y -i ${1} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
|
||||||
old_file=$(grep -v '^#' ${2})
|
|
||||||
tmp_file=$(grep -v '^#' ${md5_tmp})
|
|
||||||
if [ "${old_file}" = "${tmp_file}" ]; then
|
|
||||||
echo -e "${BLUE}OK${NC} '$(basename ${1})' matches '$(basename ${2})'."
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo -e "${RED}ERROR:${NC} The following differences were detected between '$(basename ${1})' and '$(basename ${2})':"
|
|
||||||
diff "${2}" "${md5_tmp}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
rm "${md5_tmp}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo -e "${RED}ERROR:${NC} Too many arguments."
|
md5_tmp="${HOME}/$(basename ${input_hash}).tmp"
|
||||||
_output_prompt
|
fi
|
||||||
exit 1
|
$(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
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user