[import_dir] Now supports EAC and CUETOOLS sources

This commit is contained in:
ayakael 2018-07-12 16:57:03 -08:00
parent b4ed3f664d
commit 8bc2cb41a3
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026

View file

@ -15,32 +15,34 @@
import_dir() { import_dir() {
local GIT_DIR="${1}" local GIT_DIR="${1}"
local TRACK_DIR="${2}" local TRACK_DIR="${2}"
local SOURCE=FLAC local SOURCE="${3}"
local trackList=($(find ${TRACK_DIR} -maxdepth 1 -name '*.flac' -printf '%p\n' | sort)) local trackList=($(find ${TRACK_DIR} -maxdepth 1 -name '*.flac' -printf '%p\n' | sort))
# Join trackList # Join trackList
_msg EXEC "Generating joined image" _msg EXEC "Processing audio files"
gen_image "${TRACK_DIR}" $(printf "%s\t" ${trackList[@]}) > ${STDERR} 2>&1 gen_image "${TRACK_DIR}/flac" $(printf "%s\t" ${trackList[@]}) > ${STDERR} 2>&1
local EXIT="$?" local EXIT="$?"
[[ $? -eq 0 ]] && _msg OK || { _msg WARN; return 1; } [[ $? -eq 0 ]] && _msg OK || { _msg WARN; return 1; }
# Generates IMAGEID # Generates IMAGEID
_msg EXEC "Generating IMAGEID" _msg EXEC "Generating IMAGEID"
for track in ${trackList[@]}; do [[ "${SOURCE}" == "CUETOOLS" ]] && local SOURCE=$(grep "CTDB TOCID:" ${TRACK_DIR}/accurip)
local TRACK_EXT="$(basename ${track} | cut -d. -f2)" local IMAGEID="SHA256-${SOURCE}--$(sha256sum "${TRACK_DIR}/flac" | cut -d' ' -f1)"
[[ "${TRACK_EXT}" != "FLAC" ]] && SOURCE="${TRACK_EXT}"
done
local IMAGEID="SHA256-${SOURCE}--$(sha256sum "${TRACK_DIR}/joined.flac" | cut -d' ' -f1)"
_msg OK _msg OK
# Generate metadata_trackList # Generate metadata_trackList
local COUNT=0 local COUNT=0
for track in ${trackList[@]}; do for track in ${trackList[@]}; do
local TRACKID=$(metaflac --list --block-number=0 "${track}" | awk 'BEGIN{FS=": "}{if($1==" MD5 signature") {print $2}}') if [[ "${SOURCE}" == "FLAC" ]]; then
local DURATION=$(soxi -D "${track}") local TRACKID=$(metaflac --list --block-number=0 "${track}" | awk 'BEGIN{FS=": "}{if($1==" MD5 signature") {print $2}}')
local metadata_trackList[${COUNT}]="$(print_meta_flac "${track}");DURATION=${DURATION};IMAGEID=${IMAGEID};TRACKID=${TRACKID};" local DURATION=$(soxi -D "${track}")
local metadata_trackList[${COUNT}]="$(print_meta_flac "${track}");DURATION=${DURATION};IMAGEID=${IMAGEID};TRACKID=${TRACKID};"
elif [[ "${SOURCE}" == "CUETOOLS" ]] || [[ "${SOURCE}" == "EAC" ]]; then
local trackmetaList=$(gen_trackmeta "${TRACK_DIR}" "${FLAC}" "${CUE}")
local metadata_trackList=($(print_meta_cue "${TRACK_DIR}/cue")${trackmetaList}IMAGEID=${IMAGEID};)
fi
local COUNT=$(( ${COUNT} + 1 )) local COUNT=$(( ${COUNT} + 1 ))
done done
@ -60,7 +62,7 @@ import_dir() {
# Move joined.flac to GIT_DIR # Move joined.flac to GIT_DIR
mv "${TRACK_DIR}/joined.flac" "${GIT_DIR}/${IMAGEID}.flac" mv "${TRACK_DIR}/flac" "${GIT_DIR}/${IMAGEID}.flac"
# Generate cover images # Generate cover images
gen_cover ${TRACK_DIR} > ${GIT_DIR}/${IMAGEID}.png gen_cover ${TRACK_DIR} > ${GIT_DIR}/${IMAGEID}.png