New version using getopts

... as in the other amiaopensource repository.
This commit is contained in:
Reto Kromer 2016-10-08 12:10:19 +02:00 committed by GitHub
parent 3ac0e21659
commit 94b0690594

View File

@ -38,17 +38,15 @@ EOF
} }
while getopts ":hi:m:" 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 ;;
m) input_hash=$OPTARG ;; m) input_hash=$OPTARG ;;
*) echo "bad option -${OPTARG}" ; _output_prompt ;; *) echo -e "${RED}Error:${NC }bad option -${OPTARG}" ; _output_prompt ;;
:) echo "Option -${OPTARG} requires an argument" ; _output_prompt ;; :) echo -e "${RED}Error:${NC} option -${OPTARG} requires an argument" ; _output_prompt ;;
esac esac
done done
[ -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
@ -57,9 +55,7 @@ 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 [[ ! -f ${md5_tmp} ]] && _output_prompt
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})