Added posibility to not convert
This commit is contained in:
parent
3d108ecf7f
commit
4aee64d3fe
@ -15,6 +15,7 @@ Options:
|
|||||||
-s, --source <source> The source folder of the music
|
-s, --source <source> The source folder of the music
|
||||||
-d, --dest <destination> The destionation folder of the music
|
-d, --dest <destination> The destionation folder of the music
|
||||||
-t, --temp <folder> The temporary cache for converted files (default: /tmp/converted)
|
-t, --temp <folder> The temporary cache for converted files (default: /tmp/converted)
|
||||||
|
-c, --convert Convert files before syncing
|
||||||
-v, --verbose <0-6> Set log level (default: 2)
|
-v, --verbose <0-6> Set log level (default: 2)
|
||||||
-h, --help Display this help text
|
-h, --help Display this help text
|
||||||
|
|
||||||
|
@ -5,11 +5,13 @@ begin=$(date +"%s")
|
|||||||
set -o errexit -o pipefail -o noclobber -o nounset
|
set -o errexit -o pipefail -o noclobber -o nounset
|
||||||
source="-"
|
source="-"
|
||||||
dest="-"
|
dest="-"
|
||||||
|
convert=false
|
||||||
verbose=2
|
verbose=2
|
||||||
help=false
|
help=false
|
||||||
temp="/tmp/converted"
|
temp="/tmp/converted"
|
||||||
|
|
||||||
CheckDeps() {
|
CheckDeps() {
|
||||||
|
if [[ $1 == 0 ]]; then
|
||||||
# Check getopt
|
# Check getopt
|
||||||
! getopt --test > /dev/null
|
! getopt --test > /dev/null
|
||||||
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
|
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
|
||||||
@ -19,22 +21,26 @@ CheckDeps() {
|
|||||||
ExecTime
|
ExecTime
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $1 == 1 ]]; then
|
||||||
# Check lame
|
# Check lame
|
||||||
if [[ ! $(lame --version 2>/dev/null) ]]; then
|
echo $convert
|
||||||
|
if [[ $convert == true && ! $(lamek --version 2>/dev/null) ]]; then
|
||||||
VerboseOutput 5 "\`lame --version\` failed"
|
VerboseOutput 5 "\`lame --version\` failed"
|
||||||
VerboseOutput 5 "Sorry, It seems that lame is not installed on your system"
|
VerboseOutput 5 "Sorry, It seems that lame is not installed on your system"
|
||||||
VerboseOutput 5 "Please install lame from your repositories and make sure it is available in your \$PATH"
|
VerboseOutput 5 "Please install lame from your repositories and make sure it is available in your \$PATH"
|
||||||
ExecTime
|
ExecTime
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
|
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS=s:d:t:v::h
|
OPTIONS=s:d:t:cv::h
|
||||||
LONGOPTS=source:,dest:,temp:,verbose::,help
|
LONGOPTS=source:,dest:,temp:,convert,verbose::,help
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -78,6 +84,10 @@ GetOptions() {
|
|||||||
temp="$2"
|
temp="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-c|--convert)
|
||||||
|
convert=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -114,6 +124,7 @@ Usage() {
|
|||||||
echo " -s, --source <source> The source folder of the music"
|
echo " -s, --source <source> The source folder of the music"
|
||||||
echo " -d, --dest <destination> The destionation folder of the music"
|
echo " -d, --dest <destination> The destionation folder of the music"
|
||||||
echo " -t, --temp <folder> The temporary cache for converted files (default: /tmp/converted)"
|
echo " -t, --temp <folder> The temporary cache for converted files (default: /tmp/converted)"
|
||||||
|
echo " -c, --convert Convert files before syncing"
|
||||||
echo " -v, --verbose <0-6> Set log level (default: 2)"
|
echo " -v, --verbose <0-6> Set log level (default: 2)"
|
||||||
echo " -h, --help Display this help text"
|
echo " -h, --help Display this help text"
|
||||||
echo ""
|
echo ""
|
||||||
@ -281,8 +292,9 @@ ExitHandler() {
|
|||||||
trap 'ExitHandler' SIGINT
|
trap 'ExitHandler' SIGINT
|
||||||
trap 'ErrorHandler $BASH_COMMAND' ERR
|
trap 'ErrorHandler $BASH_COMMAND' ERR
|
||||||
|
|
||||||
CheckDeps
|
CheckDeps 0
|
||||||
GetOptions $@
|
GetOptions $@
|
||||||
|
CheckDeps 1
|
||||||
if [[ $help == true ]]; then
|
if [[ $help == true ]]; then
|
||||||
Usage
|
Usage
|
||||||
exit
|
exit
|
||||||
@ -296,7 +308,14 @@ if [[ ! -f /tmp/music-sync-filelist ]]; then
|
|||||||
CleanUp
|
CleanUp
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
ConvertFiles
|
if [[ $convert == true ]]; then
|
||||||
|
ConvertFiles
|
||||||
|
else
|
||||||
|
if [[ $temp != "/tmp/converted" ]]; then
|
||||||
|
VerboseOutput 2 "Conversion not enabled. Ignoring cache folder"
|
||||||
|
fi
|
||||||
|
temp=$source
|
||||||
|
fi
|
||||||
CopyFiles
|
CopyFiles
|
||||||
CleanUp
|
CleanUp
|
||||||
ExecTime
|
ExecTime
|
||||||
|
Loading…
Reference in New Issue
Block a user