#!/bin/bash
-# working directory
-work="$(pwd)/work.$$"
-# path to flactomp3v2.sh script
-scriptpath="/usr/bin"
-# collection directory
-musicpath="/tmp/musikpath"
-
-# Check exist config and script is exists
-# config file can set scriptpath and musicpath
+work="$(pwd)/work.$$" # temporary working directory
+scriptpath="/usr/bin" # path to flactomp3v2.sh and notify.sh script
+musicpath="/tmp/musikpath" # flac collection directory
+
+# check exist config and scripts
+# .albentohandy.conf: set scriptpath and musicpath
if [ -f $HOME/.albentohandy.conf ]
then
source $HOME/.albentohandy.conf
printf "\nERROR\n%s/.albentohandy.conf does not exists\n" $HOME
exit 1
fi
+# flactomp3v2.sh: convert flac's to mp3
if [ ! -f $scriptpath/flactomp3v2.sh ]
then
printf "\nERROR\nflactomp3v2.sh do not found in %s\n" $scriptpath
exit 1
fi
+# notify.sh: functions send email
if [ ! -f $scriptpath/notify.sh ]
then
printf "\nERROR\nnotify.sh do not found in %s\n" $scriptpath
removework=false
cptodest=false
+# in cluster you have to same bitrate and
+# stereo mode of mp3's on every pc.
+# read more about basefile in man parallel
if [ -f $HOME/.flactomp3v2.conf ]
then
BASEFILE="--bf $HOME/.flactomp3v2.conf --cleanup"
addInfo "albentohandy.sh is started</p>"
addInfo "<p>Foldende Alben wurden ausgewählt:</p>"
addInfo "<p>$(cat "$albumlist" | sed 's/$/<br>/')</p>"
-# make symlinks of original flac's
+# make symlinks of original flac's in working directory
printf "\nPhase %02d of %02d: create symlinks of flac's to working directory %s\n" $((curphase++)) $phase "$work"
for i in $(cat "$albumlist")
do
cp -rs $musicpath/$i $work/
done
-# convert flac to mp3
-# it is the longest phase
addInfo "<p>"
currentDate
addInfo "flac -> mp3 start<br>"
+# convert flac to mp3
+# it is the longest phase
printf "\nPhase %02d of %02d: flac -> mp3\n" $((curphase++)) $phase
find $work -name '*.flac' | sort | parallel $BASEFILE --eta --progress --noswap -S $parallelopts $scriptpath/flactomp3v2.sh {}
currentDate
fi
# make zipfile in the current path
+# content of zipfile is content of working directory
if [ $mkzip == true ]
then
printf "Phase %02d of %02d: create %s\n" $((curphase++)) $phase $zipname
MODE="j"
# check config exists
-# config can set BITRATE and MODE
+# config .flactomp3v2.conf can set BITRATE and MODE
if [ -f $HOME/.flactomp3v2.conf ]
then
source $HOME/.flactomp3v2.conf
fi
INPUTFILE=$1
-# give output correct extension
-OUTPUTFILE="${INPUTFILE[@]/%flac/mp3}"
+OUTPUTFILE="${INPUTFILE[@]/%flac/mp3}" # give output correct extension
-# get the tags
+# get the tags from flac file
ARTIST=$(metaflac "$INPUTFILE" --show-tag=ARTIST | sed s/.*=//g)
TITLE=$(metaflac "$INPUTFILE" --show-tag=TITLE | sed s/.*=//g)
ALBUM=$(metaflac "$INPUTFILE" --show-tag=ALBUM | sed s/.*=//g)
# stream flac into the lame encoder
flac -s -c -d "$INPUTFILE" | lame --silent -b $BITRATE -m $MODE --noreplaygain - "$OUTPUTFILE"
-# ID3v2.3 tagging
+# ID3v2.3 tagging with cover and without cover
if [ -f ${INPUTFILE%/*}/cover.jpg ]
then
eyeD3 --to-v2.3 \
# default no notify
# it will be set in .ablentohandy.conf
NOTIFY=false
-
MESSAGE=""
+
# load all parameters to sendemail over smtp
+# NOTIFY; FROMADDRESS; TOADDRESS; STMP; SMPTUSERNAME; SMTPPASSWORD(base64)
if [ ! -f $HOME/.albentohandy.conf ]
then
printf "\nERROR\n.albentohandy.conf does not exist\n"
fi
}
+# add current date in message
currentDate()
{
MESSAGE="${MESSAGE}$(date +"%Y-%m-%d %H:%M:%S") "
}
+# open html, header and body
openMail()
{
MESSAGE="<html>\n \
<body>\n"
}
+# write message
addInfo()
{
MESSAGE="${MESSAGE}$1\n"
}
+# close body andy html
closeMail()
{
MESSAGE="${MESSAGE}\n \