Re: [Debian]: MPEG3-Encode
> Da ich zu faul bin mir das Zeug, das Du da erwaehnst, selbst zu basteln und da
> ich bei einer spontanen(zugegebenerweise oberflächlichen) Suche auf debian.org
> und fokus.gmd.de nichts gefunden habe, wäre ich, und vermutlich auch andere,
> Dir dankbar wenn Du mal sagst, wo das alles zu finden ist oder es mir mailst.
id3 und cd-discid sind programme aus potato (unstable): source saugen und
selbst kompilieren. cdparanoia und bladeenc gibts im netz (siehe freshmeat),
und die anderen sind anbei.
andreas
#!/bin/sh
PATH=/home/mp3/bin:/bin:/usr/bin
set -e
test -f trackinfo || cd-discid /dev/cdrom > trackinfo
TRACKINFOPLUS=`sed 's/ /+/g' < trackinfo`
wget -O cdinfo "http://cddb.cddb.com/~cddb/cddb.cgi?cmd=cddb+query+$TRACKINFOPLUS\&hello=aj+dungeon.inka.de+getinfo+0.1\&proto=4"
CDDBGENRE=`cut -f2 -d' ' < cdinfo`
DISCID=`cut -f3 -d' ' < cdinfo`
wget -O cddbdata "http://cddb.cddb.com/~cddb/cddb.cgi?cmd=cddb+read+$CDDBGENRE+$DISCID\&hello=aj+dungeon.inka.de+getinfo+0.1\&proto=4"
/* mv - an mp3 ID tag reader and move command
* Copyright (c) 1998,1999 Andreas Jellinghaus <aj@pandur.org>
*
* based on:
* id3 - an ID3 tag editor
* Copyright (c) 1998,1999 Robert Woodcock <rcw@debian.org>
*
* This code is hereby licensed for public consumption under either the
* GNU GPL v2 or greater, or Larry Wall's Artistic license - your choice.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
struct id3 {
char tag[3];
char title[30];
char artist[30];
char album[30];
char year[4];
char comment[30];
unsigned char genre;
};
char *mkfilename(struct id3 id3info, char *format)
{
int j, max;
char *buffer, *fmt, *dst, *src, mode;
buffer = malloc(1024);
bzero(buffer, 1024);
fmt = format;
dst = buffer;
while (*fmt) {
if (*fmt != '%') {
*dst = *fmt;
fmt++;
dst++;
continue;
}
fmt++;
switch (*fmt) {
case ' ':
mode = ' ';
fmt++;
break;
case '_':
mode = '_';
fmt++;
break;
case '-':
mode = '-';
fmt++;
break;
default:
mode = 0;
break;
}
if (*fmt == '%') {
*dst = '%';
fmt++;
dst++;
continue;
}
if (*fmt == 'A') {
j = 0;
max = 29;
src = id3info.album;
} else if (*fmt == 'N') {
j = 0;
max = 29;
src = id3info.artist;
} else if (*fmt == 'T') {
j = 0;
max = 29;
src = id3info.title;
} else if (*fmt == 'Y') {
j = 0;
max = 3;
src = id3info.year;
} else if (*fmt == 'C') {
j = 0;
max = 29;
src = id3info.comment;
} else {
printf("unsupported format char \"%c\". Aborting.\n",
*fmt);
exit(1);
}
while (j <= max && src[j] == ' ')
j++;
while (j <= max && src[max] == ' ')
max--;
while (j <= max) {
if (!src[j])
break;
if (src[j] == ' ' ||
src[j] == '-' ||
src[j] == '_') {
*dst = (mode == 0 ?
src[j] : mode);
} else
*dst = src[j];
dst++;
j++;
}
fmt++;
continue;
}
return buffer;
}
int readid3(struct id3 *id3info, char *filename)
{
FILE *fp;
bzero(id3info, sizeof(struct id3));
fp = fopen(filename, "r");
if (fp == NULL) { /* file didn't open */
fprintf(stderr, "fopen %s: %s",
filename, strerror(errno));
return 1;
}
if (fseek(fp, -128, SEEK_END) < 0) {
fprintf(stderr, "fseek %s: %s",
filename, strerror(errno));
fclose(fp);
return 1;
}
if (fread(id3info, 128, 1, fp) < 0) {
fprintf(stderr, "fread %s: %s",
filename, strerror(errno));
fclose(fp);
return 1;
}
fclose(fp);
return 0;
}
int main(int argc, char *argv[])
{
int i, j;
struct id3 id3info;
char *file, *dir, command[1024];
if (argc < 3) {
printf("mv3 version 0.01 (C) aj@dungeon.inka.de\n");
printf("usage: mv3 \"format\" file1 [file2...]\n");
printf("format: %%%% -> %%, %%A -> Album, %%T -> Title\n");
printf(" %%N -> Artist, %%C -> Comment, %%Y -> Year\n");
printf(" anything else: the char itself\n");
printf("special: %%_A : like %%A \n");
printf("but replace minus, space, underscore with _\n");
printf("similiar with %%-A, %% A, %%_T, %%-T, ...\n");
exit(1);
}
for (i = 2; i < argc; i++) {
if (readid3(&id3info, argv[i]) != 0)
continue;
/* This simple detection code has a 1 in 16777216
* chance of misrecognizing or deleting the last 128
* bytes of your mp3 if it isn't tagged. ID3 ain't
* world peace, live with it.
*/
if (strncmp(id3info.tag, "TAG", 3))
continue;
file = mkfilename(id3info, argv[1]);
dir = file;
j = 0;
while (file[j])
j++;
while (j && file[j] != '/')
j--;
if (file[j] == '/') {
file[j] = 0;
file += j + 1;
snprintf(command, 1024, "mkdir -p \"%s\"", dir);
system(command);
snprintf(command, 1024, "mv \"%s\" \"%s/%s\"\n",
argv[i], dir, file);
system(command);
free(dir);
} else {
snprintf(command, 1024, "mv \"%s\" \"%s/%s\"\n",
argv[i], dir, file);
system(command);
free(dir);
}
}
return 0;
}
#!/bin/sh
PATH=/home/mp3/bin:/bin:/usr/bin
set -e
TRACKS=`cut -f2 -d' ' < trackinfo`
DARTISTALBUM="`grep ^DTITLE= cddbdata | cut -f2 -d= | sed 's- / -~-g'`"
DARTIST=`echo $DARTISTALBUM | cut -f1 -d~`
DALBUM=`echo $DARTISTALBUM | cut -f2 -d~ | tr -d \[:cntrl:\]`
GENRE=`cut -f2 -d' ' < cdinfo`
let i=0 ||true
while let "i<$TRACKS"
do
TRACKNAME=`grep ^TTITLE$i= cddbdata | cut -f2 -d= | tr -d \[:cntrl:\]`
let i=i+1
FILE=`printf track%02d.cdda.mp3 $i`
#id3 -A "$DALBUM" -a "$DARTIST" -t "$TRACKNAME" -g $GENRE $FILE
id3 -A "$DALBUM" -a "$DARTIST" -t "$TRACKNAME" $FILE
done
Reply to: