Compare commits
4 Commits
7c33ff2dca
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 52eff86047 | |||
| 444f3ada33 | |||
| c2644c93ee | |||
| c7a7dee603 |
@@ -78,12 +78,16 @@ function read_tag_id3 {
|
||||
local tag="$1"
|
||||
local file="$2"
|
||||
|
||||
# TODO: Amorphis/Eclipse eclipse uses 3char id3v2 rfc822 codes
|
||||
declare -A id3v2_map=( [artist]=TPE1 \
|
||||
[album]=TALB \
|
||||
[title]=TIT2 \
|
||||
[date]=TYER \
|
||||
[track]=TRCK )
|
||||
declare -A id3v2_map_alt=( [artist]=TP1 \
|
||||
[album]=TAL \
|
||||
[title]=TT2 \
|
||||
[date]=TYE \
|
||||
[track]=TRK )
|
||||
|
||||
local id3v2_content_rfc822
|
||||
id3v2_content_rfc822=$(id3v2 -R "$file")
|
||||
@@ -102,14 +106,26 @@ function read_tag_id3 {
|
||||
error "Unknown tag \"$tag\" requested for file \"$file\""
|
||||
return
|
||||
fi
|
||||
local line=$(grep -E "^$rfc822tag:\s" <<<"$id3v2_content_rfc822" | head -1)
|
||||
local result=${line:6}
|
||||
|
||||
local substr_idx=6
|
||||
local line=$(grep -aE "^$rfc822tag:\s" <<<"$id3v2_content_rfc822" | head -1)
|
||||
if [[ -z $line ]]; then
|
||||
rfc822tag=${id3v2_map_alt[$tag]}
|
||||
line=$(grep -aE "^$rfc822tag:\s" <<<"$id3v2_content_rfc822" | head -1)
|
||||
substr_idx=5
|
||||
fi
|
||||
|
||||
local result=${line:${substr_idx}}
|
||||
|
||||
if [[ -z $result ]]; then
|
||||
error "Reading tag \"$tag\" from \"$file\" failed: empty value"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $tag == 'track' ]]; then
|
||||
result=$(grep -oE '^[[:digit:]]+' <<<"$result")
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
fi
|
||||
}
|
||||
@@ -273,13 +289,14 @@ function cmd_wrap {
|
||||
}
|
||||
|
||||
function tagmove_single {
|
||||
function _replace_slash { tr '/' '-' <<<"$1"; }
|
||||
local_errf=
|
||||
file_name="$1"
|
||||
artist=$(read_tag artist "$file_name")
|
||||
date=$(read_tag date "$file_name")
|
||||
album=$(read_tag album "$file_name")
|
||||
track=$(read_tag track "$file_name")
|
||||
title=$(read_tag title "$file_name")
|
||||
artist=$(_replace_slash "$(read_tag artist "$file_name")")
|
||||
date=$( _replace_slash "$(read_tag date "$file_name")")
|
||||
album=$( _replace_slash "$(read_tag album "$file_name")")
|
||||
track=$( _replace_slash "$(read_tag track "$file_name")")
|
||||
title=$( _replace_slash "$(read_tag title "$file_name")")
|
||||
|
||||
if [[ -n $local_errf ]]; then
|
||||
error "Error reading tags for file \"$file_name\""
|
||||
@@ -296,8 +313,8 @@ function tagmove_single {
|
||||
fi
|
||||
|
||||
# Set fixed width for track number
|
||||
track=$(printf "%02d" $(cut -d'/' -f1 <<<"${track#0}"))
|
||||
|
||||
track=$(printf "%02d" $(cut -d'-' -f1 <<<"${track#0}"))
|
||||
|
||||
|
||||
eval "dest_directory=\"$DIRECTORY_FORMAT\""
|
||||
eval "dest_file=\"$FILE_FORMAT\""
|
||||
|
||||
Reference in New Issue
Block a user