From 0b6ea663eb11d430ad7a31d178ffd2740c79a0e5 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 14:31:56 +1000 Subject: [PATCH 01/10] fix processing of filenames containing spaces --- src/tools/cuetag.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/cuetag.sh b/src/tools/cuetag.sh index 73f4660..26f438b 100755 --- a/src/tools/cuetag.sh +++ b/src/tools/cuetag.sh @@ -81,7 +81,7 @@ vorbis() (for field in $fields; do value="" 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") if [ -n "$value" ]; then echo "$field=$value" @@ -114,7 +114,7 @@ id3() for field in $fields; do value="" 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") if [ -n "$value" ]; then break @@ -159,14 +159,14 @@ main() cue_file=$1 shift - ntrack=$(cueprint -d '%N' $cue_file) + ntrack=$(cueprint -d '%N' "$cue_file") trackno=1 if [ $# -ne $ntrack ]; then echo "warning: number of files does not match number of tracks" fi - for file in $@; do + for file in "$@"; do case $file in *.[Ff][Ll][Aa][Cc]) vorbis $trackno "$file" From 3949cccc457b60f90be828f18edfb7beca313219 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 14:54:32 +1000 Subject: [PATCH 02/10] fix cli parameters for metaflac --- src/tools/cuetag.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cuetag.sh b/src/tools/cuetag.sh index 26f438b..2f26816 100755 --- a/src/tools/cuetag.sh +++ b/src/tools/cuetag.sh @@ -29,7 +29,7 @@ vorbis() { # FLAC tagging # --remove-vc-all overwrites existing comments - METAFLAC="metaflac --remove-vc-all --import-vc-from=-" + METAFLAC="metaflac --remove-all-tags --import-tags-from=-" # Ogg Vorbis tagging # -w overwrites existing comments From 26b7d5295f4ab8c27235972cb925aac728146a38 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 15:05:07 +1000 Subject: [PATCH 03/10] replaces confusing error message at comparing the file suffix (Debian #499445) --- src/lib/cuefile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/cuefile.c b/src/lib/cuefile.c index 66bf475..3975c72 100644 --- a/src/lib/cuefile.c +++ b/src/lib/cuefile.c @@ -18,7 +18,7 @@ Cd *cf_parse(char *name, int *format) if (UNKNOWN == *format) { if (UNKNOWN == (*format = cf_format_from_suffix(name))) { - fprintf(stderr, "%s: unknown format\n", name); + fprintf(stderr, "%s: unknown file suffix\n", name); return NULL; } } @@ -52,7 +52,7 @@ int cf_print(char *name, int *format, Cd *cd) if (UNKNOWN == *format) { if (UNKNOWN == (*format = cf_format_from_suffix(name))) { - fprintf(stderr, "%s: unknown format\n", name); + fprintf(stderr, "%s: unknown file suffix\n", name); return -1; } } From 92980fd399f1aa96fee5d6084b4a5994839eac63 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 15:06:21 +1000 Subject: [PATCH 04/10] fix "Buffer overflow detected" in cueconvert (Debian #576367) --- src/lib/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/time.c b/src/lib/time.c index 9f38f25..d9b8845 100644 --- a/src/lib/time.c +++ b/src/lib/time.c @@ -34,7 +34,7 @@ void time_frame_to_msf(long frame, int *m, int *s, int *f) /* print frame in mm:ss:ff format */ char *time_frame_to_mmssff(long f) { - static char msf[9]; + static char msf[10]; int minutes, seconds, frames; msf_frame_to_msf(f, &minutes, &seconds, &frames); From efd39b282e93e8c077579233ce18ea397a4cdf89 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 15:18:19 +1000 Subject: [PATCH 05/10] X --- src/lib/cd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/cd.c b/src/lib/cd.c index 67b2a23..2d52fa3 100644 --- a/src/lib/cd.c +++ b/src/lib/cd.c @@ -146,7 +146,7 @@ int cd_get_ntrack(Cd *cd) Track *cd_get_track(Cd *cd, int i) { - if (0 < i <= cd->ntrack) { + if (0 < i && i <= cd->ntrack) { return cd->track[i - 1]; } @@ -283,7 +283,7 @@ int track_get_nindex(Track *track) long track_get_index(Track *track, int i) { - if (0 <= i < track->nindex) { + if (0 <= i && i < track->nindex) { return track->index[i]; } From 521b7552de89dff84e2baa84048ff94fe2e2aec6 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 15:21:39 +1000 Subject: [PATCH 06/10] cueprint: use the correct type format string --- src/tools/cueprint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cueprint.c b/src/tools/cueprint.c index 37d2db6..754e13d 100644 --- a/src/tools/cueprint.c +++ b/src/tools/cueprint.c @@ -264,7 +264,7 @@ void print_conv(char *start, int length, Cd *cd, int trackno) printf(conv, value.sval); break; default: - printf("%d: ", strlen(conv)); + printf("%zu: ", strlen(conv)); printf("%s", conv); } From eb9bd4ff6c93affdc613a25625156be67448cfdb Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 15:35:16 +1000 Subject: [PATCH 07/10] Use python-mutagen (`mid3v2`) or id3v2 instead of `mp3info` to tag (Debian: #676478) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids truncating long titles/albums/etc. Author: Felipe Sateler Reviewed-By: Dmitry Smirnov Thanks-To: Rogério Brito. Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=676478 * Look for `mid3v2` first and fallback to `id3v2` according to their availability. * Added error message if neither of them found. --- src/tools/cuetag.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/tools/cuetag.sh b/src/tools/cuetag.sh index 2f26816..922ba69 100755 --- a/src/tools/cuetag.sh +++ b/src/tools/cuetag.sh @@ -93,7 +93,12 @@ vorbis() id3() { - MP3INFO=mp3info + MP3TAG=$(which mid3v2) \ + || MP3TAG=$(which id3v2) + if [ -z "${MP3TAG}" ]; then + echo "error: not found '(m)id3v2'." + exit 1 + fi # space seperated list of ID3 v1.1 tags # see http://id3lib.sourceforge.net/id3/idev1.html @@ -124,25 +129,25 @@ id3() if [ -n "$value" ]; then case $field in TITLE) - $MP3INFO -t "$value" "$2" + $MP3TAG -t "$value" "$2" ;; ALBUM) - $MP3INFO -l "$value" "$2" + $MP3TAG -A "$value" "$2" ;; ARTIST) - $MP3INFO -a "$value" "$2" + $MP3TAG -a "$value" "$2" ;; YEAR) - $MP3INFO -y "$value" "$2" + $MP3TAG -y "$value" "$2" ;; COMMENT) - $MP3INFO -c "$value" "$2" + $MP3TAG -c "$value" "$2" ;; GENRE) - $MP3INFO -g "$value" "$2" + $MP3TAG -g "$value" "$2" ;; TRACKNUMBER) - $MP3INFO -n "$value" "$2" + $MP3TAG -T "$value" "$2" ;; esac fi From 0c7f15be0ba8164dffb6ec7ff34775526f7768e7 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 16:41:19 +1000 Subject: [PATCH 08/10] pad tracknumbers with leading zeroes (Debian #655079) Ensures that tracknumbers are zero-padded to two digits. That seems to be common usage. Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=655079 From: martin f krafft --- src/tools/cuetag.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/cuetag.sh b/src/tools/cuetag.sh index 922ba69..09d7e9d 100755 --- a/src/tools/cuetag.sh +++ b/src/tools/cuetag.sh @@ -64,8 +64,8 @@ vorbis() TITLE='%t' VERSION='' ALBUM='%T' - TRACKNUMBER='%n' - TRACKTOTAL='%N' + TRACKNUMBER='%02n' + TRACKTOTAL='%02N' ARTIST='%c %p' PERFORMER='%p' COPYRIGHT='' From 6ef317d871fe74d0c2d3058bad16bf872381b865 Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 17:10:24 +1000 Subject: [PATCH 09/10] ability to specify field list (for Ogg/Flac), as well as specify field contents (Debian: #655078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Author: Dmitry Smirnov --- src/tools/cuetag.sh | 72 ++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/src/tools/cuetag.sh b/src/tools/cuetag.sh index 09d7e9d..19229e4 100755 --- a/src/tools/cuetag.sh +++ b/src/tools/cuetag.sh @@ -27,6 +27,10 @@ usage() # 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=-" @@ -40,7 +44,7 @@ vorbis() # TODO: this also outputs to stdout TXTFILE="tee" - case "$2" in + case "$file" in *.[Ff][Ll][Aa][Cc]) VORBISTAG=$METAFLAC ;; @@ -55,8 +59,9 @@ vorbis() # 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 @@ -79,16 +84,21 @@ vorbis() 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() @@ -117,14 +127,19 @@ id3() 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 @@ -167,6 +182,15 @@ main() 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 @@ -174,13 +198,13 @@ main() 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 ;; *.[Tt][Xx][Tt]) vorbis $trackno "$file" From e74f095fe184fe11c1fc8e07181a0a21146738ce Mon Sep 17 00:00:00 2001 From: Dmitry Smirnov Date: Fri, 5 Jul 2013 17:50:02 +1000 Subject: [PATCH 10/10] fix handling of cuesheets with 99 tracks (Debian #658818) There's an off-by-one error in cd.c which causes cueprint to wrongly reject cuesheets with 99 tracks. Its actual limit is 98 tracks, and yet as the source code notes, the Red Book audio standard permits 99 tracks per disc (and 99 indices per track). . When I looked into this, I saw that: . 1) not only will the same error occur with index numbers, but 2) the wrong preprocessor symbol is being expanded when checking the index number Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=658818 From: Branden Robinson Author: Dmitry Smirnov --- src/lib/cd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/cd.c b/src/lib/cd.c index 2d52fa3..516af09 100644 --- a/src/lib/cd.c +++ b/src/lib/cd.c @@ -126,7 +126,7 @@ Cdtext *cd_get_cdtext(Cd *cd) Track *cd_add_track(Cd *cd) { - if (MAXTRACK - 1 > cd->ntrack) { + if (MAXTRACK > cd->ntrack) { cd->ntrack++; } else { fprintf(stderr, "too many tracks\n"); @@ -266,7 +266,7 @@ Cdtext *track_get_cdtext(Track *track) void track_add_index(Track *track, long index) { - if (MAXTRACK - 1 > track->nindex) { + if (MAXINDEX > track->nindex) { track->nindex++; } else { fprintf(stderr, "too many indexes\n");