Bläddra i källkod

Merge pull request #7 from onlyjob/my-fixes

Fixes and improvements from Debian
master
Svend Sorensen 11 år sedan
förälder
incheckning
ac28bb8cd8
5 ändrade filer med 74 tillägg och 45 borttagningar
  1. +4
    -4
      src/lib/cd.c
  2. +2
    -2
      src/lib/cuefile.c
  3. +1
    -1
      src/lib/time.c
  4. +1
    -1
      src/tools/cueprint.c
  5. +66
    -37
      src/tools/cuetag.sh

+ 4
- 4
src/lib/cd.c Visa fil

@@ -126,7 +126,7 @@ Cdtext *cd_get_cdtext(Cd *cd)


Track *cd_add_track(Cd *cd) Track *cd_add_track(Cd *cd)
{ {
if (MAXTRACK - 1 > cd->ntrack) {
if (MAXTRACK > cd->ntrack) {
cd->ntrack++; cd->ntrack++;
} else { } else {
fprintf(stderr, "too many tracks\n"); fprintf(stderr, "too many tracks\n");
@@ -146,7 +146,7 @@ int cd_get_ntrack(Cd *cd)


Track *cd_get_track(Cd *cd, int i) Track *cd_get_track(Cd *cd, int i)
{ {
if (0 < i <= cd->ntrack) {
if (0 < i && i <= cd->ntrack) {
return cd->track[i - 1]; return cd->track[i - 1];
} }


@@ -266,7 +266,7 @@ Cdtext *track_get_cdtext(Track *track)


void track_add_index(Track *track, long index) void track_add_index(Track *track, long index)
{ {
if (MAXTRACK - 1 > track->nindex) {
if (MAXINDEX > track->nindex) {
track->nindex++; track->nindex++;
} else { } else {
fprintf(stderr, "too many indexes\n"); fprintf(stderr, "too many indexes\n");
@@ -283,7 +283,7 @@ int track_get_nindex(Track *track)


long track_get_index(Track *track, int i) long track_get_index(Track *track, int i)
{ {
if (0 <= i < track->nindex) {
if (0 <= i && i < track->nindex) {
return track->index[i]; return track->index[i];
} }




+ 2
- 2
src/lib/cuefile.c Visa fil

@@ -18,7 +18,7 @@ Cd *cf_parse(char *name, int *format)


if (UNKNOWN == *format) { if (UNKNOWN == *format) {
if (UNKNOWN == (*format = cf_format_from_suffix(name))) { 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; return NULL;
} }
} }
@@ -52,7 +52,7 @@ int cf_print(char *name, int *format, Cd *cd)


if (UNKNOWN == *format) { if (UNKNOWN == *format) {
if (UNKNOWN == (*format = cf_format_from_suffix(name))) { 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; return -1;
} }
} }


+ 1
- 1
src/lib/time.c Visa fil

@@ -34,7 +34,7 @@ void time_frame_to_msf(long frame, int *m, int *s, int *f)
/* print frame in mm:ss:ff format */ /* print frame in mm:ss:ff format */
char *time_frame_to_mmssff(long f) char *time_frame_to_mmssff(long f)
{ {
static char msf[9];
static char msf[10];
int minutes, seconds, frames; int minutes, seconds, frames;


msf_frame_to_msf(f, &minutes, &seconds, &frames); msf_frame_to_msf(f, &minutes, &seconds, &frames);


+ 1
- 1
src/tools/cueprint.c Visa fil

@@ -264,7 +264,7 @@ void print_conv(char *start, int length, Cd *cd, int trackno)
printf(conv, value.sval); printf(conv, value.sval);
break; break;
default: default:
printf("%d: ", strlen(conv));
printf("%zu: ", strlen(conv));
printf("%s", conv); printf("%s", conv);
} }




+ 66
- 37
src/tools/cuetag.sh Visa fil

@@ -27,9 +27,13 @@ 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-vc-all --import-vc-from=-"
METAFLAC="metaflac --remove-all-tags --import-tags-from=-"


# Ogg Vorbis tagging # Ogg Vorbis tagging
# -w overwrites existing comments # -w overwrites existing comments
@@ -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
;; ;;
@@ -55,8 +59,9 @@ vorbis()
# space seperated list of recomended stardard field names # space seperated list of recomended stardard field names
# 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
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 # fields' corresponding cueprint conversion characters
# seperate alternates with a space # seperate alternates with a space
@@ -64,8 +69,8 @@ vorbis()
TITLE='%t' TITLE='%t'
VERSION='' VERSION=''
ALBUM='%T' ALBUM='%T'
TRACKNUMBER='%n'
TRACKTOTAL='%N'
TRACKNUMBER='%02n'
TRACKTOTAL='%02N'
ARTIST='%c %p' ARTIST='%c %p'
PERFORMER='%p' PERFORMER='%p'
COPYRIGHT='' COPYRIGHT=''
@@ -79,21 +84,31 @@ vorbis()
ISRC='%i %u' ISRC='%i %u'


(for field in $fields; do (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() 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 # space seperated list of ID3 v1.1 tags
# see http://id3lib.sourceforge.net/id3/idev1.html # see http://id3lib.sourceforge.net/id3/idev1.html
@@ -112,37 +127,42 @@ id3()
TRACKNUMBER='%n' TRACKNUMBER='%n'


for field in $fields; do 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 if [ -n "$value" ]; then
case $field in case $field in
TITLE) TITLE)
$MP3INFO -t "$value" "$2"
$MP3TAG -t "$value" "$2"
;; ;;
ALBUM) ALBUM)
$MP3INFO -l "$value" "$2"
$MP3TAG -A "$value" "$2"
;; ;;
ARTIST) ARTIST)
$MP3INFO -a "$value" "$2"
$MP3TAG -a "$value" "$2"
;; ;;
YEAR) YEAR)
$MP3INFO -y "$value" "$2"
$MP3TAG -y "$value" "$2"
;; ;;
COMMENT) COMMENT)
$MP3INFO -c "$value" "$2"
$MP3TAG -c "$value" "$2"
;; ;;
GENRE) GENRE)
$MP3INFO -g "$value" "$2"
$MP3TAG -g "$value" "$2"
;; ;;
TRACKNUMBER) TRACKNUMBER)
$MP3INFO -n "$value" "$2"
$MP3TAG -T "$value" "$2"
;; ;;
esac esac
fi fi
@@ -159,23 +179,32 @@ main()
cue_file=$1 cue_file=$1
shift shift


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


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"


Laddar…
Avbryt
Spara