diff --git a/music-sync.sh b/music-sync.sh index 11bb409..ca25d17 100755 --- a/music-sync.sh +++ b/music-sync.sh @@ -11,6 +11,7 @@ bitrate=192 help=false temp="/tmp/converted" convertart=false +coverartsize=200 CheckDeps() { if [[ $1 == 0 ]]; then @@ -59,8 +60,8 @@ CheckDeps() { GetOptions() { # https://stackoverflow.com/a/29754866 - OPTIONS=s:d:t:cab:v::h - LONGOPTS=source:,dest:,temp:,convert,convert-art,bitrate:,verbose::,help + OPTIONS=s:d:t:ca::b: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 @@ -110,6 +111,11 @@ GetOptions() { ;; -a|--convert-art) convertart=true + coverartsize=200 + if [[ $2 != "" ]]; then + coverartsize=${2} + shift + fi shift ;; -b|--bitrate) @@ -149,14 +155,14 @@ Usage() { echo "Syncronises music from one folder to another." echo "" echo "Options:" - echo " -s, --source The source folder of the music" - echo " -d, --dest The destionation folder of the music" - 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 " -s, --source The source folder of the music" + echo " -d, --dest The destionation folder of the music" + 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 (default width: 200)" + 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 "" echo "Log levels:" echo " 0 | Verbose" @@ -254,7 +260,7 @@ ConvertFiles() { if [[ $convertart == true ]]; then mkdir -p "$temp/$line-images/" eyeD3 --write-images "$temp/$line-images/" "$temp/$line" 1>/dev/null 2>/dev/null - convert "$temp/$line-images/FRONT_COVER.*" -resize 200x200 "$temp/$line-images/FRONT_COVER.jpg" 1>/dev/null 2>/dev/null + convert "$temp/$line-images/FRONT_COVER.*" -resize ${coverartsize}x${coverartsize} "$temp/$line-images/FRONT_COVER.jpg" 1>/dev/null 2>/dev/null eyeD3 --remove-all-images "$temp/$line" 1>/dev/null 2>/dev/null eyeD3 --add-image "$temp/$line-images/FRONT_COVER.jpg:FRONT_COVER" "$temp/$line" 1>/dev/null 2>/dev/null VerboseOutput 2 "Converted cover art: $line"