tc-audio-transcode: track number is now safe, "Machine" does not become "MacHine", metadata entries beyond the first one are discarded.

master
Pierre Neidhardt 2013-04-05 14:47:26 +02:00
parent c6ff2f78a7
commit 1670553673
2 changed files with 15 additions and 12 deletions

View File

@ -185,9 +185,11 @@ if [ -z "$FORMAT" ]; then
exit
fi
## This function greps for one match only, so if several metadata are present,
## this may not be the desired values.
_metadata_filter()
{
echo "$METADATA" | grep -i "\<$1\>" | sed 's/[^:]* : //g'
echo "$METADATA" | grep -im1 "\<$1\>" | sed 's/[^:]* : //g'
}
TITLE=$(_metadata_filter "title")
@ -240,8 +242,9 @@ case $OUTPUT_GENRE in
*) OUTPUT_GENRE="";;
esac
## We remove the track count if any, we suppress leading zeros.
OUTPUT_TRACK=$(eval _string_cleanser $OUTPUT_TRACK | sed -e 's/^0*//' -e 's|/.*||')
## We remove the track count if any, we suppress leading zeros, we suppress all
## non-digit characters.
OUTPUT_TRACK=$(eval _string_cleanser $OUTPUT_TRACK | sed -e 's/^0*//' -e 's|[^[:digit:]].*||')
## If DATE is not a year, we use TYER if it is a year.
OUTPUT_DATE=$(eval _string_cleanser $OUTPUT_DATE)

View File

@ -34,7 +34,7 @@
BEGIN {
#-----ABBREVIATIONS TO BE SET IN MIXEDCASE-----
mixed = "KlassX "
mixed = "KlassX Machine "
split(mixed, keep_mixed, " ")
#-----ABBREVIATIONS TO BE SET IN LOWERCASE-----
@ -178,18 +178,18 @@ function titlecase(string,x) {
} while (pos > 0);
# Everything should be converted now.
## Everything should be converted now.
# Double exception 1: Set 1st word of string in Cap case
# Need to handle potential internal single/double quotes like
# "A Day in the Life" or 'On the Waterfront'
## WARNING: here we consider digits as part of a work (as in 1st, 2nd, etc.)
## Double exception 1: Set 1st word of string in capital case. Need to
## handle potential internal single/double quotes like "A Day in the Life"
## or 'On the Waterfront'. WARNING: here we consider digits as part of a
## work (as in 1st, 2nd, etc.)
match(a, /[A-Za-z0-9]/)
a = toupper(substr(a,1,RSTART)) substr(a,RSTART+1)
# Double exception 2: Set 1st word after a colon, question mark or
# exclamation point in title case. This kludge handles multiple colons,
# question marks, etc. on the line. \a is the BEL or CTRL-G character.
## Double exception 2: Set 1st word after a colon, question mark or
## exclamation point in title case. This kludge handles multiple colons,
## question marks, etc. on the line. \a is the BEL or CTRL-G character.
## WARNING: we also follow double quotes by a capital.
done = gensub(/([:?!"][^a-zA-Z]*)([a-zA-Z])/,"\\1\a\\2", "g", a)