Compare commits
112 Commits
distribute
...
master
Author | SHA1 | Date |
---|---|---|
Jeffrey Paul | e425c6fd5b | |
louwrentius | 2aec933067 | |
louwrentius | 8e11672952 | |
louwrentius | 2f612846cb | |
louwrentius | baa44063f4 | |
louwrentius | b24d58294e | |
louwrentius | 8fe6ca64db | |
louwrentius | a33f87d0b0 | |
louwrentius | eb61175bf4 | |
louwrentius | 01b944ad9e | |
louwrentius | 66d0d3e4b2 | |
louwrentius | 42c4305ac5 | |
louwrentius | d947d84646 | |
louwrentius | c78896892b | |
louwrentius | ec1d542ab6 | |
louwrentius | 30f92bbae9 | |
louwrentius | 74d1e90282 | |
louwrentius | a06634d450 | |
louwrentius | dbd8f51590 | |
louwrentius | a908682185 | |
louwrentius | 48c80d9257 | |
louwrentius | 828e4d135c | |
louwrentius | 114112241f | |
louwrentius | 625eb7e1e4 | |
louwrentius | b69e1e6d7b | |
louwrentius | edb7c21683 | |
louwrentius | 55f4b1f2e2 | |
louwrentius | eaa18282d1 | |
louwrentius | 2dcb39ecbf | |
louwrentius | 136c1c13ca | |
louwrentius | c344794953 | |
louwrentius | bccd42ab9d | |
louwrentius | cc1aa38f05 | |
louwrentius | 836378eda8 | |
louwrentius | ed4c0bf554 | |
louwrentius | 72e0c983d0 | |
louwrentius | 3c9a4d5ee8 | |
louwrentius | 29713bcc14 | |
louwrentius | 126e71e231 | |
Louwrentius | 2946abc3d6 | |
Louwrentius | c07e95b2a2 | |
Louwrentius | ff63e9950b | |
Louwrentius | 8663f482c3 | |
Louwrentius | 427c97f5af | |
Louwrentius | 654b52d91f | |
Louwrentius | 2c42f7568e | |
Louwrentius | 3ec86b451e | |
Louwrentius | 1575fb28f6 | |
Louwrentius | 20e8cdce95 | |
Louwrentius | 7550b4a5c1 | |
Louwrentius | c4bc6f963a | |
Louwrentius | d18102ba58 | |
Louwrentius | c220353e7e | |
Louwrentius | ecc9d3da3b | |
Louwrentius | caa6519d0f | |
Louwrentius | 211bd40641 | |
Louwrentius | 5614724162 | |
Louwrentius | 55583de5f8 | |
Louwrentius | b6bd8c6c33 | |
Louwrentius | c1a359340c | |
Louwrentius | 6836784b54 | |
Louwrentius | b922bd40e5 | |
Louwrentius | f1ccfd2457 | |
Louwrentius | 8eec8287f0 | |
Louwrentius | f85f7b6d03 | |
Louwrentius | b133b76ddf | |
Louwrentius | 4b9df537a0 | |
Louwrentius | 708803688f | |
Louwrentius | 40b3ed8228 | |
Louwrentius | 9d92350f4b | |
Louwrentius | 0db3781021 | |
Louwrentius | 9feea3fb59 | |
Louwrentius | 7c2d336dba | |
Louwrentius | 61d8a24ed2 | |
Louwrentius | 825d7ed0a1 | |
Louwrentius | 2cae93e7ce | |
Louwrentius | 13e6b77c65 | |
Louwrentius | 7c9da647b5 | |
Louwrentius | 2dcaced13b | |
Louwrentius | 38812a58b6 | |
Louwrentius | cf3b54e61e | |
Louwrentius | 8b7944dad7 | |
Louwrentius | 3f1b96e1bb | |
Louwrentius | bdaab0afe3 | |
Louwrentius | efd6f72a5e | |
Louwrentius | 7df68e7658 | |
Louwrentius | f0ca726f28 | |
Louwrentius | 806f17c2dc | |
Louwrentius | 2c595ce846 | |
Louwrentius | 283c93f871 | |
Louwrentius | ea33b0f0e7 | |
Louwrentius | 0109e1fa3c | |
Louwrentius | 831e008e11 | |
Louwrentius | 54c898f202 | |
Louwrentius | 0f8dced209 | |
Louwrentius | 789db609c9 | |
Louwrentius | d1685d297c | |
Louwrentius | d5ea910e05 | |
Louwrentius | a63973fe73 | |
Louwrentius | cda2c7b5c1 | |
Louwrentius | 53deba3d63 | |
Louwrentius | a2fdbba0c4 | |
Louwrentius | 365705e8c7 | |
Louwrentius | 9790e52c89 | |
Louwrentius | 50de3d4fdf | |
Louwrentius | 4d5324e7c8 | |
Louwrentius | a9b4eac886 | |
Louwrentius | bd97eed1ea | |
Louwrentius | 081337c5b2 | |
Louwrentius | 2356f6bb0a | |
Louwrentius | 83bc8fbf06 | |
Louwrentius | 121f1e5779 |
|
@ -0,0 +1,94 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
INPUT="$1"
|
||||||
|
|
||||||
|
METATAGS="--export-tags-to="
|
||||||
|
LAMEOPTS=""
|
||||||
|
ERROR_STATUS="0"
|
||||||
|
|
||||||
|
function usage () {
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Usage: $0 <flac file name>"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function error () {
|
||||||
|
|
||||||
|
ERROR="$1"
|
||||||
|
MSG="$2"
|
||||||
|
|
||||||
|
echo "Error: $MSG"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "$INPUT" ]
|
||||||
|
then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "$INPUT" ]
|
||||||
|
then
|
||||||
|
echo "File $INPUT does not exist!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILETYPE="`file -b "$INPUT" | awk '{ print $1 }'`"
|
||||||
|
if [ ! "$FILETYPE" == "FLAC" ]
|
||||||
|
then
|
||||||
|
echo "File $FILE is not a flac file..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
checkvar () {
|
||||||
|
|
||||||
|
VAR="$1"
|
||||||
|
|
||||||
|
if [ -z "$VAR" ] || [ "$VAR" == "" ]
|
||||||
|
then
|
||||||
|
echo "Unknown"
|
||||||
|
else
|
||||||
|
echo "$VAR"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
METATAGS="TITLE ARTIST ALBUM GENRE COMPOSER CONDUCTOR ENSEMBLE TRACKNUMBER DATE ALBUM ARTIST DISCNUMBER DISC"
|
||||||
|
|
||||||
|
function convert () {
|
||||||
|
|
||||||
|
FILE="$1"
|
||||||
|
META="$FILE.meta"
|
||||||
|
MP3FILE="`echo ${FILE%flac}mp3`"
|
||||||
|
DIR="`dirname "$FILE"`"
|
||||||
|
|
||||||
|
metaflac --export-tags-to="$META" "$FILE"
|
||||||
|
|
||||||
|
ARTIST="`metaflac "$FILE" --show-tag=ARTIST | sed s/.*=//g`"
|
||||||
|
TITLE="`metaflac "$FILE" --show-tag=TITLE | sed s/.*=//g`"
|
||||||
|
ALBUM="`metaflac "$FILE" --show-tag=ALBUM | sed s/.*=//g`"
|
||||||
|
GENRE="`metaflac "$FILE" --show-tag=GENRE | sed s/.*=//g`"
|
||||||
|
TRACKNUMBER="`metaflac "$FILE" --show-tag=TRACKNUMBER | sed s/.*=//g`"
|
||||||
|
|
||||||
|
for x in $METATAGS
|
||||||
|
do
|
||||||
|
declare $x="`grep "$x" "$META" | cut -d "=" -f 2`"
|
||||||
|
|
||||||
|
VAR=$(eval echo " \$$x")
|
||||||
|
VAR="`checkvar $VAR`"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
flac -s -c -d "$FILE" | lame --tt "$TITLE" --tn "$TRACKNUMBER" --tg "$GENRE" --ty "$DATE" --ta "$ARTIST" --tl "$ALBUM" --ty "$YEAR" --preset insane - "$MP3FILE"
|
||||||
|
ERROR_STATUS="$?"
|
||||||
|
if [ -e "$META" ]
|
||||||
|
then
|
||||||
|
rm "$META"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
convert "$INPUT"
|
||||||
|
|
||||||
|
exit "$ERROR_STATUS"
|
304
ppss-test.sh
304
ppss-test.sh
|
@ -1,13 +1,22 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
DEBUG="$1"
|
DEBUG="$1"
|
||||||
VERSION=2.55
|
VERSION="2.98"
|
||||||
TMP_DIR="ppss"
|
TMP_DIR="/tmp/ppss"
|
||||||
PPSS=ppss
|
PPSS=./ppss
|
||||||
PPSS_DIR=ppss_dir
|
PPSS_DIR=ppss_dir
|
||||||
|
export PPSS_DEBUG=1
|
||||||
|
HOST_ARCH=`uname`
|
||||||
|
SPECIAL_DIR=$TMP_DIR/root/special
|
||||||
|
. "$PPSS"
|
||||||
|
|
||||||
cleanup () {
|
cleanup () {
|
||||||
|
|
||||||
|
unset RES1
|
||||||
|
unset RES2
|
||||||
|
GLOBAL_COUNTER=1
|
||||||
|
if [ ! "$DEBUG" = "debug" ]
|
||||||
|
then
|
||||||
for x in $REMOVEFILES
|
for x in $REMOVEFILES
|
||||||
do
|
do
|
||||||
if [ -e ./$x ]
|
if [ -e ./$x ]
|
||||||
|
@ -15,6 +24,12 @@ cleanup () {
|
||||||
rm -r ./$x
|
rm -r ./$x
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$TMP_DIR" ] && [ -e "$TMP_DIR" ]
|
||||||
|
then
|
||||||
|
rm -rf "$TMP_DIR"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
parseJobStatus () {
|
parseJobStatus () {
|
||||||
|
@ -24,45 +39,38 @@ parseJobStatus () {
|
||||||
RES=`grep "Status:" "$JOBLOG/$TMP_FILE"`
|
RES=`grep "Status:" "$JOBLOG/$TMP_FILE"`
|
||||||
STATUS=`echo "$RES" | awk '{ print $2 }'`
|
STATUS=`echo "$RES" | awk '{ print $2 }'`
|
||||||
echo "$STATUS"
|
echo "$STATUS"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_item_count_of_input_file () {
|
||||||
|
|
||||||
|
if [ -e "$PPSS_DIR/INPUT_FILE-$$" ]
|
||||||
|
then
|
||||||
|
CONTENTS_OF_INPUTFILE=`cat $PPSS_DIR/INPUT_FILE-$$ | wc -l | awk '{ print $1 }'`
|
||||||
|
echo "$CONTENTS_OF_INPUTFILE"
|
||||||
|
else
|
||||||
|
echo "Error, file $PPSS_DIR/INPUT_FILE-$$ does not exist."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
oneTimeSetUp () {
|
oneTimeSetUp () {
|
||||||
|
|
||||||
NORMALTESTFILES=`echo test-{a..z}`
|
|
||||||
SPECIALTESTFILES="\'file-!@#$%^&*()_+=-0987654321~\' \'file-/\<>?:;'{}[]\' file-/\/\:\/!@#$%^&*()_+=-0987654321~ file-/\<>?:;'{}[] http://www.google.nl ftp://storage.nl"
|
|
||||||
JOBLOG=./$PPSS_DIR/job_log
|
JOBLOG=./$PPSS_DIR/job_log
|
||||||
INPUTFILENORMAL=test-normal.input
|
INPUTFILENORMAL=test-normal.input
|
||||||
INPUTFILESPECIAL=test-special.input
|
INPUTFILESPECIAL_DIR=test-special.input
|
||||||
LOCALOUTPUT=ppss_dir/PPSS_LOCAL_OUTPUT
|
LOCALOUTPUT=ppss_dir/PPSS_LOCAL_OUTPUT
|
||||||
|
REMOVEFILES="$PPSS_DIR test-ppss-*"
|
||||||
|
|
||||||
REMOVEFILES="$INPUTFILENORMAL $INPUTFILESPECIAL $PPSS_DIR test-ppss-*"
|
if [ ! -e "$TMP_DIR" ]
|
||||||
|
then
|
||||||
|
mkdir -p "$TMP_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
for x in $NORMALTESTFILES
|
|
||||||
do
|
|
||||||
echo "$x" >> "$INPUTFILENORMAL"
|
|
||||||
done
|
|
||||||
|
|
||||||
for x in $SPECIALTESTFILES
|
|
||||||
do
|
|
||||||
echo $x >> "$INPUTFILESPECIAL"
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testVersion () {
|
testVersion () {
|
||||||
|
|
||||||
RES=`./$PPSS -v`
|
assertEquals "Version mismatch!" "$VERSION" "$SCRIPT_VERSION"
|
||||||
|
|
||||||
for x in $RES
|
|
||||||
do
|
|
||||||
echo "$x" | grep [0-9] >> /dev/null
|
|
||||||
if [ "$?" == "0" ]
|
|
||||||
then
|
|
||||||
assertEquals "Version mismatch!" "$VERSION" "$x"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rename-ppss-dir () {
|
rename-ppss-dir () {
|
||||||
|
@ -85,139 +93,191 @@ oneTimeTearDown () {
|
||||||
|
|
||||||
createDirectoryWithSomeFiles () {
|
createDirectoryWithSomeFiles () {
|
||||||
|
|
||||||
A="File with Spaces"
|
ROOT_DIR=$TMP_DIR/root
|
||||||
B="File\With\Slashes"
|
CHILD_1=$ROOT_DIR/child_1
|
||||||
|
CHILD_2=$ROOT_DIR/child_2
|
||||||
|
|
||||||
mkdir "/tmp/$TMP_DIR"
|
if [ ! -e "$ROOT_DIR" ]
|
||||||
for x in "$A" "$B"
|
then
|
||||||
|
mkdir -p "$ROOT_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "$CHILD_1" ]
|
||||||
|
then
|
||||||
|
mkdir -p "$CHILD_1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "$CHILD_2" ]
|
||||||
|
then
|
||||||
|
mkdir -p "$CHILD_2"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for x in {1..10}
|
||||||
do
|
do
|
||||||
TMP_FILE="/tmp/$TMP_DIR/$x"
|
touch "$ROOT_DIR/file-$x"
|
||||||
touch "$TMP_FILE"
|
touch "$CHILD_1/file-$x"
|
||||||
|
touch "$CHILD_2/file-$x"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
ln -s /etc/resolve.conf "$ROOT_DIR" 2> /dev/null
|
||||||
|
ln -s /etc/hosts "$ROOT_DIR" 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
testSpacesInFilenames () {
|
createSpecialFilenames () {
|
||||||
|
|
||||||
|
ERROR=0
|
||||||
|
mkdir -p "$SPECIAL_DIR"
|
||||||
|
|
||||||
|
touch "$SPECIAL_DIR/a file with spaces"
|
||||||
|
touch "$SPECIAL_DIR/a\\'file\\'with\\'quotes"
|
||||||
|
touch "$SPECIAL_DIR/a{file}with{curly}brackets}"
|
||||||
|
touch "$SPECIAL_DIR/a(file)with(parenthesis)"
|
||||||
|
touch "$SPECIAL_DIR/a\\file\\with\\backslashes"
|
||||||
|
touch "$SPECIAL_DIR/a!file!with!exclamationmarks"
|
||||||
|
touch "$SPECIAL_DIR/a filé with special characters"
|
||||||
|
touch "$SPECIAL_DIR/a\"file\"with\"double\"quotes"
|
||||||
|
}
|
||||||
|
|
||||||
|
testMD5 () {
|
||||||
|
|
||||||
|
export USE_MD5=1
|
||||||
|
init_vars > /dev/null 2>&1
|
||||||
|
ARCH=Darwin
|
||||||
|
set_md5
|
||||||
|
assertEquals "MD5 executable not set properly - $MD5" "$MD5" "md5"
|
||||||
|
ARCH=Linux
|
||||||
|
set_md5
|
||||||
|
assertEquals "MD5 executable not set properly - $MD5" "$MD5" "md5sum"
|
||||||
|
ARCH=$HOST_ARCH
|
||||||
|
}
|
||||||
|
|
||||||
|
init_get_all_items () {
|
||||||
|
|
||||||
|
DIR="$1"
|
||||||
|
TRAVERSAL="$2"
|
||||||
createDirectoryWithSomeFiles
|
createDirectoryWithSomeFiles
|
||||||
|
create_working_directory
|
||||||
RES=$( { ./$PPSS -d /tmp/$TMP_DIR -c 'ls -alh ' >> /dev/null ; } 2>&1 )
|
export SRC_DIR=$DIR
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
init_vars > /dev/null 2>&1
|
||||||
|
get_all_items
|
||||||
assertNull "PPSS retured some errors..." "$RES"
|
|
||||||
if [ ! "$?" == "0" ]
|
|
||||||
then
|
|
||||||
echo "RES IS $RES"
|
|
||||||
fi
|
|
||||||
|
|
||||||
grep "SUCCESS" $JOBLOG/* >> /dev/null 2>&1
|
|
||||||
assertEquals "Found error with space in filename $TMP_FILE" "0" "$?"
|
|
||||||
|
|
||||||
rm -rf "/tmp/$TMP_DIR"
|
|
||||||
rename-ppss-dir $FUNCNAME
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testSpecialCharacterHandling () {
|
testRecursion () {
|
||||||
|
|
||||||
RES=$( { ./$PPSS -f "$INPUTFILESPECIAL" -c 'echo ' >> /dev/null ; } 2>&1 )
|
init_get_all_items $TMP_DIR/root 1
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
RESULT=`get_item_count_of_input_file`
|
||||||
|
EXPECTED=32
|
||||||
assertNull "PPSS retured some errors..." "$RES"
|
assertEquals "Recursion not correct." "$EXPECTED" "$RESULT"
|
||||||
if [ ! "$?" == "0" ]
|
|
||||||
then
|
|
||||||
echo "RES IS $RES"
|
|
||||||
fi
|
|
||||||
|
|
||||||
RES=`find ppss_dir/PPSS_LOCAL_OUTPUT | wc -l | sed 's/\ //g'`
|
|
||||||
assertEquals "To many lock files..." "7" "$RES"
|
|
||||||
|
|
||||||
RES1=`ls -1 $JOBLOG`
|
|
||||||
RES2=`ls -1 $LOCALOUTPUT`
|
|
||||||
|
|
||||||
assertEquals "RES1 $RES1 is not the same as RES2 $RES2" "$RES1" "$RES2"
|
|
||||||
|
|
||||||
rename-ppss-dir $FUNCNAME
|
rename-ppss-dir $FUNCNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
testSkippingOfProcessedItems () {
|
testNoRecursion () {
|
||||||
|
|
||||||
createDirectoryWithSomeFiles
|
init_get_all_items $TMP_DIR/root 0
|
||||||
|
RESULT=`get_item_count_of_input_file`
|
||||||
|
EXPECTED=12
|
||||||
|
|
||||||
RES=$( { ./$PPSS -d /tmp/$TMP_DIR -c 'echo ' >> /dev/null ; } 2>&1 )
|
assertEquals "Recursion not correct." "$EXPECTED" "$RESULT"
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
||||||
assertNull "PPSS retured some errors..." "$RES"
|
|
||||||
|
|
||||||
RES=$( { ./$PPSS -d /tmp/$TMP_DIR -c 'echo ' >> /dev/null ; } 2>&1 )
|
rename-ppss-dir $FUNCNAME
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
||||||
assertNull "PPSS retured some errors..." "$RES"
|
|
||||||
|
|
||||||
grep -i skip ./$PPSS_dir/* >> /dev/null 2>&1
|
|
||||||
assertEquals "Skipping of items went wrong." 0 "$?"
|
|
||||||
|
|
||||||
rename-ppss-dir $FUNCNAME-1
|
|
||||||
|
|
||||||
RES=$( { ./$PPSS -f $INPUTFILESPECIAL -c 'echo ' >> /dev/null ; } 2>&1 )
|
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
||||||
assertNull "PPSS retured some errors..." "$RES"
|
|
||||||
|
|
||||||
RES=$( { ./$PPSS -f $INPUTFILESPECIAL -c 'echo ' >> /dev/null ; } 2>&1 )
|
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
||||||
assertNull "PPSS retured some errors..." "$RES"
|
|
||||||
|
|
||||||
grep -i skip ./$PPSS_dir/* >> /dev/null 2>&1
|
|
||||||
assertEquals "Skipping of items went wrong." 0 "$?"
|
|
||||||
|
|
||||||
rm -rf "/tmp/$TMP_DIR"
|
|
||||||
rename-ppss-dir $FUNCNAME-2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testExistLogFiles () {
|
testGetItem () {
|
||||||
|
|
||||||
./$PPSS -f "$INPUTFILENORMAL" -c 'echo "$ITEM"' >> /dev/null
|
createSpecialFilenames
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
init_get_all_items $TMP_DIR/root 1
|
||||||
|
get_item
|
||||||
|
if [ -z "$ITEM" ]
|
||||||
|
then
|
||||||
|
ERROR=1
|
||||||
|
else
|
||||||
|
ERROR=0
|
||||||
|
fi
|
||||||
|
EXPECTED=0
|
||||||
|
assertEquals "Get item failed." "$EXPECTED" "$ERROR"
|
||||||
|
|
||||||
for x in $NORMALTESTFILES
|
i=1
|
||||||
|
ERROR=0
|
||||||
|
while get_item
|
||||||
do
|
do
|
||||||
assertTrue "[ -e $JOBLOG/$x ]"
|
((i++))
|
||||||
done
|
done
|
||||||
|
EXPECTED=40
|
||||||
|
assertEquals "Got wrong number of items." "$EXPECTED" "$i"
|
||||||
|
|
||||||
rename-ppss-dir $FUNCNAME
|
rename-ppss-dir $FUNCNAME
|
||||||
|
cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
return_all_items () {
|
||||||
|
|
||||||
|
while get_item
|
||||||
|
do
|
||||||
|
ALL_ITEMS="$ALL_ITEMS$ITEM"$'\n'
|
||||||
|
done
|
||||||
|
echo "$ALL_ITEMS"
|
||||||
|
}
|
||||||
|
|
||||||
|
testNumberOfItems () {
|
||||||
|
|
||||||
|
createSpecialFilenames
|
||||||
|
RESULT=`init_get_all_items $TMP_DIR/root 1`
|
||||||
|
|
||||||
|
RES1=`find $TMP_DIR/root/ ! -type d`
|
||||||
|
|
||||||
|
RES2=`return_all_items`
|
||||||
|
|
||||||
|
echo "$RES1" > a
|
||||||
|
echo "$RES2" > b
|
||||||
|
|
||||||
|
assertEquals "Input file and actual files not the same!" "$RES1" "$RES2"
|
||||||
|
rename-ppss-dir $FUNCNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatusOfJob () {
|
|
||||||
|
|
||||||
EXPECTED="$1"
|
testInvalidProcessingOfitemVariable() {
|
||||||
|
|
||||||
if [ "$EXPECTED" == "SUCCESS" ]
|
createSpecialFilenames
|
||||||
then
|
init_get_all_items $TMP_DIR/root 1
|
||||||
./$PPSS -f "$INPUTFILENORMAL" -c 'echo ' >> /dev/null
|
COMMAND='echo $ITEM'
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
while get_item
|
||||||
elif [ "$EXPECTED" == "FAILURE" ]
|
|
||||||
then
|
|
||||||
./$PPSS -f "$INPUTFILENORMAL" -c 'thiscommandfails ' >> /dev/null
|
|
||||||
assertEquals "PPSS did not execute properly." 0 "$?"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for x in $NORMALTESTFILES
|
|
||||||
do
|
do
|
||||||
STATUS=`parseJobStatus "$x"`
|
commando "$ITEM"
|
||||||
assertEquals "FAILED WITH STATUS $STATUS." "$EXPECTED" "$STATUS"
|
|
||||||
done
|
done
|
||||||
|
RESULT=$(grep '$ITEM' $PPSS_DIR/job_log/*)
|
||||||
rename-ppss-dir "$FUNCNAME-$EXPECTED"
|
EXPECTED=""
|
||||||
|
assertEquals "Got incorrect processing of ITEM variable." "$EXPECTED" "$RESULT"
|
||||||
|
rename-ppss-dir $FUNCNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
testErrorHandlingOK () {
|
testNumberOfLogfiles () {
|
||||||
|
|
||||||
getStatusOfJob SUCCESS
|
createSpecialFilenames
|
||||||
|
init_get_all_items $TMP_DIR/root 1
|
||||||
|
COMMAND='echo hoi'
|
||||||
|
while get_item
|
||||||
|
do
|
||||||
|
commando "$ITEM"
|
||||||
|
done
|
||||||
|
RESULT=`ls -1 $PPSS_DIR/job_log/ | wc -l | awk '{ print $1}'`
|
||||||
|
EXPECTED=40
|
||||||
|
assertEquals "Got wrong number of log files." "$EXPECTED" "$RESULT"
|
||||||
|
rename-ppss-dir $FUNCNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
testErrorHandlingFAIL () {
|
testUserInputFile () {
|
||||||
|
|
||||||
getStatusOfJob FAILURE
|
cleanup
|
||||||
|
INPUT_FILE=test-special.input
|
||||||
|
create_working_directory
|
||||||
|
init_vars > /dev/null 2>&1
|
||||||
|
get_all_items
|
||||||
|
RESULT=`return_all_items`
|
||||||
|
ORIGINAL=`cat $INPUT_FILE`
|
||||||
|
assertEquals "User input processing not ok." "$RESULT" "$ORIGINAL"
|
||||||
|
rename-ppss-dir $FUNCNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
. ./shunit2
|
. ./shunit2
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
REMOTE_OUTPUT_DIR=/mnt/mp3
|
||||||
|
SSH_KEY=ppss-key.dsa
|
||||||
|
SSH_KNOWN_HOSTS=known_hosts
|
||||||
|
SRC_DIR=/mnt/wav
|
||||||
|
COMMAND='./wav2mp3.sh "$ITEM" "$OUTPUT_DIR"'
|
||||||
|
NODES_FILE=nodes.txt
|
||||||
|
SSH_SERVER=10.0.1.110
|
||||||
|
USER=ppss
|
||||||
|
SCRIPT=wav2mp3.sh
|
||||||
|
RANDOMIZE=1
|
||||||
|
DOWNLOAD_TO_NODE=0
|
||||||
|
UPLOAD_TO_SERVER=0
|
||||||
|
SECURE_COPY=1
|
||||||
|
PPSS_DEBUG=1
|
|
@ -0,0 +1,26 @@
|
||||||
|
test-a
|
||||||
|
test-b
|
||||||
|
test-c
|
||||||
|
test-d
|
||||||
|
test-e
|
||||||
|
test-f
|
||||||
|
test-g
|
||||||
|
test-h
|
||||||
|
test-i
|
||||||
|
test-j
|
||||||
|
test-k
|
||||||
|
test-l
|
||||||
|
test-m
|
||||||
|
test-n
|
||||||
|
test-o
|
||||||
|
test-p
|
||||||
|
test-q
|
||||||
|
test-r
|
||||||
|
test-s
|
||||||
|
test-t
|
||||||
|
test-u
|
||||||
|
test-v
|
||||||
|
test-w
|
||||||
|
test-x
|
||||||
|
test-y
|
||||||
|
test-z
|
|
@ -0,0 +1,8 @@
|
||||||
|
\'file-!@#$%^&*()_ +=-0987654321~\'
|
||||||
|
\'file-/\<>?:;'{}[]\'
|
||||||
|
file-/\/\:\/!@#$%^&*()_+=-0987654321~
|
||||||
|
file-42>424>424<2424>424?24<24>24
|
||||||
|
file-/\<>?:;'{}[]
|
||||||
|
http://www.google.nl
|
||||||
|
ftp://storage.nl
|
||||||
|
./flac/Bééthoven Overtures CD2/01 - Beethoven, Lv - Leonore I - Op.138.flac
|
|
@ -0,0 +1,124 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
INPUT="$1"
|
||||||
|
RESOLUTION="$3"
|
||||||
|
SEPARATE="$4"
|
||||||
|
TITLES=0
|
||||||
|
OPTS_HIGHRES="-e x264 -q 20.0 -r 29.97 --pfr -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -4 -X 1024 --strict-anamorphic -m"
|
||||||
|
OPTS_LOWRES="-e x264 -q 20.0 -a 1 -E faac -B 128 -6 dpl2 -R 48 -D 0.0 -f mp4 -X 480 -m -x cabac=0:ref=2:me=umh:bframes=0:subme=6:8x8dct=0:trellis=0"
|
||||||
|
OPTS_SOURCE="-e x264 -q 20.0 -a 1,1 -E faac,ac3 -l 576 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 -f mp4 --detelecine --decomb --strict-anamorphic -m -x b-adapt=2:rc-lookahead=50"
|
||||||
|
MODE=""
|
||||||
|
HANDBRAKE=HandBrakeCLI
|
||||||
|
DIRNAME=`dirname "$INPUT"`
|
||||||
|
BASENAME=`basename "$INPUT"`
|
||||||
|
OPTS=""
|
||||||
|
OUTPUT_DIR="$2"
|
||||||
|
OUTPUT_FILE_NAME=""
|
||||||
|
|
||||||
|
if [ -z "$INPUT" ]
|
||||||
|
then
|
||||||
|
echo "usage $0 <input file / folder> <output folder> <highres|lowres> <separate>"
|
||||||
|
echo
|
||||||
|
echo "Input either file, VIDEO_TS directory or .ISO"
|
||||||
|
echo
|
||||||
|
echo -e "highres:\t1024 x 576"
|
||||||
|
echo -e "lowres:\t\t480 x 320"
|
||||||
|
echo -e "source:\t\tsame as source."
|
||||||
|
echo
|
||||||
|
echo -e "separate:\tseparate files for episodes of a serie."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$OUTPUT_DIR" ]
|
||||||
|
then
|
||||||
|
if [ ! -e "$OUTPUT_DIR" ] || [ ! -d "$OUTPUT_DIR" ]
|
||||||
|
then
|
||||||
|
echo "Output directory does not exist or is not a directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Output to current directory."
|
||||||
|
OUTPUT_DIR="."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ ! -e "$INPUT" ]
|
||||||
|
then
|
||||||
|
echo "$INPUT does not exist!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "$INPUT" ]
|
||||||
|
then
|
||||||
|
MODE=DIR
|
||||||
|
else
|
||||||
|
MODE=FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Input type is $MODE"
|
||||||
|
|
||||||
|
case "$RESOLUTION" in
|
||||||
|
highres|HIGHRES )
|
||||||
|
OPTS="$OPTS_HIGHRES" ;;
|
||||||
|
lowres|LOWRES )
|
||||||
|
OPTS="$OPTS_LOWRES" ;;
|
||||||
|
source|SOURCE )
|
||||||
|
OPTS="$OPTS_SOURCE" ;;
|
||||||
|
*)
|
||||||
|
echo "Resolution must be 'highres', 'source' or 'lowres'."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
function titles () {
|
||||||
|
|
||||||
|
TITLES=`./$HANDBRAKE -t 0 -i "$INPUT" 2>&1 | grep "+ title" | awk '{ print $3 }' | sed s/://g`
|
||||||
|
echo $TITLES
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$MODE" = "FILE" ]
|
||||||
|
then
|
||||||
|
mkdir -p "$OUTPUT_DIR/$DIRNAME"
|
||||||
|
OUTPUT_FILE_NAME="$OUTPUT_DIR/$DIRNAME/${BASENAME%.*}"
|
||||||
|
elif [ "$MODE" = "DIR" ]
|
||||||
|
then
|
||||||
|
echo "$INPUT" | grep -i video_ts >> /dev/null 2>&1
|
||||||
|
if [ "$?" = "0" ]
|
||||||
|
then
|
||||||
|
INTERMEDIATE2=`basename "$DIRNAME"`
|
||||||
|
mkdir -p "$OUTPUT_DIR/$DIRNAME"
|
||||||
|
OUTPUT_FILE_NAME="$OUTPUT_DIR/$DIRNAME/$INTERMEDIATE2"
|
||||||
|
else
|
||||||
|
INTERMEDIATE2="$BASENAME"
|
||||||
|
mkdir -p "$OUTPUT_DIR/$DIRNAME/$INTERMEDIATE2"
|
||||||
|
OUTPUT_FILE_NAME="$OUTPUT_DIR/$DIRNAME/$INTERMEDIATE2/$INTERMEDIATE2"
|
||||||
|
fi
|
||||||
|
echo "INTERMEDIATE2 = $INTERMEDIATE2"
|
||||||
|
else
|
||||||
|
echo "Mode is not determined..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SEPARATE" = "separate" ]
|
||||||
|
then
|
||||||
|
TITLES=`titles $INPUT`
|
||||||
|
echo "TITLES = $TITLES"
|
||||||
|
ERROR=0
|
||||||
|
|
||||||
|
for x in $TITLES
|
||||||
|
do
|
||||||
|
HandBrakeCLI $OPTS -i "$INPUT" -o "$OUTPUT_FILE_NAME-$x.mp4"
|
||||||
|
if [ ! "$?" = "0" ]
|
||||||
|
then
|
||||||
|
ERROR="1"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
exit "$ERROR"
|
||||||
|
else
|
||||||
|
echo "Creating a single file."
|
||||||
|
HandBrakeCLI $OPTS -i "$INPUT" -o "$OUTPUT_FILE_NAME.mp4"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SRC="$1"
|
||||||
|
DEST="$2"
|
||||||
|
|
||||||
|
|
||||||
|
TYPE=`file -b "$SRC"`
|
||||||
|
RES=`echo "$TYPE" | grep "WAVE audio"`
|
||||||
|
if [ ! "$?" == "0" ]
|
||||||
|
then
|
||||||
|
echo "File $SRC is not a wav file..."
|
||||||
|
echo "Type is $TYPE"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
BASENAME=`basename "$SRC"`
|
||||||
|
MP3FILE="`echo ${BASENAME%wav}mp3`"
|
||||||
|
lame --quiet --preset insane "$SRC" "$DEST/$MP3FILE"
|
||||||
|
exit "$?"
|
Loading…
Reference in New Issue