[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#655078: ability to specify field list (for Ogg/Flac), as well as specify field contents



Package: cuetools
Version: 1.3.1-12
Severity: wishlist
File: /usr/bin/cuetag
Tags: patch

Please consider the attached patch to cuetag. It allows me 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.

Thanks,

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-rc4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_NZ, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages cuetools depends on:
ii  id3v2  0.1.12-2
ii  libc6  2.13-24

Versions of packages cuetools recommends:
ii  flac  1.2.1-6

cuetools suggests no packages.

-- no debconf information


-- 
 .''`.   martin f. krafft <madduck@d.o>      Related projects:
: :'  :  proud Debian developer               http://debiansystem.info
`. `'`   http://people.debian.org/~madduck    http://vcs-pkg.org
  `-  Debian - when you have better things to do than fixing systems
--- /usr/bin/cuetag	2011-06-18 23:10:37.000000000 +0200
+++ /tmp/cuetag	2012-01-08 13:13:27.694212038 +0100
@@ -16,6 +16,10 @@
 # for FLAC and Ogg Vorbis files
 vorbis()
 {
+	trackno=$1; shift
+	file="$1"; shift
+	fields="$@"
+
 	# FLAC tagging
 	# --remove-vc-all overwrites existing comments
 	METAFLAC="metaflac --remove-all-tags --import-tags-from=-"
@@ -25,7 +29,7 @@
 	# -a appends to existing comments
 	VORBISCOMMENT="vorbiscomment -w -c -"
 
-	case "$2" in
+	case "$file" in
 	*.[Ff][Ll][Aa][Cc])
 		VORBISTAG=$METAFLAC
 		;;
@@ -37,8 +41,9 @@
 	# space seperated list of recomended stardard field names
 	# see http://www.xiph.org/ogg/vorbis/doc/v-comment.html
 	# TRACKTOTAL is not in the Xiph recomendation, but is in common use
-	
-	fields='TITLE VERSION ALBUM TRACKNUMBER TRACKTOTAL ARTIST PERFORMER COPYRIGHT LICENSE ORGANIZATION DESCRIPTION GENRE DATE LOCATION CONTACT ISRC'
+
+	[ -n "$fields" ] ||
+		fields='TITLE VERSION ALBUM TRACKNUMBER TRACKTOTAL ARTIST PERFORMER COPYRIGHT LICENSE ORGANIZATION DESCRIPTION GENRE DATE LOCATION CONTACT ISRC'
 
 	# fields' corresponding cueprint conversion characters
 	# seperate alternates with a space
@@ -61,16 +66,21 @@
 	ISRC='%i %u'
 
 	(for field in $fields; do
-		value=""
-		for conv in `eval echo \\$$field`; do
-			value=`$CUEPRINT -n $1 -t "$conv\n" "$cue_file"`
-
-			if [ -n "$value" ]; then
-				echo "$field=$value"
-				break
-			fi
-		done
-	done) | $VORBISTAG "$2"
+		case "$field" in
+			(*=*) echo "$field";;
+			(*)
+				value=""
+				for conv in `eval echo \\$$field`; do
+					value=`$CUEPRINT -n $trackno -t "$conv\n" "$cue_file"`
+
+					if [ -n "$value" ]; then
+						echo "$field=$value"
+						break
+					fi
+				done
+				;;
+		esac
+	done) | $VORBISTAG "$file"
 }
 
 id3()
@@ -94,14 +104,19 @@
 	TRACKNUMBER='%n'
 
 	for field in $fields; do
-		value=""
-		for conv in `eval echo \\$$field`; do
-			value=`$CUEPRINT -n $1 -t "$conv\n" "$cue_file"`
-
-			if [ -n "$value" ]; then
-				break
-			fi
-		done
+		case "$field" in
+			*=*) value="${field#*=}";;
+			*)
+				value=""
+				for conv in `eval echo \\$$field`; do
+					value=`$CUEPRINT -n $1 -t "$conv\n" "$cue_file"`
+
+					if [ -n "$value" ]; then
+						break
+					fi
+				done
+				;;
+		esac
 
 		if [ -n "$value" ]; then
 			case $field in
@@ -144,6 +159,15 @@
 	ntrack=`cueprint -d '%N' "$cue_file"`
 	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
 		echo "warning: number of files does not match number of tracks"
 	fi
@@ -151,13 +175,13 @@
 	for file in "$@"; do
 		case $file in
 		*.[Ff][Ll][Aa][Cc])
-			vorbis $trackno "$file"
+			vorbis $trackno "$file" $FIELDS
 			;;
 		*.[Oo][Gg][Gg])
-			vorbis $trackno "$file"
+			vorbis $trackno "$file" $FIELDS
 			;;
 		*.[Mm][Pp]3)
-			id3 $trackno "$file"
+			id3 $trackno "$file" $FIELDS
 			;;
 		*)
 			echo "$file: uknown file type"
@@ -168,3 +192,5 @@
 }
 
 main "$@"
+
+# vim:noet ts=8 sts=8 sw=8

Attachment: digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)


Reply to: