From 4a9d29a9b9858ba06c945ab436b6146c153e0d0f Mon Sep 17 00:00:00 2001 From: ayakael Date: Fri, 18 May 2018 16:37:07 -0700 Subject: [PATCH] [import_dir] Completed function --- src/import_dir | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/import_dir b/src/import_dir index 6f38e58..359d178 100644 --- a/src/import_dir +++ b/src/import_dir @@ -8,12 +8,41 @@ # USAGE # import_dir # +# DEPENDENCIES src/gen_mtag +# # } import_dir() { local GIT_DIR="${1}" local TRACK_DIR="${2}" - local trackList=($(find ${TRACK_DIR} -maxdepth=1 -name *.flac -print '%p\t')) + local trackList=($(find ${TRACK_DIR} -maxdepth 1 -name *.flac -print '%p\t')) + # Join trackList + _msg EXEC "Generating joined image" + gen_image "${TARGET_DIR}" $(printf "%s\t" ${trackList[@]}) + local EXIT="$?" + [[ $? -eq 0 ]] && _msg OK || { _msg WARN; return 1; } + + + # Generates IMAGEID + for track in ${trackList[@]}; do + local TRACK_EXT="$(cut -d '.' -f2)" + [[ "${TRACK_EXT}" != "FLAC" ]] && SOURCE="${TRACK_EXT}" + done + local IMAGEID="SHA256-${SOURCE}--$(sha256sum "${TARGET_DIR}/joined.flac")" + + # Generate metadata_trackList + local COUNT=0 + for track in ${trackList[@]}; do + 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}");IMAGEID=${IMAGEID};TRACKID=${TRACKID};" + local COUNT=$(( ${COUNT} + 1 )) + done + + # Generate cuesheet + gen_cue $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.cue" + + # Generate tags file + gen_mtag $(printf '%s\t' ${metadata_trackList[@]}) > "${GIT_DIR}/${IMAGEID}.tags" }