2018-04-08 16:31:53 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# doc cmd_import_tracks {
|
|
|
|
#
|
|
|
|
# DESCRIPTION
|
|
|
|
# cmd_import_tracks - Wrapper for import_tracks
|
|
|
|
#
|
|
|
|
# USAGE
|
2018-05-18 12:37:03 -07:00
|
|
|
# cmd_import_tracks </path/to/git/dir> </path/to/dir_or_archive>
|
2018-04-08 16:31:53 -04:00
|
|
|
#
|
2018-05-18 13:39:39 -07:00
|
|
|
# DEPENDENCIES bunc/src/* src/import_track src/import_dir src/ismp3 src/iszip
|
|
|
|
#
|
2018-04-08 16:31:53 -04:00
|
|
|
# }
|
|
|
|
|
2018-05-15 22:52:31 -07:00
|
|
|
cmd_import_tracks() {
|
2018-05-18 12:37:03 -07:00
|
|
|
local GIT_DIR="${1}"; shift
|
|
|
|
local srcList=(${@})
|
|
|
|
|
|
|
|
for src in ${srcList}; do
|
|
|
|
if iszip ${src}; then
|
|
|
|
_msg EXEC "Uncompressing ${archive}"
|
2018-05-18 18:13:37 -07:00
|
|
|
7z x "${src}" -o"${_OPT_TMP}/$(basename ${src})/" -y >${STDERR} 2>&1
|
2018-05-18 12:37:03 -07:00
|
|
|
local EXIT=$?
|
2018-05-18 18:13:37 -07:00
|
|
|
[[ ${EXIT} -eq 0 ]] && { _msg OK; local src="${_OPT_TMP}/$(basename ${src})"; } || _msg WARN
|
2018-05-18 12:37:03 -07:00
|
|
|
fi
|
|
|
|
local fileList=($(find "${src}" -name '*.flac' -o -name '*.mp3'))
|
2018-05-18 18:13:37 -07:00
|
|
|
echo ${fileList[@]}
|
2018-05-18 12:37:03 -07:00
|
|
|
|
|
|
|
for file in ${fileList}; do
|
|
|
|
_msg EXEC "Consolidating ${file}"
|
2018-05-18 18:06:19 -07:00
|
|
|
import_track "${GIT_DIR}" "${file}" >${STDERR} 2>&1
|
2018-05-18 12:37:03 -07:00
|
|
|
local EXIT=$?
|
|
|
|
[[ ${EXIT} -eq 0 ]] && _msg OK || { _msg WARN "Consolidation of ${file} failed, continuing"; continue; }
|
2018-04-08 16:31:53 -04:00
|
|
|
done
|
|
|
|
done
|
2018-05-18 12:37:03 -07:00
|
|
|
|
2018-05-18 18:07:24 -07:00
|
|
|
local importList=($(find ${GIT_DIR}/.import/ -maxdepth 1 -type d -printf '%p\t'))
|
2018-05-18 12:37:03 -07:00
|
|
|
for import in ${importList[@]}; do
|
|
|
|
_msg EXEC "Importing ${import}"
|
2018-05-18 18:06:19 -07:00
|
|
|
import_dir "${GIT_DIR}" "${import}" >${STDERR} 2>&1
|
2018-05-18 12:37:03 -07:00
|
|
|
local EXIT=$?
|
|
|
|
[[ ${EXIT} -eq 0 ]] && _msg OK || { _msg WARN "Importation of ${import} failed, continuing"; continue; }
|
|
|
|
done
|
|
|
|
|
2018-05-18 18:06:19 -07:00
|
|
|
|
|
|
|
|
2018-04-08 16:31:53 -04:00
|
|
|
}
|