8d7c925676
[import_src] Now fills in newline char in between outouts of print_meta* and gen_metatrack when combining the two inteo metadataList
50 lines
1.9 KiB
Bash
50 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
# doc gen_metatrack {
|
|
#
|
|
# DESCRIPTION
|
|
# gen_metatrack - Generates track specific metadata using image file
|
|
#
|
|
# USAGE
|
|
# gen_metatrack </path/to/flac/file> </path/to/cue/file>
|
|
#
|
|
# DEPENDENCIES src/gen_tracks
|
|
#
|
|
# }
|
|
|
|
gen_metatrack() {
|
|
while true; do
|
|
case ${1} in
|
|
(-c) local CUE="${2}"; shift 2 ;;
|
|
(*) local fileList=(${@}); local TOTALTRACKS=${#fileList[@]}; break ;;
|
|
esac
|
|
done
|
|
|
|
|
|
if [[ -n "${CUE}" ]]; then
|
|
gen_tracks "${_OPT_TMP}" "${fileList}" "${CUE}" >/dev/null 2>&1
|
|
local TOTALTRACKS="$(grep -e "TRACK [0-9][0-9] AUDIO" "${CUE}" | wc -l)"
|
|
local COUNT=0
|
|
while [[ ${COUNT} -lt ${TOTALTRACKS} ]]; do
|
|
local fileList[${COUNT}]=$(printf "${_OPT_TMP}/split-track%02d.flac\t" $(( ${COUNT} + 1 )))
|
|
local COUNT=$(( ${COUNT} + 1 ))
|
|
done
|
|
fi
|
|
|
|
local replaygainList=($(metaflac --scan-replay-gain ${fileList[@]} | awk 'BEGIN{ORS=" ";FS=":"}{print $2}' | tr ' ' '\t'))
|
|
local REPLAYGAIN_ALBUM_GAIN=${replaygainList[0]}
|
|
local REPLAYGAIN_ALBUM_PEAK=${replaygainList[1]}
|
|
local trackidList=($(metaflac --list --block-number=0 ${fileList[@]} | awk 'BEGIN{FS=": "}{if($2==" MD5 signature") {print $3}}'))
|
|
local durationList=($(soxi -D ${fileList[@]}))
|
|
|
|
local COUNT=0
|
|
while [[ ${COUNT} -lt ${TOTALTRACKS} ]]; do
|
|
local TRACKID=${trackidList[${COUNT}]}
|
|
local DURATION=${durationList[${COUNT}]}
|
|
local REPLAYGAIN_TRACK_GAIN=${replaygainList[$(( $(( ${COUNT} * 4 )) + 2 ))]}
|
|
local REPLAYGAIN_TRACK_PEAK=${replaygainList[$(( $(( ${COUNT} * 4 )) + 3 ))]}
|
|
echo "TRACKID=${TRACKID};DURATION=${DURATION};REPLAYGAIN_ALBUM_GAIN=${REPLAYGAIN_ALBUM_GAIN};REPLAYGAIN_ALBUM_PEAK=${REPLAYGAIN_ALBUM_PEAK};REPLAYGAIN_TRACK_GAIN=${REPLAYGAIN_TRACK_GAIN};REPLAYGAIN_TRACK_PEAK=${REPLAYGAIN_TRACK_PEAK}"
|
|
local COUNT=$(( ${COUNT} + 1 ))
|
|
done
|
|
}
|
|
|