- Fix metadata load/save bugs in music_tools lib.

This commit is contained in:
2026-09-02 23:34:23 +02:00
parent cf0548d32d
commit 2298881174
3 changed files with 34 additions and 13 deletions

View File

@@ -249,9 +249,9 @@ mt_tagtab_read()
TAGLIST="${TAGLIST}${tag}:"
fi
if [[ ( "${mode}" != "FACTORING" ) || ( "${tag}" =~ ^${MT_NODEF_TAG_COND}$ ) || ( -v "TAGTAB[\"0,${tag}\"]}" ) ]]
if [[ ( "${mode}" != "FACTORING" ) || ( "${tag}" =~ ^${MT_NODEF_TAG_COND}$ ) || ( -v "TAGTAB[\"0,${tag}\"]" ) ]]
then
if [[ ( ! -v "TAGTAB[\"0,${tag}\"]}" ) || ( "${TAGTAB["0,${tag}"]}" != "${value}") ]]
if [[ ( ! -v "TAGTAB[\"0,${tag}\"]" ) || ( "${TAGTAB["0,${tag}"]}" != "${value}") ]]
then
TAGTAB["${track_id},${tag}"]="$value"
fi
@@ -279,10 +279,10 @@ mt_tagtab_read()
then
TAGLIST="${TAGLIST}${tag}:"
fi
if [[ ( "${mode}" != "FACTORING" ) || ( "${tag}" =~ ^${MT_NODEF_TAG_COND}$ ) || ( "${TAGTAB["0,${tag}"]}" != "" ) ]]
then
if [[ "${TAGTAB["0,${tag}"]}" != "${value}" ]]
if [[ ( "${mode}" != "FACTORING" ) || ( "${tag}" =~ ^${MT_NODEF_TAG_COND}$ ) || ( -v "TAGTAB[\"0,${tag}\"]" ) ]]
then
if [[ ( ! -v "TAGTAB[\"0,${tag}\"]" ) || ( "${TAGTAB["0,${tag}"]}" != "${value}") ]]
then
TAGTAB["${track_id},${tag}"]="$value"
fi
@@ -434,12 +434,22 @@ mt_tag_get()
local track_id="$2"
local tag="$3"
return="${TAGTAB["${track_id},${tag}"]}"
if [[ -v "TAGTAB[\"${track_id},${tag}\"]" ]]
then
return="${TAGTAB["${track_id},${tag}"]}"
else
return=""
fi
if [[ "${return}" == "" ]]
then
return="${TAGTAB["0,${tag}"]}"
if [[ -v "TAGTAB[\"0,${tag}\"]" ]]
then
return="${TAGTAB["0,${tag}"]}"
else
return=""
fi
if [[ "${return}" == "" ]] && [[ "${tag}" == "TRACKNUMBER" ]]
then
@@ -510,12 +520,12 @@ mt_tag_read()
case "${track_file}"
in
*.flac)
sh_exec FORCE "metaflac --show-tag=\"${tag}\" \"${track_file}\" | sed -e 's/^[^=]*=//' -e ':a' -e 'N' -e '"'$!'"ba' -e 's/\n/\\n/g'"
sh_exec "metaflac --show-tag=\"${tag}\" \"${track_file}\" | sed -e 's/^[^=]*=//' -e ':a' -e 'N' -e '"'$!'"ba' -e 's/\n/\\n/g'"
;;
*.mp3)
# sh_exec FORCE "mid3v2 --list \"${track_file}\" | tail -n +2 | sed -e 's/^[^=]*=/\U&\E/' | grep -e \"^${MT_FLAC_2_MP3_TAB[\"${tag}\"]}\" | sed -e 's/^[^=]*=//' -e ':a' -e 'N' -e '"'$!'"ba' -e 's/\n/\\n/g'"
sh_exec FORCE "mid3v2 --list \"${track_file}\" | tail -n +2 | grep -e \"^${tag}\" | sed -e 's/^[^=]*=//' -e ':a' -e 'N' -e '"'$!'"ba' -e 's/\n/\\n/g'"
# sh_exec "mid3v2 --list \"${track_file}\" | tail -n +2 | sed -e 's/^[^=]*=/\U&\E/' | grep -e \"^${MT_FLAC_2_MP3_TAB[\"${tag}\"]}\" | sed -e 's/^[^=]*=//' -e ':a' -e 'N' -e '"'$!'"ba' -e 's/\n/\\n/g'"
sh_exec "mid3v2 --list \"${track_file}\" | tail -n +2 | grep -e \"^${tag}\" | sed -e 's/^[^=]*=//' -e ':a' -e 'N' -e '"'$!'"ba' -e 's/\n/\\n/g'"
;;
*)