From afca94286815fccdfb45e40df24957a0c80e583a Mon Sep 17 00:00:00 2001 From: Reto Kromer Date: Sun, 10 Jul 2016 14:32:35 +0200 Subject: [PATCH 1/3] 'check_framemd5.sh' Bash script for review - It's more or less the situation... on February. - I changed GREEN to BLUE, in order to make the script suitable for users suffering red-green colour blindness. --- check_framemd5.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 check_framemd5.sh diff --git a/check_framemd5.sh b/check_framemd5.sh new file mode 100644 index 0000000..28709d0 --- /dev/null +++ b/check_framemd5.sh @@ -0,0 +1,86 @@ +#!/bin/bash + SCRIPT=$(basename $0) + VERSION='2016-07-10' + AUTHOR='Kieran O\'Leary, Reto Kromer' + RED='\033[1;31m' + BLUE='\033[1;34m' + NC='\033[0m' + +output_prompt() { + cat < ] +END_OF_MSG +} + +output_version() { + cat < + Pass to the script the audio-visual file and the corresponding MD5 + file to check. +Dependency: + ffmpeg +END_OF_MSG +} + +if [ ! $(which diff) ] ; then + echo -e "${RED}ERROR:${NC} diff is not installed by default. Please install diffutils from Cygwin." + exit 1 +fi + +if [ "$#" -eq 0 ]; then + output_prompt + exit 0 +elif [ "$#" -eq 1 ]; then + if [ "$1" == '-h' ]; then + output_help + exit 0 + elif [ "$1" == '-v' ]; then + output_version + 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 + if [[ $OSTYPE == "cygwin" ]]; then + md5_tmp=""$USERPROFILE/$(basename $2).tmp"" + else + md5_tmp="$HOME/$(basename $2).tmp" + fi + $(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)'." + else + echo -e "${RED}ERROR:${NC} The following differences were detected between '$(basename $1)' and '$(basename $2)':" + diff "$2" "$md5_tmp" + fi + rm "$md5_tmp" + fi +else + echo -e "${RED}ERROR:${NC} Too many arguments." + output_prompt + exit 1 +fi From 53cb0e2023cdbc18ca15c2c9ebc2e5285e3e98af Mon Sep 17 00:00:00 2001 From: Reto Kromer Date: Sun, 10 Jul 2016 14:35:06 +0200 Subject: [PATCH 2/3] more general path --- check_framemd5.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_framemd5.sh b/check_framemd5.sh index 28709d0..b6a2c44 100644 --- a/check_framemd5.sh +++ b/check_framemd5.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash SCRIPT=$(basename $0) VERSION='2016-07-10' AUTHOR='Kieran O\'Leary, Reto Kromer' From add5079faa20b6a2dab0d11a9bfdbed237d15fff Mon Sep 17 00:00:00 2001 From: Reto Kromer Date: Sun, 10 Jul 2016 15:01:00 +0200 Subject: [PATCH 3/3] changed author --- check_framemd5.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_framemd5.sh b/check_framemd5.sh index b6a2c44..06f4008 100644 --- a/check_framemd5.sh +++ b/check_framemd5.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash SCRIPT=$(basename $0) VERSION='2016-07-10' - AUTHOR='Kieran O\'Leary, Reto Kromer' + AUTHOR='ffmprovisr' RED='\033[1;31m' BLUE='\033[1;34m' NC='\033[0m'