#!/bin/bash # doc cmd_import_tracks { # # DESCRIPTION # cmd_import_tracks - Wrapper for import_tracks # # USAGE # cmd_import_tracks # # DEPENDENCIES bunc/src/* src/import_track src/import_src src/ismp3 src/iszip # # } cmd_import_tracks() { local GIT_DIR="${1}"; shift case ${1} in (-b) local BATCHID=${2}; shift 2;; esac local srcList=(${@}) local SOURCE=FLAC rm -Rvf "${GIT_DIR}/.import" >/dev/null 2>&1 for src in ${srcList[@]}; do if iszip ${src}; then _msg EXEC "Uncompressing ${src}" 7z x "${src}" -o"${_OPT_TMP}/$(basename ${src})/" -y >${STDERR} 2>&1 local EXIT=$? [[ ${EXIT} -eq 0 ]] && { _msg OK; local src="${_OPT_TMP}/$(basename ${src})"; } || _msg WARN local ZIP=true fi local fileList=($(find "${src}" -name '*.flac' -o -name '*.mp3')) _msg EXEC "Consolidating ${src}" for file in ${fileList[@]}; do import_track "${GIT_DIR}" "${file}" "${SOURCE}" >${STDERR} 2>&1 local EXIT=$? [[ ${EXIT} -eq 0 ]] || { local CONSOLE_ERROR=true; _msg WARN "Consolidation of ${file} failed, continuing"; continue; } done [[ "${CONSOLE_ERROR}" == "true" ]] || _msg OK [[ "${ZIP}" == "true" ]] && rm -Rvf "${src}" >/dev/null 2>&1 done local importList=($(find ${GIT_DIR}/.import/FLAC -mindepth 1 -maxdepth 1 -type d -printf '%p\t')) for import in ${importList[@]}; do _msg EXEC "Importing ${import}" import_src "${GIT_DIR}" "${import}" $([[ -n "${BATCHID}" ]] && echo "-b") ${BATCHID} >${STDERR} 2>&1 local EXIT=$? [[ ${EXIT} -eq 0 ]] && _msg OK || { _msg WARN "Importation of ${import} failed, continuing"; continue; } rm -R ${import} >/dev/null 2>&1 done rm -Rvf "${GIT_DIR}/.import" >/dev/null 2>&1 }