mirror of
https://github.com/amiaopensource/ffmprovisr.git
synced 2024-12-26 11:48:21 +01:00
now with getopts
This commit is contained in:
parent
1577451a41
commit
5fd84ee1d7
@ -37,50 +37,39 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "${#}" -eq 0 ]]; then
|
while getopts ":hi:c:" opt; do
|
||||||
_output_prompt
|
case $opt in
|
||||||
exit 0
|
h) output_help ;;
|
||||||
elif [[ "${#}" -eq 1 ]]; then
|
i) input_file=$OPTARG ;;
|
||||||
if [[ "${1}" = '-h' ]]; then
|
c) input_hash=$OPTARG ;;
|
||||||
_output_help
|
*) echo "bad option -${OPTARG}" ; output_prompt ;;
|
||||||
else
|
:) echo "Option -${OPTARG} requires an argument" ; output_prompt ;;
|
||||||
echo -e "${RED}ERROR:${NC} '$1' is an invalid argument."
|
esac
|
||||||
_output_prompt
|
done
|
||||||
fi
|
|
||||||
elif [[ "${#}" -eq 2 ]]; then
|
[ -z "$@" ] && output_prompt
|
||||||
if [[ ! -f "${1}" ]]; then
|
|
||||||
echo -e "${RED}ERROR:${NC} There is no file '$(basename ${1})'."
|
echo -e "${BLUE}Please wait...${NC}"
|
||||||
_output_prompt
|
unset md5_tmp
|
||||||
elif [[ ! -f "${2}" ]]; then
|
if [[ $OSTYPE = "cygwin" ]]; then
|
||||||
echo -e "${RED}ERROR:${NC} There is no file '$(basename ${2})'."
|
md5_tmp=""${USERPROFILE}/$(basename ${input_hash}).tmp""
|
||||||
_output_prompt
|
else
|
||||||
else
|
md5_tmp="${HOME}/$(basename ${input_hash}).tmp"
|
||||||
echo -e "${BLUE}Please wait...${NC}"
|
fi
|
||||||
unset md5_tmp
|
$(ffmpeg -i ${input_file} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
||||||
if [[ $OSTYPE = "cygwin" ]]; then
|
if [[ ! -f ${md5_tmp} ]]; then
|
||||||
md5_tmp=""${USERPROFILE}/$(basename ${2}).tmp""
|
echo -e "${RED}ERROR:${NC} '$(basename ${input_file})' is not an audio-visual file."
|
||||||
else
|
output_prompt
|
||||||
md5_tmp="${HOME}/$(basename ${2}).tmp"
|
fi
|
||||||
fi
|
old_file=$(grep -v '^#' ${input_hash})
|
||||||
$(ffmpeg -y -i ${1} -loglevel 0 -f framemd5 -an ${md5_tmp})
|
tmp_file=$(grep -v '^#' ${md5_tmp})
|
||||||
if [[ ! -f ${md5_tmp} ]]; then
|
if [[ "${old_file}" = "${tmp_file}" ]]; then
|
||||||
echo -e "${RED}ERROR:${NC} '$(basename ${1})' is not an audio-visual file."
|
echo -e "${BLUE}OK${NC} '$(basename ${input_file})' matches '$(basename ${input_hash})'."
|
||||||
output_prompt
|
rm "${md5_tmp}"
|
||||||
fi
|
exit 0
|
||||||
old_file=$(grep -v "^#" ${2})
|
else
|
||||||
tmp_file=$(grep -v "^#" ${md5_tmp})
|
echo -e "${RED}ERROR:${NC} The following differences were detected between '$(basename ${input_file})' and '$(basename ${input_hash})':"
|
||||||
if [[ "${old_file}" = "${tmp_file}" ]]; then
|
diff "${input_hash}" "${md5_tmp}"
|
||||||
echo -e "${BLUE}OK${NC} '$(basename ${1})' matches '$(basename ${2})'."
|
rm "${md5_tmp}"
|
||||||
rm "${md5_tmp}"
|
exit 1
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo -e "${RED}ERROR:${NC} The following differences were detected between '$(basename ${1})' and '$(basename ${2})':"
|
|
||||||
diff "${2}" "${md5_tmp}"
|
|
||||||
rm "${md5_tmp}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "${RED}ERROR:${NC} Too many arguments."
|
|
||||||
_output_prompt
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user