albumtohandy - konvertiert flac to mp3 von einer Sammlung
SYNOPSIS
- albentohandy [-c] [-i <inputfile] [-m <destfolder]
- [-S [<jobs>]/<sshlogin>[,[<jobs>]/<sshlogin>]..] [-r] [-z <zipfile]
+ albentohandy [-i <inputfile] [-m <destfolder] [-r] [-h]
OPTIONS
- -c generiert eine sha256sum
-h show this help
-i <file> input Datei default=albumlist
-m <dest> kopiert das Arbeitsverzeichnis
in das angegeben Zielverzeichnis
- -S [<jobs>]/<sshlogin> parallel mehr information
- in der Manpage von parallel
-r löscht das Arbeitsverzeichnis
- wenn -z oder -m angegeben ist
+ wenn -m angegeben ist
-w <workdir> das Arbeitsverzeichnis angegeben
- -z <zipfile> erstellt ein Zip Datei
EOF
}
for i in $(cat "$albumlist"); do
cp --recursive --symbolic-link $musicdir/$i $workdir/
rsync --recursive --perms --times --group --owner \
- --exclude="*.flac" --exclude="*.mp3" \
+ --exclude="*.flac" --exclude="*.mp3" --exclude="*.ogg" \
--include="cover.jpg" $musicdir/$i $workdir/
done
-
}
ReadFlacToOggTags()
metaflac --export-tags-to=- $INPUTFILE \
| vorbiscomment --commentfile - --write $OUTPUTFILE
+
if [ -f $COVERFILE ]; then
echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 $COVERFILE)" \
| vorbiscomment --commentfile - --raw --append $OUTPUTFILE
local readonly INPUTFILE="$1"
local readonly OUTPUTFILE="$2"
- # stream flac into the ogg vorbis
nice --adjustment=10 flac --silent --stdout --decode "$INPUTFILE" \
| nice --adjustment=15 oggenc --quiet --quality 6 \
--output "$OUTPUTFILE" -
{
local readonly workdir="$1"
local readonly paralleopts="$2"
- local readonly scriptdir="$3"
export -f FlacToVorbis
export -f ReadFlacToOggTags
cp --recursive $workdir/* $destdir
}
-MakeZipFile()
-{
- local readonly workdir="$1"
- local zipname="$2"
-
- if [[ ! $zipname =~ .zip ]]; then
- local zipname="${zipname}.zip"
- fi
-
- local readonly curpath=$(pwd)
- cd $workdir
- 7z a -bd -mmt=off -mm=Copy $curpath/$zipname .
- cd $curpath
-}
-
-MakeSha256CheckSum()
-{
- local readonly workdir="$1"
-
- find $workdir -name '*.mp3' | sort | xargs sha256sum \
- | sed "s=$workdir/==" >> $workdir/sha256sum
-}
-
LoadConfig()
{
- # .albentohandy.conf: set SCRIPTPATH and MUSICPATH
+ # .albentohandy.conf: set MUSICPATH
if [ -f $HOME/.albentohandy.conf ]; then
source $HOME/.albentohandy.conf
else
ExistsBasicProgramms()
{
local exists=true
- local programms=("eyeD3" "flac" "lame" "sha256sum" "7z" "parallel")
+ local programms=("vorbiscomment" "flac" "oggenc" "parallel")
for programm in $programms; do
if [ ! -f /usr/bin/$programm ]; then
parallelopts=":"
curphase=1
phase=3
- checksum=false
- mkzip=false
removework=false
cptodest=false
}
ReadArguments()
{
- while getopts "chi:m:S:rw:z:" optname; do
+ while getopts "hi:m:rw:" optname; do
case "$optname" in
- "c")
- checksum=true
- ((phase++))
- ;;
"h")
Usage
exit 0
dest="$OPTARG"
((phase++))
;;
- "S")
- parallelopts="$OPTARG"
- ;;
"r")
removework=true
;;
"w")
WORK="$OPTARG"
;;
- "z")
- mkzip=true
- zipname="$OPTARG"
- ((phase++))
- ;;
esac
done
}
AdvancedFeatures()
{
- # create sha256sum in working directory
- if [ $checksum == true ]; then
- printf "Phase %02d of %02d: " $((curphase++)) $phase
- printf "create sha256sum\n\n"
- MakeSha256CheckSum "$WORK"
- fi
-
- # make zipfile in the current path
- # content of zipfile is content of working directory
- if [ $mkzip == true ]; then
- printf "Phase %02d of %02d: " $((curphase++)) $phase
- printf " create %s\n" $zipname
- MakeZipFile "$WORK" "$zipname"
- printf "\n"
- fi
-
# copy work directory to destination folder
if [ $cptodest == true ]; then
printf "Phase %02d of %02d:\n" $((curphase++)) $phase
fi
# delete the working directory
- if ([ $mkzip == true ] || [ $cptodest == true ]) \
- && [ $removework == true ]; then
+ if [ $cptodest == true ] && [ $removework == true ]; then
CleanupWorkDir "$WORK"
fi
}
main()
{
WORK="$(pwd)/work.$$" # temporary working directory
- SCRIPTPATH="/usr/bin" # path to flactomp3v2 and notify.sh script
MUSICPATH="/tmp/musikpath" # flac collection directory
ExistsBasicProgramms