diff --git a/music-sync.sh b/music-sync.sh index 24079a0..267d586 100755 --- a/music-sync.sh +++ b/music-sync.sh @@ -7,6 +7,7 @@ source="-" dest="-" convert=false verbose=2 +bitrate=192 help=false temp="/tmp/converted" convertart=false @@ -58,8 +59,8 @@ CheckDeps() { GetOptions() { # https://stackoverflow.com/a/29754866 - OPTIONS=s:d:t:cav::h - LONGOPTS=source:,dest:,temp:,convert,convert-art,verbose::,help + OPTIONS=s:d:t:cab:v::h + LONGOPTS=source:,dest:,temp:,convert,convert-art,bitrate:,verbose::,help # -use ! and PIPESTATUS to get exit code with errexit set # -temporarily store output to be able to check for errors @@ -111,6 +112,10 @@ GetOptions() { convertart=true shift ;; + -b|--bitrate) + bitrate="$2" + shift 2 + ;; --) shift break @@ -149,6 +154,7 @@ Usage() { echo " -t, --temp The temporary cache for converted files (default: /tmp/converted)" echo " -c, --convert Convert files before syncing" echo " -a, --convert-art Convert album-art before syncing" + echo " -b, --bitrate When converting use this bitrate" echo " -v, --verbose <0-6> Set log level (default: 2)" echo " -h, --help Display this help text" echo "" @@ -243,7 +249,7 @@ ConvertFiles() { mkdir -p "$temp/${line%/*}"; fi; if [[ ! -f "$temp/$line" || "${source}/$line" -nt "$temp/$line" ]]; then - lame -b 192 $source/$line $temp/$line 1>/dev/null 2>/dev/null + lame -b ${bitrate} $source/$line $temp/$line 1>/dev/null 2>/dev/null VerboseOutput 2 "Converted: $line" if [[ $convertart == true ]]; then mkdir "$temp/$line-images/"