+#!/bin/bash
+
read_flac_to_ogg_tags()
{
local inputfile="$1"
local outputfile="$2"
local coverfile="${inputfile%/*}/cover.txt"
- metaflac --export-tags-to=- $inputfile \
- | vorbiscomment --commentfile - --write $outputfile
+ metaflac --export-tags-to=- "$inputfile" \
+ | vorbiscomment --commentfile - --write "$outputfile"
- [ -f $coverfile ] \
+ [ -f "$coverfile" ] \
|| return 0
- echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 $coverfile)" \
- | vorbiscomment --commentfile - --raw --append $outputfile
+ echo "METADATA_BLOCK_PICTURE=$(base64 --wrap 0 "$coverfile")" \
+ | vorbiscomment --commentfile - --raw --append "$outputfile"
}
encoding_flac_to_ogg()
{
local number="$1"
local outputfile="$2"
- local hex_number=$(printf "%08x" "$number")
+ local hex_number=
+ hex_number=$(printf "%08x" "$number")
for i in {0..6..2}; do
- printf "%b" "\x${hex_number:$i:2}" >> $outputfile
+ printf "%b" "\x${hex_number:$i:2}" >> "$outputfile"
done
}
{
local inputfile="$1"
local outputfile="${inputfile/.jpg/.txt}"
- local filesize=$(cat $inputfile | wc -c)
+ local filesize=
+ filesize=$(wc --chars "$inputfile")
+ filesize=${filesize/ */}
# picture typ (jpg)
write_hex_to_file "3" "$outputfile"
# mime type (image/jpeg)
write_hex_to_file "10" "$outputfile"
- printf "%s" "image/jpeg" >> $outputfile
+ printf "%s" "image/jpeg" >> "$outputfile"
# description length (zero)
write_hex_to_file "0" "$outputfile"
# width (zero)
write_hex_to_file "0" "$outputfile"
# file size
write_hex_to_file "$filesize" "$outputfile"
- cat $inputfile >> $outputfile
+ cat "$inputfile" >> "$outputfile"
}
convert_flac_to_ogg()
export -f read_flac_to_ogg_tags
export -f cover_to_metadata
export -f write_hex_to_file
- find $workdir -name '*.jpg' \
+ find "$workdir" -name '*.jpg' \
| sort \
| parallel --will-cite --ungroup \
cover_to_metadata {}
- find $workdir -name '*.flac' \
+ find "$workdir" -name '*.flac' \
| sort \
| parallel --will-cite --ungroup --eta --progress \
flac_to_vorbis "{}"