ability to specify field list (for Ogg/Flac), as well as specify field contents (Debian: #655078)
It allows to call `cuetag` like so:
cuetag Björk-Volta.cue *.ogg ARTIST ALBUM TITLE YEAR=2007 GENRE=electronic TRACKNUMBER
which accomplishes two things:
1. it pre-selects the fields and specifies their order;
2. it hardcodes two fields to specific values for all tracks.
Since the field list is hardcoded for MP3, any fields specified on
the command line are effectively ignored. This could probably be
implemented better, but I do not care about MP3 at all.
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=655078
From: martin f krafft <madduck@debian.org>
Author: Dmitry Smirnov <onlyjob@member.fsf.org>
This commit is contained in:
@@ -27,6 +27,10 @@ usage()
|
|||||||
# for FLAC and Ogg Vorbis files
|
# for FLAC and Ogg Vorbis files
|
||||||
vorbis()
|
vorbis()
|
||||||
{
|
{
|
||||||
|
trackno=$1; shift
|
||||||
|
file="$1"; shift
|
||||||
|
fields="$@"
|
||||||
|
|
||||||
# FLAC tagging
|
# FLAC tagging
|
||||||
# --remove-vc-all overwrites existing comments
|
# --remove-vc-all overwrites existing comments
|
||||||
METAFLAC="metaflac --remove-all-tags --import-tags-from=-"
|
METAFLAC="metaflac --remove-all-tags --import-tags-from=-"
|
||||||
@@ -40,7 +44,7 @@ vorbis()
|
|||||||
# TODO: this also outputs to stdout
|
# TODO: this also outputs to stdout
|
||||||
TXTFILE="tee"
|
TXTFILE="tee"
|
||||||
|
|
||||||
case "$2" in
|
case "$file" in
|
||||||
*.[Ff][Ll][Aa][Cc])
|
*.[Ff][Ll][Aa][Cc])
|
||||||
VORBISTAG=$METAFLAC
|
VORBISTAG=$METAFLAC
|
||||||
;;
|
;;
|
||||||
@@ -56,6 +60,7 @@ vorbis()
|
|||||||
# see http://www.xiph.org/ogg/vorbis/doc/v-comment.html
|
# see http://www.xiph.org/ogg/vorbis/doc/v-comment.html
|
||||||
# TRACKTOTAL is not in the Xiph recomendation, but is in common use
|
# TRACKTOTAL is not in the Xiph recomendation, but is in common use
|
||||||
|
|
||||||
|
[ -n "$fields" ] ||
|
||||||
fields='TITLE VERSION ALBUM TRACKNUMBER TRACKTOTAL ARTIST PERFORMER COPYRIGHT LICENSE ORGANIZATION DESCRIPTION GENRE DATE LOCATION CONTACT ISRC'
|
fields='TITLE VERSION ALBUM TRACKNUMBER TRACKTOTAL ARTIST PERFORMER COPYRIGHT LICENSE ORGANIZATION DESCRIPTION GENRE DATE LOCATION CONTACT ISRC'
|
||||||
|
|
||||||
# fields' corresponding cueprint conversion characters
|
# fields' corresponding cueprint conversion characters
|
||||||
@@ -79,16 +84,21 @@ vorbis()
|
|||||||
ISRC='%i %u'
|
ISRC='%i %u'
|
||||||
|
|
||||||
(for field in $fields; do
|
(for field in $fields; do
|
||||||
|
case "$field" in
|
||||||
|
(*=*) echo "$field";;
|
||||||
|
(*)
|
||||||
value=""
|
value=""
|
||||||
for conv in $(eval echo \$$field); do
|
for conv in $(eval echo \$$field); do
|
||||||
value=$($CUEPRINT -n $1 -t "$conv\n" "$cue_file")
|
value=$($CUEPRINT -n $trackno -t "$conv\n" "$cue_file")
|
||||||
|
|
||||||
if [ -n "$value" ]; then
|
if [ -n "$value" ]; then
|
||||||
echo "$field=$value"
|
echo "$field=$value"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done) | $VORBISTAG "$2"
|
;;
|
||||||
|
esac
|
||||||
|
done) | $VORBISTAG "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
id3()
|
id3()
|
||||||
@@ -117,6 +127,9 @@ id3()
|
|||||||
TRACKNUMBER='%n'
|
TRACKNUMBER='%n'
|
||||||
|
|
||||||
for field in $fields; do
|
for field in $fields; do
|
||||||
|
case "$field" in
|
||||||
|
*=*) value="${field#*=}";;
|
||||||
|
*)
|
||||||
value=""
|
value=""
|
||||||
for conv in $(eval echo \$$field); do
|
for conv in $(eval echo \$$field); do
|
||||||
value=$($CUEPRINT -n $1 -t "$conv\n" "$cue_file")
|
value=$($CUEPRINT -n $1 -t "$conv\n" "$cue_file")
|
||||||
@@ -125,6 +138,8 @@ id3()
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [ -n "$value" ]; then
|
if [ -n "$value" ]; then
|
||||||
case $field in
|
case $field in
|
||||||
@@ -167,6 +182,15 @@ main()
|
|||||||
ntrack=$(cueprint -d '%N' "$cue_file")
|
ntrack=$(cueprint -d '%N' "$cue_file")
|
||||||
trackno=1
|
trackno=1
|
||||||
|
|
||||||
|
FILES= FIELDS=
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
*.*) FILES="$FILES $arg";;
|
||||||
|
*) FIELDS="$FIELDS $arg";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
set -- $FILES
|
||||||
if [ $# -ne $ntrack ]; then
|
if [ $# -ne $ntrack ]; then
|
||||||
echo "warning: number of files does not match number of tracks"
|
echo "warning: number of files does not match number of tracks"
|
||||||
fi
|
fi
|
||||||
@@ -174,13 +198,13 @@ main()
|
|||||||
for file in "$@"; do
|
for file in "$@"; do
|
||||||
case $file in
|
case $file in
|
||||||
*.[Ff][Ll][Aa][Cc])
|
*.[Ff][Ll][Aa][Cc])
|
||||||
vorbis $trackno "$file"
|
vorbis $trackno "$file" $FIELDS
|
||||||
;;
|
;;
|
||||||
*.[Oo][Gg][Gg])
|
*.[Oo][Gg][Gg])
|
||||||
vorbis $trackno "$file"
|
vorbis $trackno "$file" $FIELDS
|
||||||
;;
|
;;
|
||||||
*.[Mm][Pp]3)
|
*.[Mm][Pp]3)
|
||||||
id3 $trackno "$file"
|
id3 $trackno "$file" $FIELDS
|
||||||
;;
|
;;
|
||||||
*.[Tt][Xx][Tt])
|
*.[Tt][Xx][Tt])
|
||||||
vorbis $trackno "$file"
|
vorbis $trackno "$file"
|
||||||
|
|||||||
Reference in New Issue
Block a user