Added variable width for coverart

This commit is contained in:
Jeroen De Meerleer 2019-03-16 17:32:39 +01:00
parent 344efcc38b
commit b6cf8005e4
1 changed files with 17 additions and 11 deletions

View File

@ -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 <source> The source 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 " -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 <source> The source 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 " -c, --convert Convert files before syncing"
echo " -a, --convert-art <width> 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"