- Add VSL support,

- Support now rx3-base 1.2.0.
This commit is contained in:
2026-09-13 12:14:25 +02:00
parent 2298881174
commit 7cbd0dc0c9
16 changed files with 688 additions and 472 deletions

View File

@@ -39,15 +39,16 @@
# Global Variables
#-----------------------------------------------------------------------------------------------------------------------------------
declare -g VERSION="1.1.0"
declare -g NAME="album_convert"
declare -g VERSION="1.1.3"
declare -g NAME="Album_Convert"
declare -g HELP="usage: [-h | --help] | [-V | --version] | [-T | --test] [-v | --verbose] [-r | --resample] [-d | --downsampled_tag] <source_dir> <target_dir>"
declare -g RESAMPLE="FALSE"
declare -g DSTAG="FLASE"
declare -g SOURCE_DIR=""
declare -g TARGET_DIR=""
declare -g EXIT_CODE=0
declare -g MODE="DEFAULT"
declare -g VERBOSE="FALSE"
declare -g DRY_RUN="FALSE"
@@ -75,7 +76,6 @@ ac_version_print()
ac_help_print()
{
ac_version_print
help_print
}
@@ -103,8 +103,8 @@ ac_args_parse()
# Mode switches
-T|--test) MODE="TEST"; shift;;
-h|--help) MODE="EXIT"; ac_help_print; shift;;
-V|--version) MODE="EXIT"; ac_version_print; shift;;
-h|--help) MODE="HELP"; shift;;
-V|--version) MODE="VERSION"; shift;;
# Global options
-v|--verbose) VERBOSE="TRUE"; shift;;
@@ -117,7 +117,7 @@ ac_args_parse()
esac
done
if [[ "${MODE}" != "EXIT" ]]
if [[ "${MODE}" == "DEFAULT" ]]
then
if [[ "${#}" != "2" ]]
then
@@ -128,11 +128,11 @@ ac_args_parse()
echo_error "Too many args!"
fi
MODE="EXIT"
ac_help_print
MODE="HELP"
EXIT_CODE=1
else
SOURCE_DIR="$1"
TARGET_DIR="$2"
SOURCE_DIR="$1"
TARGET_DIR="$2"
fi
fi
}
@@ -145,19 +145,31 @@ ac_args_parse()
# Main
#-----------------------------------------------------------------------------------------------------------------------------------
vsl_add
ac_args_parse "$@"
case "${MODE}" in
"EXIT")
exit ${EXIT_CODE}
;;
"HELP")
ac_help_print
exit ${EXIT_CODE}
;;
if [[ "${MODE}" == "EXIT" ]]
then
exit 0
else
if [[ "${MODE}" == "TEST" ]]
then
"TEST")
DRY_RUN="TRUE"
fi
fi
;;
"VERSION")
ac_version_print
exit ${EXIT_CODE}
;;
esac
if [[ "${RESAMPLE}" == "TRUE" ]]
then
@@ -170,55 +182,59 @@ fi
echo_error "${NAME}: Mode: [${MODE}] Verbose: [${VERBOSE}] Resample : [${RESAMPLE}] DownSampled_Tag : [${DSTAG}] Source_Dir: [${SOURCE_DIR}] Target_Dir: [${TARGET_DIR}]"
if [[ ! -d "${TARGET_DIR}" ]]
then
echo_error "Target directory doesn't exit !"
exit -1
fi
for file in "${SOURCE_DIR}"/*@(.flac|.ogg|.mp3|.m4a|.ape|.wav)
do
id="$(basename "${file}" | sed -e "s/-.*//")"
target_file="${TARGET_DIR}/$(basename "${file}" | sed -e 's/\.[^.]*$//').flac"
cmd_exec ffmpeg -i "${file}" -compression_level 12 ${resample_flags} "${target_file}"
done
set -x
if [[ "${RESAMPLE}" == "TRUE" ]]
then
for file in "${TARGET_DIR}"/*.flac
EXIT_CODE=1
else
for file in "${SOURCE_DIR}"/*@(.flac|.ogg|.mp3|.m4a|.ape|.wav)
do
if [[ "${DSTAG}" == "TRUE" ]]
then
tag="DESCRIPTION"
id="$(basename "${file}" | sed -e "s/-.*//")"
target_file="${TARGET_DIR}/$(basename "${file}" | sed -e 's/\.[^.]*$//').flac"
value="$(mt_tag_read "${file}" "${tag}")"
if [[ "$( echo "${value}" | grep "Downsampled")" == "" ]]
then
value="${value}\nDownsampled"
mt_tag_delete "${file}" "${tag}"
mt_tag_write "${file}" "${tag}" "${value}"
fi
fi
for tag in "ALBUM" "TITLE"
do
value="$(mt_tag_read "${file}" "${tag}")"
new_value="$(echo ${value} | sed -e 's/ - HD$//')"
if [[ "${value}" != "${new_value}" ]]
then
mt_tag_delete "${file}" "${tag}"
mt_tag_write "${file}" "${tag}" "${new_value}"
fi
done
if [[ "${file}" != "${file/-hd.flac/.flac}" ]]
then
cmd_exec mv "${file}" "${file/-hd.flac/.flac}"
else
echo_error "No '-hd' renmaming needed..."
fi
cmd_exec ffmpeg -i "${file}" -compression_level 12 ${resample_flags} "${target_file}"
done
if [[ "${RESAMPLE}" == "TRUE" ]]
then
for file in "${TARGET_DIR}"/*.flac
do
if [[ "${DSTAG}" == "TRUE" ]]
then
tag="DESCRIPTION"
value="$(mt_tag_read "${file}" "${tag}")"
if [[ "$( echo "${value}" | grep "Downsampled")" == "" ]]
then
value="${value}\nDownsampled"
mt_tag_delete "${file}" "${tag}"
mt_tag_write "${file}" "${tag}" "${value}"
fi
fi
for tag in "ALBUM" "TITLE"
do
value="$(mt_tag_read "${file}" "${tag}")"
new_value="$(echo ${value} | sed -e 's/ - HD$//')"
if [[ "${value}" != "${new_value}" ]]
then
mt_tag_delete "${file}" "${tag}"
mt_tag_write "${file}" "${tag}" "${new_value}"
fi
done
if [[ "${file}" != "${file/-hd.flac/.flac}" ]]
then
cmd_exec mv "${file}" "${file/-hd.flac/.flac}"
else
echo_error "No '-hd' renmaming needed..."
fi
done
fi
fi
exit ${EXIT_CODE}