[import_dir] Now supports EAC and CUETOOLS sources
This commit is contained in:
parent
b4ed3f664d
commit
8bc2cb41a3
1 changed files with 14 additions and 12 deletions
|
@ -15,32 +15,34 @@
|
|||
import_dir() {
|
||||
local GIT_DIR="${1}"
|
||||
local TRACK_DIR="${2}"
|
||||
local SOURCE=FLAC
|
||||
local SOURCE="${3}"
|
||||
|
||||
local trackList=($(find ${TRACK_DIR} -maxdepth 1 -name '*.flac' -printf '%p\n' | sort))
|
||||
|
||||
# Join trackList
|
||||
_msg EXEC "Generating joined image"
|
||||
gen_image "${TRACK_DIR}" $(printf "%s\t" ${trackList[@]}) > ${STDERR} 2>&1
|
||||
_msg EXEC "Processing audio files"
|
||||
gen_image "${TRACK_DIR}/flac" $(printf "%s\t" ${trackList[@]}) > ${STDERR} 2>&1
|
||||
local EXIT="$?"
|
||||
[[ $? -eq 0 ]] && _msg OK || { _msg WARN; return 1; }
|
||||
|
||||
|
||||
# Generates IMAGEID
|
||||
_msg EXEC "Generating IMAGEID"
|
||||
for track in ${trackList[@]}; do
|
||||
local TRACK_EXT="$(basename ${track} | cut -d. -f2)"
|
||||
[[ "${TRACK_EXT}" != "FLAC" ]] && SOURCE="${TRACK_EXT}"
|
||||
done
|
||||
local IMAGEID="SHA256-${SOURCE}--$(sha256sum "${TRACK_DIR}/joined.flac" | cut -d' ' -f1)"
|
||||
[[ "${SOURCE}" == "CUETOOLS" ]] && local SOURCE=$(grep "CTDB TOCID:" ${TRACK_DIR}/accurip)
|
||||
local IMAGEID="SHA256-${SOURCE}--$(sha256sum "${TRACK_DIR}/flac" | cut -d' ' -f1)"
|
||||
_msg OK
|
||||
|
||||
# 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 DURATION=$(soxi -D "${track}")
|
||||
local metadata_trackList[${COUNT}]="$(print_meta_flac "${track}");DURATION=${DURATION};IMAGEID=${IMAGEID};TRACKID=${TRACKID};"
|
||||
if [[ "${SOURCE}" == "FLAC" ]]; then
|
||||
local TRACKID=$(metaflac --list --block-number=0 "${track}" | awk 'BEGIN{FS=": "}{if($1==" MD5 signature") {print $2}}')
|
||||
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 ))
|
||||
done
|
||||
|
||||
|
@ -60,7 +62,7 @@ import_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
|
||||
gen_cover ${TRACK_DIR} > ${GIT_DIR}/${IMAGEID}.png
|
||||
|
|
Loading…
Reference in a new issue