Commit 388a47ab15a0d89ce6bfd0025acdd823c9cedc4a

Authored by Georg Hopp
1 parent dab92246

Initial repository layout

No preview for this file type
  1 +diff -Naur CDDB_get-2.23/CDDB_get.pm CDDB_get-2.23p1/CDDB_get.pm
  2 +--- CDDB_get-2.23/CDDB_get.pm 2003-09-07 15:49:27.000000000 +0000
  3 ++++ CDDB_get-2.23p1/CDDB_get.pm 2004-06-30 08:37:28.000000000 +0000
  4 +@@ -261,6 +261,7 @@
  5 +
  6 + my $input = $config->{input};
  7 + my $multi = $config->{multi};
  8 ++ my $entry = $config->{entry} if (defined($config->{entry}));
  9 + $input = 0 if $multi;
  10 +
  11 + print STDERR Dumper($config) if $debug;
  12 +@@ -426,7 +427,14 @@
  13 + }
  14 + }
  15 + } else {
  16 +- push @to_get,@list;
  17 ++ unless(defined($entry)) {
  18 ++ push @to_get,@list;
  19 ++ }
  20 ++ else {
  21 ++ if($entry-1 >= 0 && $entry-1 <= $#list) {
  22 ++ push @to_get,$list[$entry-1];
  23 ++ }
  24 ++ }
  25 + }
  26 +
  27 + my $i=0;
  28 +diff -Naur CDDB_get-2.23/cddb.pl CDDB_get-2.23p1/cddb.pl
  29 +--- CDDB_get-2.23/cddb.pl 2003-08-16 19:01:49.000000000 +0000
  30 ++++ CDDB_get-2.23p1/cddb.pl 2004-06-30 08:33:03.000000000 +0000
  31 +@@ -27,12 +27,13 @@
  32 + use strict;
  33 +
  34 + my %option = ();
  35 +-getopts("oghdtsiSfDlOFc:", \%option);
  36 ++getopts("oghdtsiSfDlOFe:c:", \%option);
  37 +
  38 + if($option{h}) {
  39 + print "$0: gets CDDB info of a CD\n";
  40 + print " no argument - gets CDDB info of CD in your drive\n";
  41 + print " -c device (other than default device)\n";
  42 ++ print " -e which cddb-entry to use\n";
  43 + print " -o offline mode - just stores CD info\n";
  44 + print " -d output in xmcd format\n";
  45 + print " -s save in xmcd format\n";
  46 +@@ -81,11 +82,19 @@
  47 + $config{CD_DEVICE}=$option{c} if $option{c};
  48 +
  49 + # user interaction welcome?
  50 +-
  51 +-$config{input}=1; # 1: ask user if more than one possibility
  52 +- # 0: no user interaction
  53 +-$config{multi}=0; # 1: do not ask user and get all of them
  54 +- # 0: just the first one
  55 ++if($option{e}) {
  56 ++ $config{entry}=$option{e};
  57 ++ $config{input}=0; # 1: ask user if more than one possibility
  58 ++ # 0: no user interaction
  59 ++ $config{multi}=0; # 1: do not ask user and get all of them
  60 ++ # 0: just the first one
  61 ++}
  62 ++else {
  63 ++ $config{input}=1; # 1: ask user if more than one possibility
  64 ++ # 0: no user interaction
  65 ++ $config{multi}=0; # 1: do not ask user and get all of them
  66 ++ # 0: just the first one
  67 ++}
  68 +
  69 + my %db;
  70 +
... ...
No preview for this file type
  1 +diff -Naur CDDB_get-2.27/CDDB_get.pm CDDB_get-2.27.patched/CDDB_get.pm
  2 +--- CDDB_get-2.27/CDDB_get.pm 2006-01-01 20:52:54.000000000 +0100
  3 ++++ CDDB_get-2.27.patched/CDDB_get.pm 2006-05-27 09:54:30.733131044 +0200
  4 +@@ -262,6 +262,7 @@
  5 +
  6 + my $input = $config->{input};
  7 + my $multi = $config->{multi};
  8 ++ my $entry = $config->{entry} if (defined($config->{entry}));
  9 + $input = 0 if $multi;
  10 +
  11 + print STDERR Dumper($config) if $debug;
  12 +@@ -441,7 +442,14 @@
  13 + }
  14 + }
  15 + } else {
  16 +- push @to_get,@list;
  17 ++ unless(defined($entry)) {
  18 ++ push @to_get,@list;
  19 ++ }
  20 ++ else {
  21 ++ if($entry-1 >= 0 && $entry-1 <= $#list) {
  22 ++ push @to_get,$list[$entry-1];
  23 ++ }
  24 ++ }
  25 + }
  26 +
  27 + my $i=0;
  28 +diff -Naur CDDB_get-2.27/cddb.pl CDDB_get-2.27.patched/cddb.pl
  29 +--- CDDB_get-2.27/cddb.pl 2005-10-06 08:00:59.000000000 +0200
  30 ++++ CDDB_get-2.27.patched/cddb.pl 2006-05-27 09:56:17.798156565 +0200
  31 +@@ -27,12 +27,13 @@
  32 + use strict;
  33 +
  34 + my %option = ();
  35 +-getopts("oghdtsi:SfDlOFc:H:CIRGP", \%option);
  36 ++getopts("oghdtsi:SfDlOFe:c:H:CIRGP", \%option);
  37 +
  38 + if($option{h}) {
  39 + print "$0: gets CDDB info of a CD\n";
  40 + print " no argument - gets CDDB info of CD in your drive\n";
  41 + print " -c device (other than default device)\n";
  42 ++ print " -e which cddb-entry to use\n";
  43 + print " -o offline mode - just stores CD info\n";
  44 + print " -d output in xmcd format\n";
  45 + print " -s save in xmcd format\n";
  46 +@@ -110,11 +111,19 @@
  47 + $config{CD_DEVICE}=$option{c} if $option{c};
  48 +
  49 + # user interaction welcome?
  50 +-
  51 +-$config{input}=1; # 1: ask user if more than one possibility
  52 +- # 0: no user interaction
  53 +-$config{multi}=0; # 1: do not ask user and get all of them
  54 +- # 0: just the first one
  55 ++if($option{e}) {
  56 ++ $config{entry}=$option{e};
  57 ++ $config{input}=0; # 1: ask user if more than one possibility
  58 ++ # 0: no user interaction
  59 ++ $config{multi}=0; # 1: do not ask user and get all of them
  60 ++ # 0: just the first one
  61 ++}
  62 ++else {
  63 ++ $config{input}=1; # 1: ask user if more than one possibility
  64 ++ # 0: no user interaction
  65 ++ $config{multi}=0; # 1: do not ask user and get all of them
  66 ++ # 0: just the first one
  67 ++}
  68 +
  69 + $config{input}=0 if($option{I});
  70 +
... ...
  1 +#!/usr/bin/perl -I.
  2 +#
  3 +# CDDB - Read the CDDB entry for an audio CD in your drive
  4 +#
  5 +# This module/script gets the CDDB info for an audio cd. You need
  6 +# LINUX, a cdrom drive and an active internet connection in order
  7 +# to do that.
  8 +#
  9 +# (c) 2004 Armin Obersteiner <armin@xos.net>
  10 +#
  11 +# LICENSE
  12 +#
  13 +# This library is released under the same conditions as Perl, that
  14 +# is, either of the following:
  15 +#
  16 +# a) the GNU General Public License Version 2 as published by the
  17 +# Free Software Foundation,
  18 +#
  19 +# b) the Artistic License.
  20 +#
  21 +
  22 +#use CDDB_get qw( get_cddb get_discids );
  23 +
  24 +use Data::Dumper;
  25 +use Getopt::Std;
  26 +
  27 +use strict;
  28 +
  29 +my %option = ();
  30 +getopts("oghdtsi:SfDlOFe:c:H:CIRGP", \%option);
  31 +
  32 +if($option{h}) {
  33 + print "$0: gets CDDB info of a CD\n";
  34 + print " no argument - gets CDDB info of CD in your drive\n";
  35 + print " -c device (other than default device)\n";
  36 + print " -e which cddb-entry to use\n";
  37 + print " -o offline mode - just stores CD info\n";
  38 + print " -d output in xmcd format\n";
  39 + print " -s save in xmcd format\n";
  40 + print " -i db. one of: mysql, pg, oracle, sqlite\n";
  41 + print " -O overwrite file or db\n";
  42 + print " -t output toc\n";
  43 + print " -l output lame command\n";
  44 + print " -f http mode (e.g. through firewalls)\n";
  45 + print " -F some stateful firewalls/http proxies need additional newlines\n";
  46 + print " -g get CDDB info for stored CDs\n";
  47 + print " -I non interactive mode\n";
  48 + print " -H CDDB hostname\n";
  49 + print " -C use local cache\n";
  50 + print " -R readonly cache\n";
  51 + print " -G cache has not the diskid as filenames (much slower)\n";
  52 + print " -P cache path (default: /tmp/xmcd)\n";
  53 + print " -D put CDDB_get in debug mode\n";
  54 + exit;
  55 +}
  56 +
  57 +my %config;
  58 +
  59 +my $diskid;
  60 +my $total;
  61 +my $toc;
  62 +my $savedir="/tmp/cddb";
  63 +my $xmcddir="/tmp/xmcd";
  64 +
  65 +if($option{C}) {
  66 + # use CDDB_cache qw( get_cddb get_discids );
  67 + require CDDB_cache;
  68 + CDDB_cache->import( qw( get_cddb get_discids ) );
  69 +
  70 + $CDDB_cache::debug=1 if($option{D});
  71 + $CDDB_cache::readonly=1 if($option{R});
  72 + $CDDB_cache::grep=1 if($option{G});
  73 +
  74 + $CDDB_cache::dir="/tmp/xmcd"; # default
  75 + # $CDDB_cache::dir="/opt/kde2/share/apps/kscd/cddb";
  76 + $CDDB_cache::dir=$option{P} if($option{P});
  77 +
  78 +} else {
  79 + # use CDDB_get qw( get_cddb get_discids );
  80 + require CDDB_get;
  81 + CDDB_get->import( qw( get_cddb get_discids ) );
  82 +}
  83 +
  84 +$CDDB_get::debug=1 if($option{D});
  85 +
  86 +# following variables just need to be declared if different from defaults
  87 +# defaults are listed below (cdrom default is os specific)
  88 +
  89 +# $config{CDDB_HOST}="freedb.freedb.org"; # set cddb host
  90 +if($option{H}) {
  91 + $config{CDDB_HOST}=$option{H};
  92 +}
  93 +# $config{CDDB_PORT}=8880; # set cddb port
  94 +# $config{CDDB_MODE}="cddb"; # set cddb mode: cddb or http, this is switched with -f
  95 +# $config{CD_DEVICE}="/dev/cdrom"; # set cd device
  96 +
  97 +# $config{HELLO_ID} ="root nowhere.com fastrip 0.77"; # hello string: username hostname clientname version
  98 +# $config{PROTO_VERSION} = 5; # cddb protokol version
  99 +
  100 +
  101 +# get proxy settings for cddb mode
  102 +
  103 +$config{HTTP_PROXY}=$ENV{http_proxy} if $ENV{http_proxy}; # maybe wanna use a proxy ?
  104 +
  105 +$config{CDDB_MODE}="http" if($option{f});
  106 +if($option{F}) {
  107 + $config{CDDB_MODE}="http";
  108 + $config{FW}=1;
  109 +}
  110 +
  111 +$config{CD_DEVICE}=$option{c} if $option{c};
  112 +
  113 +# user interaction welcome?
  114 +if($option{e}) {
  115 + $config{entry}=$option{e};
  116 + $config{input}=0; # 1: ask user if more than one possibility
  117 + # 0: no user interaction
  118 + $config{multi}=0; # 1: do not ask user and get all of them
  119 + # 0: just the first one
  120 +}
  121 +else {
  122 + $config{input}=1; # 1: ask user if more than one possibility
  123 + # 0: no user interaction
  124 + $config{multi}=0; # 1: do not ask user and get all of them
  125 + # 0: just the first one
  126 +}
  127 +
  128 +$config{input}=0 if($option{I});
  129 +
  130 +my %db;
  131 +
  132 +if($option{i}) {
  133 + require DBI;
  134 +
  135 + $db{table_cds} = "cds";
  136 + $db{table_tracks} = "tracks";
  137 +
  138 + # not needed for sqlite
  139 + $db{host} = "localhost";
  140 + $db{port} = "3306";
  141 +
  142 + # not needed for oracle/sqlite
  143 + $db{name} = "mp3-test";
  144 +
  145 + # just for oracle
  146 + $db{sid} = "xxx";
  147 + $db{home} = "xxx";
  148 +
  149 + # just for sqlite
  150 + $db{file} = "xxx";
  151 +
  152 + # not needed for sqlite
  153 + $db{user} = "root";
  154 + $db{passwd} = "xxx";
  155 +
  156 +
  157 + if($option{i} eq "mysql") {
  158 + $db{connect} = sub { "dbi:mysql:database=$db{name};host=$db{host};port=$db{port}", $db{user}, $db{passwd} };
  159 + } elsif($option{i} eq "pg") {
  160 + $db{connect} = sub { "dbi:Pg:dbname=$db{dbname};host=$db{host};port=$db{port}", $db{user}, $db{passwd} };
  161 + } elsif($option{i} eq "oracle") {
  162 + $db{connect} = sub { "dbi:Oracle:host=$db{host};sid=$db{sid};port=$db{port}", $db{user}, $db{passwd} };
  163 + $ENV{ORACLE_HOME} = $db{home};
  164 + } elsif($option{i} eq "sqlite") {
  165 + $db{connect} = sub { "dbi:SQLite:dbname=$db{file}","","" };
  166 + } else {
  167 + die "unkown database: $option{i}";
  168 + }
  169 +}
  170 +
  171 +if($option{o}) {
  172 + my $ids=get_discids($config{CD_DEVICE});
  173 +
  174 + unless(-e $savedir) {
  175 + mkdir $savedir,0755 or die "cannot create $savedir";
  176 + }
  177 +
  178 + open OUT,">$savedir/$ids->[0]\_$$" or die "cannot open outfile";
  179 + print OUT Data::Dumper->Dump($ids,["diskid","total","toc"]);
  180 + close OUT;
  181 +
  182 + print STDERR "saved in: $savedir/$ids->[0]\_$$\n";
  183 + exit;
  184 +}
  185 +
  186 +if($option{g}) {
  187 + print STDERR "retrieving stored cds ...\n";
  188 +
  189 + opendir(DIR, $savedir) or die "cannot opendir $savedir";
  190 + while (defined(my $file = readdir(DIR))) {
  191 + next if($file =~ /^\./);
  192 + print "\n";
  193 +
  194 + my $in=`/bin/cat $savedir/$file`;
  195 + my $exit = $? >> 8;
  196 +
  197 + if($exit>0) {
  198 + die "error reading file";
  199 + }
  200 +
  201 + unless($in=~ m/^\$diskid\s+=\s+('\d+'|\d+);\s+ # $diskid
  202 + \$total\s+=\s+('\d+'|\d+);\s+ # $total
  203 + \$toc\s+=\s+\[\s+ # $toc
  204 + (\{\s+
  205 + ('(frame|frames|min|sec|data)'\s+=\>\s+('\d+'|\d+)(,|)\s+){5}
  206 + \}(,|)\s+)+
  207 + \];\s+$/xs) {
  208 + print "not a save file: $savedir/$file\n";
  209 + next;
  210 + }
  211 +
  212 + eval $in;
  213 +
  214 + if($@) {
  215 + print "not a save file (eval error): $savedir/$file\n";
  216 + next;
  217 + }
  218 +
  219 + my %cd=get_cddb(\%config,[$diskid,$total,$toc]);
  220 +
  221 + unless(defined $cd{title}) {
  222 + print "no cddb entry found: $savedir/$file\n";
  223 + }
  224 +
  225 + unlink "$savedir/$file";
  226 +
  227 + next unless defined $cd{title};
  228 +
  229 + if($option{d} || $option{s}) {
  230 + print_xmcd(\%cd,$option{s});
  231 + } elsif($option{i}) {
  232 + insert_db(\%cd,\%db);
  233 + } elsif($option{l}) {
  234 + print_lame(\%cd);
  235 + } else {
  236 + print_cd(\%cd);
  237 + }
  238 + }
  239 + closedir(DIR);
  240 + exit;
  241 +}
  242 +
  243 +# get it on
  244 +
  245 +unless($config{multi}) {
  246 + my %cd;
  247 +
  248 + # for those who don't like 'die' in modules ;-)
  249 + eval {
  250 + %cd = get_cddb(\%config);
  251 + };
  252 + if ($@) {
  253 + print "fatal error: $!\n";
  254 + exit;
  255 + }
  256 +
  257 + print Dumper(\%cd) if $option{D};
  258 +
  259 + unless(defined $cd{title}) {
  260 + die "no cddb entry found";
  261 + }
  262 +
  263 + # do somthing with the results
  264 +
  265 + if($option{d} || $option{s}) {
  266 + print_xmcd(\%cd,$option{s});
  267 + } elsif($option{i}) {
  268 + insert_db(\%cd,\%db);
  269 + } elsif($option{l}) {
  270 + print_lame(\%cd);
  271 + } else {
  272 + print_cd(\%cd);
  273 + }
  274 +} else {
  275 + my @cd;
  276 +
  277 + # for those who don't like 'die' in modules ;-)
  278 + eval {
  279 + @cd=get_cddb(\%config);
  280 + };
  281 + if ($@) {
  282 + print "fatal error: $!\n";
  283 + exit;
  284 + }
  285 +
  286 + print Dumper(\@cd) if $option{D};
  287 +
  288 + for my $c (@cd) {
  289 + unless(defined $c->{title}) {
  290 + die "no cddb entry found";
  291 + }
  292 +
  293 + # do somthing with the results
  294 +
  295 + if($option{d} || $option{s}) {
  296 + print_xmcd($c,$option{s});
  297 + } elsif($option{i}) {
  298 + insert_db($c,\%db);
  299 + } elsif($option{l}) {
  300 + print_lame($c);
  301 + print "\n";
  302 + } else {
  303 + print_cd($c);
  304 + print "\n";
  305 + }
  306 + }
  307 +}
  308 +
  309 +exit;
  310 +
  311 +
  312 +# subroutines
  313 +
  314 +sub print_cd {
  315 + my $cd=shift;
  316 +
  317 + print "artist: $cd->{artist}\n";
  318 + print "title: $cd->{title}\n";
  319 + print "category: $cd->{cat}\n";
  320 + print "genre: $cd->{genre}\n" if($cd->{genre});
  321 + print "year: $cd->{year}\n" if($cd->{year});
  322 + print "cddbid: $cd->{id}\n";
  323 + print "trackno: $cd->{tno}\n";
  324 +
  325 + my $n=1;
  326 + foreach my $i ( @{$cd->{track}} ) {
  327 + if($option{t}) {
  328 + my $from=$cd->{frames}[$n-1];
  329 + my $to=$cd->{frames}[$n]-1;
  330 + my $dur=$to-$from;
  331 + my $min=int($dur/75/60);
  332 + my $sec=int($dur/75)-$min*60;
  333 + my $frm=($dur-$sec*75-$min*75*60)*100/75;
  334 + my $out=sprintf "track %2d: %8d - %8d [%2d:%.2d.%.2d]: $i\n",$n,$from,$to,$min,$sec,$frm;
  335 + print "$out";
  336 + } else {
  337 + print "track $n: $i\n";
  338 + }
  339 + $n++;
  340 + }
  341 +}
  342 +
  343 +sub print_xmcd {
  344 + my $cd=shift;
  345 + my $save=shift;
  346 +
  347 + *OUT=*STDOUT;
  348 +
  349 + if($save) {
  350 + unless(-e $xmcddir) {
  351 + mkdir $xmcddir,0755 or die "cannot create $savedir";
  352 + }
  353 +
  354 + unless($option{O}) {
  355 + if(-e "$xmcddir/$cd->{id}") {
  356 + print "XMCD file exists\n";
  357 + exit;
  358 + }
  359 + }
  360 +
  361 + open XMCD,">$xmcddir/$cd->{id}" or die "cannot open outfile";
  362 + *OUT=*XMCD;
  363 + }
  364 +
  365 + for(@{$cd->{raw}}) {
  366 + print OUT "$_";
  367 + }
  368 +
  369 + if($save) {
  370 + print STDERR "saved in: $xmcddir/$cd->{id}\n";
  371 + close OUT;
  372 + }
  373 +}
  374 +
  375 +sub insert_db {
  376 + my $cd=shift;
  377 + my $db=shift;
  378 +
  379 + my ($artist, $title, $category, $cddbid, $trackno) =
  380 + ($cd->{artist}, $cd->{title}, $cd->{cat}, $cd->{id}, $cd->{tno});
  381 +
  382 + my $sql = "SELECT cddbid FROM $db->{table_cds} WHERE CDDBID = \'$cddbid\'";
  383 + my $dbh = DBI->connect($db->{connect}->()) or die "cannot connect to db: $DBI::errstr";
  384 + my $sth = $dbh->prepare($sql);
  385 + my $r = $sth->execute or die "cannot check for cd: $DBI::errstr";
  386 + if ($r == 1) {
  387 + print "cd already in db\n";
  388 + if($option{O}) {
  389 + my $sql = "DELETE FROM $db->{table_cds} WHERE CDDBID = \'$cddbid\'";
  390 + my $sth = $dbh->prepare($sql);
  391 + my $r = $sth->execute or die "cannot delete from $db->{table_cds}: $DBI::errstr";
  392 + $sql = "DELETE FROM $db->{table_tracks} WHERE CDDBID = \'$cddbid\'";
  393 + $sth = $dbh->prepare($sql);
  394 + $r = $sth->execute or die "cannot delete from $db->{table_tracks}: $DBI::errstr";
  395 + } else {
  396 + exit;
  397 + }
  398 + }
  399 +
  400 + $title =~ s/'/\\'/g;
  401 + $artist =~ s/'/\\'/g;
  402 + $category =~ s/'/\\'/g;
  403 +
  404 + $sql = "INSERT INTO $db->{table_cds} (cddbid, artist, title, category, tracks) VALUES (\'$cddbid\', \'$artist\', \'$title\', \'$category\' , \'$trackno\')";
  405 + $sth = $dbh->prepare($sql);
  406 + $r = $sth->execute or die "failed to insert cd: $DBI::errstr";
  407 +
  408 + my $n=1;
  409 +
  410 + print "titel: $title\n";
  411 + print "artist: $artist\n";
  412 + print "category: $category\n\n";
  413 +
  414 + for my $t ( @{$cd->{track}} ) {
  415 + $t =~ s/'/\\'/g;
  416 + my $dur=($cd->{frames}[$n]-1-$cd->{frames}[$n-1])/75;
  417 + my $hour=int($dur/3600);
  418 + my $min=int($dur/60-$hour*60);
  419 + my $sec=$dur-$hour*3600-$min*60;
  420 + my $fr=substr(sprintf("%5.2f",$sec-int($sec)),2,3);
  421 + my $time=sprintf "%.2d:%.2d:%.2d%s",$hour,$min,int($sec),$fr;
  422 +
  423 + print "track $n: $t [$time]\n";
  424 +
  425 + my $sql = "INSERT INTO $db->{table_tracks} (cddbid, title, trackno, time)
  426 + VALUES (\'$cddbid\',\'$t\', \'$n\', \'$time\')";
  427 + my $sth = $dbh->prepare($sql);
  428 + my $r = $sth->execute or die "failed to insert track $n: $DBI::errstr";
  429 + $n++;
  430 + }
  431 +
  432 + $dbh->disconnect();
  433 +}
  434 +
  435 +sub print_lame {
  436 + my $cd=shift;
  437 +
  438 + print_cd($cd);
  439 + print "\n";
  440 +
  441 + my $n=1;
  442 + for my $i ( @{$cd->{track}} ) {
  443 + $i =~ s/"/'/g;
  444 + print 'lame --tl "'.$cd->{title}.'" --ta "'.$cd->{artist}.'" --tt "'.$i.'" ';
  445 + printf "audio_%02d.wav ",$n;
  446 + $i =~ s/[^\S]|['"\/]/_/g;
  447 + $i =~ s/_+-_+/-/g;
  448 + print " $i.mp3\n";
  449 + $n++;
  450 + }
  451 +}
... ...
  1 +<?xml version="1.0" encoding="ISO-8859-15"?>
  2 +<xsl:stylesheet version="1.0"
  3 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4 +
  5 + <xsl:output method="text" indent="no" encoding="ISO-8859-15" />
  6 +
  7 + <xsl:template match="/">
  8 +cddb=`echo <xsl:value-of select="/cdinfo/cddb"/> | sed &apos;s/0x\(.*\)/\1/g&apos;`
  9 +date=`date`
  10 +
  11 + <xsl:apply-templates select="/cdinfo/track"/>
  12 + </xsl:template>
  13 +
  14 + <xsl:template match="track">
  15 +track=&quot;`echo <xsl:value-of select="track-number"/> | /usr/bin/awk &apos;{printf(&quot;%02d&quot;, $0)}&apos;`&quot;
  16 +track=&quot;${track}-<xsl:value-of select="track-title"/>&quot;
  17 +
  18 +cat &gt; &quot;${track}.xinf&quot; &lt;&lt;- end
  19 + #
  20 + # X-CD-Roast 0.98alpha15 - INF-File
  21 + # created: $date
  22 + # by: getcd.sh
  23 + #
  24 + file = &quot;./${track}.wav&quot;
  25 + track = <xsl:value-of select="track-number"/> of <xsl:value-of select="/cdinfo/cd-tracks"/>
  26 + title = &quot;<xsl:value-of select="track-title"/>&quot;
  27 + artist = &quot;<xsl:value-of select="track-artist"/>&quot;
  28 + size = <xsl:value-of select="track-length"/>
  29 + type = 1
  30 + rec_type = 0
  31 + preemp = 0
  32 + copyperm = 0
  33 + stereo = 1
  34 + # from CD:
  35 + cd_title = &quot;<xsl:value-of select="/cdinfo/cd-title"/>&quot;
  36 + cd_artist = &quot;<xsl:value-of select="/cdinfo/cd-artist"/>&quot;
  37 + cd_discid = &quot;$cddb&quot;
  38 +end
  39 + </xsl:template>
  40 +</xsl:stylesheet>
... ...
  1 +<?xml version="1.0" encoding="ISO-8859-15"?>
  2 +<xsl:stylesheet version="1.0"
  3 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4 +
  5 + <xsl:output method="text" indent="no" encoding="ISO-8859-15" />
  6 +
  7 + <xsl:template match="/">
  8 +outdir="../../../mp3/<xsl:value-of select="/cdinfo/cd-artist"/>"
  9 +outdir="$outdir/<xsl:value-of select="/cdinfo/cd-title"/>"
  10 +mkdirhier &quot;$outdir&quot;
  11 + <xsl:apply-templates select="/cdinfo/track"/>
  12 + </xsl:template>
  13 +
  14 + <xsl:template match="track">
  15 +tracknum=`echo <xsl:value-of select="track-number"/> | \
  16 + awk &apos;{printf(&quot;%02d&quot;, $0)}&apos;`
  17 +title=&quot;<xsl:value-of select="track-title"/>&quot;
  18 +flac -d -o - &quot;$tracknum-$title.flac&quot; | \
  19 + lame -h --ta &quot;<xsl:value-of select="track-artist"/>&quot; \
  20 + --tl &quot;<xsl:value-of select="/cdinfo/cd-title"/>&quot; \
  21 + --tg &quot;<xsl:value-of select="/cdinfo/cd-genre"/>&quot; \
  22 + --tt &quot;<xsl:value-of select="track-title"/>&quot; \
  23 + --tn &quot;<xsl:value-of select="track-number"/>&quot; \
  24 + --ty &quot;<xsl:value-of select="/cdinfo/cd-year"/>&quot; \
  25 + --tc &quot;<xsl:value-of select="track-comment"/>&quot; - \
  26 + &quot;$outdir/$tracknum-$title.mp3&quot;
  27 + </xsl:template>
  28 +</xsl:stylesheet>
... ...
  1 +<?xml version="1.0" encoding="ISO-8859-15"?>
  2 +<xsl:stylesheet version="1.0"
  3 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4 +
  5 + <xsl:output method="text" indent="no" encoding="ISO-8859-15" />
  6 +
  7 + <xsl:template match="/">
  8 +outdir="../../../wav/<xsl:value-of select="/cdinfo/cd-artist"/>"
  9 +outdir="$outdir/<xsl:value-of select="/cdinfo/cd-title"/>"
  10 +mkdirhier &quot;$outdir&quot;
  11 + <xsl:apply-templates select="/cdinfo/track"/>
  12 + </xsl:template>
  13 +
  14 + <xsl:template match="track">
  15 +tracknum=`echo <xsl:value-of select="track-number"/> | \
  16 + awk &apos;{printf(&quot;%02d&quot;, $0)}&apos;`
  17 +title=&quot;<xsl:value-of select="track-title"/>&quot;
  18 +flac -d -o &quot;$outdir/$tracknum-$title.wav&quot; \
  19 + &quot;$tracknum-$title.flac&quot;
  20 + </xsl:template>
  21 +</xsl:stylesheet>
... ...
  1 +USAGE="usage: $0 [-d delimiter [-o {t|a}]] [-t {m|f|o}] [-p path] [-e encoder] [-c cddb-entry] [-h]\n"
  2 +USAGE="${USAGE} -d :\tA single character delimiting trackname from\n"
  3 +USAGE="${USAGE}\tartistname with sampler cds\n\n"
  4 +USAGE="${USAGE} -o :\tspecifies if theres the track or the artist first\n"
  5 +USAGE="${USAGE}\tMust be:\n"
  6 +USAGE="${USAGE}\t t for titel first or\n"
  7 +USAGE="${USAGE}\t a for artist first\n"
  8 +USAGE="${USAGE}\tIf there is none specified t is assumed\n"
  9 +USAGE="${USAGE} -t :\tyou can specify either m for encoding to mp3\n"
  10 +USAGE="${USAGE}\tusing lame, or f for making lossless encoding using flac,\n"
  11 +USAGE="${USAGE}\tor o for making ogg/vorbis, or w for uncompressed wav.\n"
  12 +USAGE="${USAGE}\tOmitting this results in encoding to flac.\n"
  13 +USAGE="${USAGE}\tmp3s will be placed under a subfolder mp3 and flacs\n"
  14 +USAGE="${USAGE}\tunder a subfolder flac\n"
  15 +USAGE="${USAGE} -p :\tspecifies the path to save the encoded data.\n"
  16 +USAGE="${USAGE}\tDefaults to the users home directory.\n"
  17 +USAGE="${USAGE} -e :\tspecifies the mp3 encoder to use.\n"
  18 +USAGE="${USAGE}\tvalid encoders are actually: lame,bladeenc\n"
  19 +USAGE="${USAGE}\tDefaults to lame.\n"
  20 +USAGE="${USAGE} -c :\tspecifies the CDDB-Entry to use.\n"
  21 +USAGE="${USAGE}\tsometimes there is more than 1 entry for a cd in cddb.\n"
  22 +USAGE="${USAGE}\tThen you can specify wich one to use by this option.\n"
  23 +USAGE="${USAGE}\tYou can checkout all entries using cddb.pl.\n"
  24 +USAGE="${USAGE} -h :\tShows this help."
  25 +
  26 +HAS_DELIMITER=0
  27 +TA_ORDER="t"
  28 +ENCODING_DIR=$HOME
  29 +ENCODING_TYPE="f"
  30 +ENCODER="lame"
  31 +CDDB_ENTRY=1
  32 +
  33 +while getopts d:o:t:p:he:c: option
  34 +do
  35 + case $option in
  36 + d) if [ ${#OPTARG} -gt 1 ]
  37 + then
  38 + echo -e "$USAGE"
  39 + exit 1
  40 + fi
  41 + HAS_DELIMITER=1
  42 + TA_DELIMITER=$OPTARG
  43 + ;;
  44 + o) if [ \( "${OPTARG}" != "t" -a "${OPTARG}" != "a" \) -o \
  45 + ${HAS_DELIMITER} -eq 0 ]
  46 + then
  47 + echo -e "$USAGE"
  48 + exit 1
  49 + fi
  50 + TA_ORDER=$OPTARG
  51 + ;;
  52 + t) if [ ${OPTARG} != "m" -a ${OPTARG} != "f" -a ${OPTARG} != "o" -a \
  53 + ${OPTARG} != "w" ]
  54 + then
  55 + echo -e "$USAGE"
  56 + exit 1
  57 + fi
  58 + ENCODING_TYPE=$OPTARG
  59 + ;;
  60 + p) if [ ! \( -d ${OPTARG} \) ]
  61 + then
  62 + echo -e "$USAGE"
  63 + exit 1
  64 + fi
  65 + ENCODING_DIR=$OPTARG
  66 + ;;
  67 + e) if [ -z ${OPTARG} ]
  68 + then
  69 + echo -e "$USAGE"
  70 + exit 1
  71 + fi
  72 + ENCODER=$OPTARG
  73 + ;;
  74 + c) if [ ${OPTARG} -lt 1 ]
  75 + then
  76 + echo -e "$USAGE"
  77 + exit 1
  78 + fi
  79 + CDDB_ENTRY=$OPTARG
  80 + ;;
  81 + [h\?]) echo -e "$USAGE"
  82 + exit 1
  83 + ;;
  84 + esac
  85 +done
  86 +
  87 +test "$ENCODING_TYPE" = "m" && ENCODING_DIR="$ENCODING_DIR/mp3"
  88 +test "$ENCODING_TYPE" = "f" && ENCODING_DIR="$ENCODING_DIR/flac"
  89 +test "$ENCODING_TYPE" = "o" && ENCODING_DIR="$ENCODING_DIR/ogg"
  90 +test "$ENCODING_TYPE" = "w" && ENCODING_DIR="$ENCODING_DIR/wav"
  91 +
  92 +indices[0]="album"
  93 +indices[1]="artist"
  94 +indices[2]="genre"
  95 +indices[3]="year"
  96 +indices[4]="comment"
  97 +
  98 +i=1
  99 +max_track=30
  100 +
  101 +while [ $i -le $max_track ]; do
  102 + indices[`expr \( $i \- 1 \) \* 2 \+ 5`]="`echo $i | \
  103 + sed 's/^\([0-9]\)$/0\1/g;\
  104 + s/\(.*\)/track-\1/g'`"
  105 + indices[`expr \( $i \- 1 \) \* 2 \+ 6`]="`echo $i | \
  106 + sed 's/^\([0-9]\)$/0\1/g;\
  107 + s/\(.*\)/tartist-\1/g'`"
  108 + i=`expr $i \+ 1`
  109 +done
  110 +
  111 +comment=""
  112 +
  113 +function idxof() {
  114 + str=$1
  115 + idx=0
  116 +
  117 + for i in "${indices[@]}"; do
  118 + test "$i" == "$str" && echo $idx && return 0
  119 + idx=`expr $idx \+ 1`
  120 + done
  121 +
  122 + echo -1
  123 + return 0
  124 +}
  125 +
  126 +title_pat="/^[^:]*: *(.*[^ ]).*/"
  127 +artist_pat="//"
  128 +
  129 +if [ $HAS_DELIMITER -ne 0 ]
  130 +then
  131 + if [ $TA_ORDER == "t" ]
  132 + then
  133 + title_pat="/^[^:]*: *([^\\${TA_DELIMITER}]*[^ \\${TA_DELIMITER}]).*/"
  134 + artist_pat="/^[^:]*: *[^\\${TA_DELIMITER}]*\\${TA_DELIMITER} *(.*[^ ]).*/"
  135 + else
  136 + artist_pat="/^[^:]*: *([^\\${TA_DELIMITER}]*[^ \\${TA_DELIMITER}]).*/"
  137 + title_pat="/^[^:]*: *[^\\${TA_DELIMITER}]*\\${TA_DELIMITER} *(.*[^ ]).*/"
  138 + fi
  139 +fi
  140 +
  141 +echo "Preparing...."
  142 +
  143 +echo -n "getting cddb info..."
  144 +eval "`cddb.pl -e $CDDB_ENTRY | sed 's/ \([0-9]\):/ 0\1:/g;s/track /track-/g' |\
  145 + awk -v has_delimiter=$HAS_DELIMITER \
  146 + '/artist/||/title/||/genre/||/year/ { \
  147 + cddb[gensub(/^([^:]*):.*/, \"\\\\1\", \"1\")]=\
  148 + gensub(/^[^:]*: *(.*[^ ]).*/, \"\\\\1\", \"g\")\
  149 + } \
  150 + /trackno/ {\
  151 + trackno=int(gensub(/^trackno: *([0-9]*).*/, \"\\\\1\", \"1\"))\
  152 + }\
  153 + /track-/ {\
  154 + cddb[gensub(/^([^:]*):.*/, \"\\\\1\", \"1\")]=\
  155 + gensub('\"$title_pat\"', \"\\\\1\", \"1\");\
  156 + if(has_delimiter==0) \
  157 + cddb[gensub(/^track([^:]*):.*/, \"tarti\\\\1\", \"1\")]=\
  158 + cddb[\"artist\"]; \
  159 + else \
  160 + cddb[gensub(/^track([^:]*):.*/, \"tarti\\\\1\", \"1\")]=\
  161 + gensub('\"$artist_pat\"', \"\\\\1\", \"1\");\
  162 + } \
  163 + END {\
  164 + cddb_str=\"cddb=(\\\"\" cddb[\"title\"] \"\\\" \\\"\" \
  165 + cddb[\"artist\"] \"\\\" \\\"\" \
  166 + cddb[\"genre\"] \"\\\" \\\"\" \
  167 + cddb[\"year\"] \"\\\" \\\"'$comment'\\\"\"; \
  168 + for(i=1; i<=trackno; i++) {\
  169 + cddb_str=cddb_str \" \\\"\" \
  170 + cddb[\"track-\" sprintf(\"%02s\", i)] \"\\\"\";\
  171 + cddb_str=cddb_str \" \\\"\" \
  172 + cddb[\"tarti-\" sprintf(\"%02s\", i)] \"\\\"\"\
  173 + }\
  174 + print cddb_str \")\"\
  175 + }'`"
  176 +echo "done"
  177 +
  178 +echo -n "getting CD info..."
  179 +cddainfo=`cdda2wav -H -D/dev/cdrom -J -v summary,toc,sectors 2>&1`
  180 +echo "done"
  181 +
  182 +track_num=`echo "$cddainfo" | \
  183 + sed '/tracks/{s/^.*tracks:\([0-9]*\).*$/\1/g;p};d'`
  184 +cd_time=`echo "$cddainfo" | \
  185 + sed '/tracks/{s/^.*time \([0-9:\.]*\).*$/\1/g;p};d'`
  186 +cddbid=`echo "$cddainfo" | \
  187 + sed '/CDDB/{s/^.*discid: *\(0x[a-z0-9]*[^ ]\).*/\1/g;p};d'`
  188 +cdindex=`echo "$cddainfo" | \
  189 + sed '/CDINDEX/{s/^.*discid: *\([a-zA-Z0-9_\.]*-\).*/\1/g;p};d'`
  190 +cdtext=`echo "$cddainfo" | sed '/CD-Text/{s/^[^:]*: *\(.*[^ ]\).*/\1/g
  191 + s/&/\&amp\;/g;s/\"/\&quot\;/g
  192 + s/</\&lt\;/g;s/>/\&gt\;/g
  193 + s/\o47/\&apos\;/g
  194 + p};d'`
  195 +cdextra=`echo "$cddainfo" | sed '/CD-Extra/{s/^[^:]*: *\(.*[^ ]\).*/\1/g
  196 + s/&/\&amp\;/g;s/\"/\&quot\;/g
  197 + s/</\&lt\;/g;s/>/\&gt\;/g
  198 + s/\o47/\&apos\;/g
  199 + p};d'`
  200 +
  201 +ENCODING_DIR="${ENCODING_DIR}/${cddb[`idxof "artist"`]}/"
  202 +ENCODING_DIR="${ENCODING_DIR}${cddb[`idxof "album"`]}/"
  203 +mkdirhier "$ENCODING_DIR"
  204 +echo "Output directory is: $ENCODING_DIR"
  205 +
  206 +xmlfile="${ENCODING_DIR}cdinfo.xml"
  207 +
  208 +# some special chars within xml must be converted to special syntax
  209 +# & => &amp;
  210 +# " => &quot;
  211 +# ' => &apos;
  212 +# < => &lt;
  213 +# > => &gt;
  214 +xmlartist=`echo ${cddb[\`idxof "artist"\`]} | \
  215 + sed 's/&/\&amp\;/g
  216 + s/</\&lt\;/g
  217 + s/>/\&gt\;/g
  218 + s/\"/\&quot\;/g
  219 + s/\o47/\&apos\;/g'`
  220 +xmlalbum=`echo ${cddb[\`idxof "album"\`]} | \
  221 + sed 's/&/\&amp\;/g
  222 + s/</\&lt\;/g
  223 + s/>/\&gt\;/g
  224 + s/\"/\&quot\;/g
  225 + s/\o47/\&apos\;/g'`
  226 +
  227 +echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>" > "${xmlfile}"
  228 +echo "<!DOCTYPE cdInfo SYSTEM \"cdInfo.dtd\">" >> "${xmlfile}"
  229 +echo "<cdinfo>" >> "${xmlfile}"
  230 +echo " <cdindex>$cdindex</cdindex>" >> "${xmlfile}"
  231 +echo " <cddb>$cddbid</cddb>" >> "${xmlfile}"
  232 +echo " <cd-text>$cdtext</cd-text>" >> "${xmlfile}"
  233 +echo " <cd-extra>$cdextra</cd-extra>" >> "${xmlfile}"
  234 +echo " <cd-artist>${xmlartist}</cd-artist>" >> "${xmlfile}"
  235 +echo " <cd-title>${xmlalbum}</cd-title>" >> "${xmlfile}"
  236 +echo " <cd-year>${cddb[`idxof "year"`]}</cd-year>" >> "${xmlfile}"
  237 +echo " <cd-genre>${cddb[`idxof "genre"`]}</cd-genre>" >> "${xmlfile}"
  238 +echo " <cd-time>$cd_time</cd-time>" >> "${xmlfile}"
  239 +echo " <cd-tracks>$track_num</cd-tracks>" >> "${xmlfile}"
  240 +echo " <cd-comment></cd-comment>" >> "${xmlfile}"
  241 +
  242 +i=1; while [ $i -le $track_num ]
  243 +do
  244 + j=`expr $i \+ 1`
  245 + tracknr=`awk 'BEGIN{printf("%02d\n",'$i')}'`
  246 + track=${cddb[`idxof "track-$tracknr"`]}
  247 + tartist=${cddb[`idxof "tartist-$tracknr"`]}
  248 +
  249 + xmltrack=`echo ${track} | sed 's/&/\&amp\;/g
  250 + s/</\&lt\;/g
  251 + s/>/\&gt\;/g
  252 + s/\"/\&quot\;/g
  253 + s/\o47/\&apos\;/g'`
  254 + xmltartist=`echo ${tartist} | sed 's/&/\&amp\;/g
  255 + s/</\&lt\;/g
  256 + s/>/\&gt\;/g
  257 + s/\"/\&quot\;/g
  258 + s/\o47/\&apos\;/g'`
  259 +
  260 + tracklen=`echo "$cddainfo" | \
  261 + sed '/ '"$i"'\.([0-9 ]*:/{s/.*'"$i"'\.( *\([0-9:\.]*\)).*/\1/g;p};d'`
  262 + trackstart=`echo "$cddainfo" | \
  263 + sed '/ '"$i"'\.([0-9 ]*)/{s/.*'"$i"'\.( *\([0-9]*\)).*/\1/g;p};d'`
  264 + test $i -eq $track_num && \
  265 + trackend=`echo "$cddainfo" | \
  266 + sed '/ lead-out([0-9 ]*)/{s/.*lead-out( *\([0-9]*\)).*/\1/g;p};d'` || \
  267 + trackend=`echo "$cddainfo" | \
  268 + sed '/ '"$j"'\.([0-9 ]*)/{s/.*'"$j"'\.( *\([0-9]*\)).*/\1/g;p};d'`
  269 +
  270 + echo " <track>" >> "${xmlfile}"
  271 + echo " <track-number>$i</track-number>" >> "${xmlfile}"
  272 + echo " <track-time>$tracklen</track-time>" >> "${xmlfile}"
  273 + echo " <track-start-sector>$trackstart</track-start-sector>" >> "${xmlfile}"
  274 + echo " <track-length>`expr $trackend \- $trackstart`</track-length>" >> "${xmlfile}"
  275 + echo " <track-artist>$xmltartist</track-artist>" >> "${xmlfile}"
  276 + echo " <track-title>$xmltrack</track-title>" >> "${xmlfile}"
  277 + echo " <track-comment></track-comment>" >> "${xmlfile}"
  278 + echo " </track>" >> "${xmlfile}"
  279 +
  280 + # outfile="${ENCODING_DIR}The Wall/Disk2/"
  281 + outfile="${ENCODING_DIR}${tracknr}-${track}"
  282 +
  283 + test "$ENCODING_TYPE" = "f" && \
  284 + outstr="track-$tracknr => ${tracknr}-${track}.flac"
  285 + test "$ENCODING_TYPE" = "m" && \
  286 + outstr="track-$tracknr => ${tracknr}-${track}.mp3"
  287 + test "$ENCODING_TYPE" = "o" && \
  288 + outstr="track-$tracknr => ${tracknr}-${track}.ogg"
  289 + test "$ENCODING_TYPE" = "w" && \
  290 + outstr="track-$tracknr => ${tracknr}-${track}.wav"
  291 +
  292 + if [ "$ENCODING_TYPE" = "f" ]
  293 + then
  294 + bash -c "exec 2>&1;\
  295 + cdda2wav -H -D/dev/cdrom -H -t$i - | \
  296 + flac -c \
  297 + -T artist=\"${tartist}\" -T album=\"${cddb[`idxof "album"`]}\" \
  298 + -T genre=\"${cddb[`idxof "genre"`]}\" -T title=\"${track}\" \
  299 + -T tnum=\"`expr ${tracknr} \+ 0`\" -T date=\"${cddb[`idxof "year"`]}\" \
  300 + -T comment=\"${cddb[`idxof "comment"`]}\" \
  301 + -o \"${outfile}.flac\" - 2>/dev/null" | rton | \
  302 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  303 + fi
  304 + if [ "$ENCODING_TYPE" = "m" -a "$ENCODER" = "lame" ]
  305 + then
  306 + bash -c "exec 2>&1;\
  307 + cdda2wav -H -D/dev/cdrom -t$i - | \
  308 + lame -h \
  309 + --ta \"${tartist}\" --tl \"${cddb[`idxof "album"`]}\" \
  310 + --tg \"${cddb[`idxof "genre"`]}\" --tt \"${track}\" \
  311 + --tn \"`expr ${tracknr} \+ 0`\" --ty \"${cddb[`idxof "year"`]}\" \
  312 + --tc \"${cddb[`idxof "comment"`]}\" \
  313 + - \"${outfile}.mp3\" 2>/dev/null" | rton | \
  314 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  315 + fi
  316 + if [ "$ENCODING_TYPE" = "m" -a "$ENCODER" = "bladeenc" ]
  317 + then
  318 + bash -c "exec 2>&1;\
  319 + cdda2wav -H -D/dev/cdrom -t$i - | \
  320 + bladeenc -progress=0 STDIN \"${outfile}.mp3\" 2>/dev/null" | rton | \
  321 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  322 + fi
  323 + if [ "$ENCODING_TYPE" = "o" ]
  324 + then
  325 + bash -c "exec 2>&1;\
  326 + cdda2wav -H -D/dev/cdrom -t$i - | \
  327 + oggenc -a \"${tartist}\" -l \"${cddb[`idxof "album"`]}\" \
  328 + -G \"${cddb[`idxof "genre"`]}\" -t \"${track}\" \
  329 + -N \"`expr ${tracknr} \+ 0`\" -d \"${cddb[`idxof "year"`]}\" \
  330 + -c \"${cddb[`idxof "comment"`]}\" \
  331 + -o \"${outfile}.ogg\" - 2>/dev/null" | rton | \
  332 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  333 + fi
  334 + if [ "$ENCODING_TYPE" = "w" ]
  335 + then
  336 + bash -c "exec 2>&1;\
  337 + cdda2wav -H -D/dev/cdrom -t$i - > \"${outfile}.wav\"" | rton | \
  338 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  339 + fi
  340 +
  341 + i=`expr $i + 1`
  342 +done
  343 +
  344 +echo "</cdinfo>" >> "${xmlfile}"
... ...
  1 +USAGE="usage: $0 [-d delimiter [-o {t|a}]] [-t {m|f|o}] [-p path] [-e encoder] [-c cddb-entry] [-h]\n"
  2 +USAGE="${USAGE} -d :\tA single character delimiting trackname from\n"
  3 +USAGE="${USAGE}\tartistname with sampler cds\n\n"
  4 +USAGE="${USAGE} -o :\tspecifies if theres the track or the artist first\n"
  5 +USAGE="${USAGE}\tMust be:\n"
  6 +USAGE="${USAGE}\t t for titel first or\n"
  7 +USAGE="${USAGE}\t a for artist first\n"
  8 +USAGE="${USAGE}\tIf there is none specified t is assumed\n"
  9 +USAGE="${USAGE} -t :\tyou can specify either m for encoding to mp3\n"
  10 +USAGE="${USAGE}\tusing lame, or f for making lossless encoding using flac,\n"
  11 +USAGE="${USAGE}\tor o for making ogg/vorbis, or w for uncompressed wav.\n"
  12 +USAGE="${USAGE}\tOmitting this results in encoding to flac.\n"
  13 +USAGE="${USAGE}\tmp3s will be placed under a subfolder mp3 and flacs\n"
  14 +USAGE="${USAGE}\tunder a subfolder flac\n"
  15 +USAGE="${USAGE} -p :\tspecifies the path to save the encoded data.\n"
  16 +USAGE="${USAGE}\tDefaults to the users home directory.\n"
  17 +USAGE="${USAGE} -e :\tspecifies the mp3 encoder to use.\n"
  18 +USAGE="${USAGE}\tvalid encoders are actually: lame,bladeenc\n"
  19 +USAGE="${USAGE}\tDefaults to lame.\n"
  20 +USAGE="${USAGE} -c :\tspecifies the CDDB-Entry to use.\n"
  21 +USAGE="${USAGE}\tsometimes there is more than 1 entry for a cd in cddb.\n"
  22 +USAGE="${USAGE}\tThen you can specify wich one to use by this option.\n"
  23 +USAGE="${USAGE}\tYou can checkout all entries using cddb.pl.\n"
  24 +USAGE="${USAGE} -h :\tShows this help."
  25 +
  26 +PATH="$PATH:."
  27 +
  28 +HAS_DELIMITER=0
  29 +TA_ORDER="t"
  30 +ENCODING_DIR=$HOME
  31 +ENCODING_TYPE="f"
  32 +ENCODER="lame"
  33 +CDDB_ENTRY=1
  34 +
  35 +while getopts d:o:t:p:he:c: option
  36 +do
  37 + case $option in
  38 + d) if [ ${#OPTARG} -gt 1 ]
  39 + then
  40 + echo -e "$USAGE"
  41 + exit 1
  42 + fi
  43 + HAS_DELIMITER=1
  44 + TA_DELIMITER=$OPTARG
  45 + ;;
  46 + o) if [ \( "${OPTARG}" != "t" -a "${OPTARG}" != "a" \) -o \
  47 + ${HAS_DELIMITER} -eq 0 ]
  48 + then
  49 + echo -e "$USAGE"
  50 + exit 1
  51 + fi
  52 + TA_ORDER=$OPTARG
  53 + ;;
  54 + t) if [ ${OPTARG} != "m" -a ${OPTARG} != "f" -a ${OPTARG} != "o" -a \
  55 + ${OPTARG} != "w" ]
  56 + then
  57 + echo -e "$USAGE"
  58 + exit 1
  59 + fi
  60 + ENCODING_TYPE=$OPTARG
  61 + ;;
  62 + p) if [ ! \( -d ${OPTARG} \) ]
  63 + then
  64 + echo -e "$USAGE"
  65 + exit 1
  66 + fi
  67 + ENCODING_DIR=$OPTARG
  68 + ;;
  69 + e) if [ -z ${OPTARG} ]
  70 + then
  71 + echo -e "$USAGE"
  72 + exit 1
  73 + fi
  74 + ENCODER=$OPTARG
  75 + ;;
  76 + c) if [ ${OPTARG} -lt 1 ]
  77 + then
  78 + echo -e "$USAGE"
  79 + exit 1
  80 + fi
  81 + CDDB_ENTRY=$OPTARG
  82 + ;;
  83 + [h\?]) echo -e "$USAGE"
  84 + exit 1
  85 + ;;
  86 + esac
  87 +done
  88 +
  89 +test "$ENCODING_TYPE" = "m" && ENCODING_DIR="$ENCODING_DIR/mp3"
  90 +test "$ENCODING_TYPE" = "f" && ENCODING_DIR="$ENCODING_DIR/flac"
  91 +test "$ENCODING_TYPE" = "o" && ENCODING_DIR="$ENCODING_DIR/ogg"
  92 +test "$ENCODING_TYPE" = "w" && ENCODING_DIR="$ENCODING_DIR/wav"
  93 +
  94 +indices[0]="album"
  95 +indices[1]="artist"
  96 +indices[2]="genre"
  97 +indices[3]="year"
  98 +indices[4]="comment"
  99 +
  100 +i=1
  101 +max_track=30
  102 +
  103 +while [ $i -le $max_track ]; do
  104 + indices[`expr \( $i \- 1 \) \* 2 \+ 5`]="`echo $i | \
  105 + sed 's/^\([0-9]\)$/0\1/g;\
  106 + s/\(.*\)/track-\1/g'`"
  107 + indices[`expr \( $i \- 1 \) \* 2 \+ 6`]="`echo $i | \
  108 + sed 's/^\([0-9]\)$/0\1/g;\
  109 + s/\(.*\)/tartist-\1/g'`"
  110 + i=`expr $i \+ 1`
  111 +done
  112 +
  113 +comment=""
  114 +
  115 +function idxof() {
  116 + str=$1
  117 + idx=0
  118 +
  119 + for i in "${indices[@]}"; do
  120 + test "$i" == "$str" && echo $idx && return 0
  121 + idx=`expr $idx \+ 1`
  122 + done
  123 +
  124 + echo -1
  125 + return 0
  126 +}
  127 +
  128 +title_pat="/^[^:]*: *(.*[^ ]).*/"
  129 +artist_pat="//"
  130 +
  131 +if [ $HAS_DELIMITER -ne 0 ]
  132 +then
  133 + if [ $TA_ORDER == "t" ]
  134 + then
  135 + title_pat="/^[^:]*: *([^\\${TA_DELIMITER}]*[^ \\${TA_DELIMITER}]).*/"
  136 + artist_pat="/^[^:]*: *[^\\${TA_DELIMITER}]*\\${TA_DELIMITER} *(.*[^ ]).*/"
  137 + else
  138 + artist_pat="/^[^:]*: *([^\\${TA_DELIMITER}]*[^ \\${TA_DELIMITER}]).*/"
  139 + title_pat="/^[^:]*: *[^\\${TA_DELIMITER}]*\\${TA_DELIMITER} *(.*[^ ]).*/"
  140 + fi
  141 +fi
  142 +
  143 +echo "Preparing...."
  144 +
  145 +echo -n "getting cddb info..."
  146 +eval "`cddb.pl -c /dev/cdrom1 -e $CDDB_ENTRY | sed 's/ \([0-9]\):/ 0\1:/g;s/track /track-/g' |\
  147 + awk -v has_delimiter=$HAS_DELIMITER \
  148 + '/artist/||/title/||/genre/||/year/ { \
  149 + cddb[gensub(/^([^:]*):.*/, \"\\\\1\", \"1\")]=\
  150 + gensub(/^[^:]*: *(.*[^ ]).*/, \"\\\\1\", \"g\")\
  151 + } \
  152 + /trackno/ {\
  153 + trackno=int(gensub(/^trackno: *([0-9]*).*/, \"\\\\1\", \"1\"))\
  154 + }\
  155 + /track-/ {\
  156 + cddb[gensub(/^([^:]*):.*/, \"\\\\1\", \"1\")]=\
  157 + gensub('\"$title_pat\"', \"\\\\1\", \"1\");\
  158 + if(has_delimiter==0) \
  159 + cddb[gensub(/^track([^:]*):.*/, \"tarti\\\\1\", \"1\")]=\
  160 + cddb[\"artist\"]; \
  161 + else \
  162 + cddb[gensub(/^track([^:]*):.*/, \"tarti\\\\1\", \"1\")]=\
  163 + gensub('\"$artist_pat\"', \"\\\\1\", \"1\");\
  164 + } \
  165 + END {\
  166 + cddb_str=\"cddb=(\\\"\" cddb[\"title\"] \"\\\" \\\"\" \
  167 + cddb[\"artist\"] \"\\\" \\\"\" \
  168 + cddb[\"genre\"] \"\\\" \\\"\" \
  169 + cddb[\"year\"] \"\\\" \\\"'$comment'\\\"\"; \
  170 + for(i=1; i<=trackno; i++) {\
  171 + cddb_str=cddb_str \" \\\"\" \
  172 + cddb[\"track-\" sprintf(\"%02s\", i)] \"\\\"\";\
  173 + cddb_str=cddb_str \" \\\"\" \
  174 + cddb[\"tarti-\" sprintf(\"%02s\", i)] \"\\\"\"\
  175 + }\
  176 + print cddb_str \")\"\
  177 + }'`"
  178 +echo "done"
  179 +
  180 +echo -n "getting CD info..."
  181 +cddainfo=`cdda2wav -H -D/dev/cdrom1 -J -v summary,toc,sectors 2>&1`
  182 +echo "done"
  183 +
  184 +track_num=`echo "$cddainfo" | \
  185 + sed '/tracks/{s/^.*tracks:\([0-9]*\).*$/\1/g;p};d'`
  186 +cd_time=`echo "$cddainfo" | \
  187 + sed '/tracks/{s/^.*time \([0-9:\.]*\).*$/\1/g;p};d'`
  188 +cddbid=`echo "$cddainfo" | \
  189 + sed '/CDDB/{s/^.*discid: *\(0x[a-z0-9]*[^ ]\).*/\1/g;p};d'`
  190 +cdindex=`echo "$cddainfo" | \
  191 + sed '/CDINDEX/{s/^.*discid: *\([a-zA-Z0-9_\.]*-\).*/\1/g;p};d'`
  192 +cdtext=`echo "$cddainfo" | sed '/CD-Text/{s/^[^:]*: *\(.*[^ ]\).*/\1/g
  193 + s/&/\&amp\;/g;s/\"/\&quot\;/g
  194 + s/</\&lt\;/g;s/>/\&gt\;/g
  195 + s/\o47/\&apos\;/g
  196 + p};d'`
  197 +cdextra=`echo "$cddainfo" | sed '/CD-Extra/{s/^[^:]*: *\(.*[^ ]\).*/\1/g
  198 + s/&/\&amp\;/g;s/\"/\&quot\;/g
  199 + s/</\&lt\;/g;s/>/\&gt\;/g
  200 + s/\o47/\&apos\;/g
  201 + p};d'`
  202 +
  203 +# cddb[`idxof "artist"`]="Blue Öyster Cult"
  204 +ENCODING_DIR="${ENCODING_DIR}/${cddb[`idxof "artist"`]}/"
  205 +ENCODING_DIR="${ENCODING_DIR}${cddb[`idxof "album"`]}/"
  206 +mkdirhier "$ENCODING_DIR"
  207 +echo "Output directory is: $ENCODING_DIR"
  208 +
  209 +xmlfile="${ENCODING_DIR}cdinfo.xml"
  210 +
  211 +# some special chars within xml must be converted to special syntax
  212 +# & => &amp;
  213 +# " => &quot;
  214 +# ' => &apos;
  215 +# < => &lt;
  216 +# > => &gt;
  217 +xmlartist=`echo ${cddb[\`idxof "artist"\`]} | \
  218 + sed 's/&/\&amp\;/g
  219 + s/</\&lt\;/g
  220 + s/>/\&gt\;/g
  221 + s/\"/\&quot\;/g
  222 + s/\o47/\&apos\;/g'`
  223 +xmlalbum=`echo ${cddb[\`idxof "album"\`]} | \
  224 + sed 's/&/\&amp\;/g
  225 + s/</\&lt\;/g
  226 + s/>/\&gt\;/g
  227 + s/\"/\&quot\;/g
  228 + s/\o47/\&apos\;/g'`
  229 +
  230 +echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>" > "${xmlfile}"
  231 +echo "<!DOCTYPE cdInfo SYSTEM \"cdInfo.dtd\">" >> "${xmlfile}"
  232 +echo "<cdinfo>" >> "${xmlfile}"
  233 +echo " <cdindex>$cdindex</cdindex>" >> "${xmlfile}"
  234 +echo " <cddb>$cddbid</cddb>" >> "${xmlfile}"
  235 +echo " <cd-text>$cdtext</cd-text>" >> "${xmlfile}"
  236 +echo " <cd-extra>$cdextra</cd-extra>" >> "${xmlfile}"
  237 +echo " <cd-artist>${xmlartist}</cd-artist>" >> "${xmlfile}"
  238 +echo " <cd-title>${xmlalbum}</cd-title>" >> "${xmlfile}"
  239 +echo " <cd-year>${cddb[`idxof "year"`]}</cd-year>" >> "${xmlfile}"
  240 +echo " <cd-genre>${cddb[`idxof "genre"`]}</cd-genre>" >> "${xmlfile}"
  241 +echo " <cd-time>$cd_time</cd-time>" >> "${xmlfile}"
  242 +echo " <cd-tracks>$track_num</cd-tracks>" >> "${xmlfile}"
  243 +echo " <cd-comment></cd-comment>" >> "${xmlfile}"
  244 +
  245 +i=1; while [ $i -le $track_num ]
  246 +do
  247 + j=`expr $i \+ 1`
  248 + tracknr=`awk 'BEGIN{printf("%02d\n",'$i')}'`
  249 + track=${cddb[`idxof "track-$tracknr"`]}
  250 + tartist=${cddb[`idxof "tartist-$tracknr"`]}
  251 +
  252 + xmltrack=`echo ${track} | sed 's/&/\&amp\;/g
  253 + s/</\&lt\;/g
  254 + s/>/\&gt\;/g
  255 + s/\"/\&quot\;/g
  256 + s/\o47/\&apos\;/g'`
  257 + xmltartist=`echo ${tartist} | sed 's/&/\&amp\;/g
  258 + s/</\&lt\;/g
  259 + s/>/\&gt\;/g
  260 + s/\"/\&quot\;/g
  261 + s/\o47/\&apos\;/g'`
  262 +
  263 + tracklen=`echo "$cddainfo" | \
  264 + sed '/ '"$i"'\.([0-9 ]*:/{s/.*'"$i"'\.( *\([0-9:\.]*\)).*/\1/g;p};d'`
  265 + trackstart=`echo "$cddainfo" | \
  266 + sed '/ '"$i"'\.([0-9 ]*)/{s/.*'"$i"'\.( *\([0-9]*\)).*/\1/g;p};d'`
  267 + test $i -eq $track_num && \
  268 + trackend=`echo "$cddainfo" | \
  269 + sed '/ lead-out([0-9 ]*)/{s/.*lead-out( *\([0-9]*\)).*/\1/g;p};d'` || \
  270 + trackend=`echo "$cddainfo" | \
  271 + sed '/ '"$j"'\.([0-9 ]*)/{s/.*'"$j"'\.( *\([0-9]*\)).*/\1/g;p};d'`
  272 +
  273 + test -z "$trackstart" -o -z "$trackend" && echo "Disk Error" && exit 1
  274 +
  275 + echo " <track>" >> "${xmlfile}"
  276 + echo " <track-number>$i</track-number>" >> "${xmlfile}"
  277 + echo " <track-time>$tracklen</track-time>" >> "${xmlfile}"
  278 + echo " <track-start-sector>$trackstart</track-start-sector>" >> "${xmlfile}"
  279 + echo " <track-length>`expr $trackend \- $trackstart`</track-length>" >> "${xmlfile}"
  280 + echo " <track-artist>$xmltartist</track-artist>" >> "${xmlfile}"
  281 + echo " <track-title>$xmltrack</track-title>" >> "${xmlfile}"
  282 + echo " <track-comment></track-comment>" >> "${xmlfile}"
  283 + echo " </track>" >> "${xmlfile}"
  284 +
  285 + # outfile="${ENCODING_DIR}The Wall/Disk2/"
  286 + outfile="${ENCODING_DIR}${tracknr}-${track}"
  287 +
  288 + test "$ENCODING_TYPE" = "f" && \
  289 + outstr="track-$tracknr => ${tracknr}-${track}.flac"
  290 + test "$ENCODING_TYPE" = "m" && \
  291 + outstr="track-$tracknr => ${tracknr}-${track}.mp3"
  292 + test "$ENCODING_TYPE" = "o" && \
  293 + outstr="track-$tracknr => ${tracknr}-${track}.ogg"
  294 + test "$ENCODING_TYPE" = "w" && \
  295 + outstr="track-$tracknr => ${tracknr}-${track}.wav"
  296 +
  297 + if [ "$ENCODING_TYPE" = "f" ]
  298 + then
  299 + bash -c "exec 2>&1;\
  300 + cdda2wav -H -D0,4,0 -t$i - | \
  301 + flac -c \
  302 + -T artist=\"${tartist}\" -T album=\"${cddb[`idxof "album"`]}\" \
  303 + -T genre=\"${cddb[`idxof "genre"`]}\" -T title=\"${track}\" \
  304 + -T tracknumber=\"`expr ${tracknr} \+ 0`\" \
  305 + -T tracknum=\"`expr ${tracknr} \+ 0`\" -T date=\"${cddb[`idxof "year"`]}\" \
  306 + -T comment=\"${cddb[`idxof "comment"`]}\" \
  307 + -o \"${outfile}.flac\" - 2>/dev/null" | rton | \
  308 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  309 + fi
  310 + if [ "$ENCODING_TYPE" = "m" -a "$ENCODER" = "lame" ]
  311 + then
  312 + bash -c "exec 2>&1;\
  313 + cdda2wav -H -D0,4,0 -t$i - | \
  314 + lame -h \
  315 + --ta \"${tartist}\" --tl \"${cddb[`idxof "album"`]}\" \
  316 + --tg \"${cddb[`idxof "genre"`]}\" --tt \"${track}\" \
  317 + --tn \"`expr ${tracknr} \+ 0`\" --ty \"${cddb[`idxof "year"`]}\" \
  318 + --tc \"${cddb[`idxof "comment"`]}\" \
  319 + - \"${outfile}.mp3\" 2>/dev/null" | rton | \
  320 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  321 + fi
  322 + if [ "$ENCODING_TYPE" = "m" -a "$ENCODER" = "bladeenc" ]
  323 + then
  324 + bash -c "exec 2>&1;\
  325 + cdda2wav -H -D0,4,0 -t$i - | \
  326 + bladeenc -progress=0 STDIN \"${outfile}.mp3\" 2>/dev/null" | rton | \
  327 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  328 + fi
  329 + if [ "$ENCODING_TYPE" = "o" ]
  330 + then
  331 + bash -c "exec 2>&1;\
  332 + cdda2wav -H -D0,4,0 -t$i - | \
  333 + oggenc -a \"${tartist}\" -l \"${cddb[`idxof "album"`]}\" \
  334 + -G \"${cddb[`idxof "genre"`]}\" -t \"${track}\" \
  335 + -N \"`expr ${tracknr} \+ 0`\" -d \"${cddb[`idxof "year"`]}\" \
  336 + -c \"${cddb[`idxof "comment"`]}\" \
  337 + -o \"${outfile}.ogg\" - 2>/dev/null" | rton | \
  338 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  339 + fi
  340 + if [ "$ENCODING_TYPE" = "w" ]
  341 + then
  342 + bash -c "exec 2>&1;\
  343 + cdda2wav -H -D0,4,0 -t$i - > \"${outfile}.wav\"" | rton | \
  344 + awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}'
  345 + fi
  346 +
  347 + i=`expr $i + 1`
  348 +done
  349 +
  350 +echo "</cdinfo>" >> "${xmlfile}"
... ...
  1 +<?xml version="1.0" encoding="ISO-8859-15"?>
  2 +<!DOCTYPE cdInfo SYSTEM "cdInfo.dtd">
  3 +<cdinfo>
  4 +<cdindex>2pGK39LLL22K6K8mFDegkBNR39M-</cdindex>
  5 +<cddb>0x0911a912</cddb>
  6 +<cd-text/>
  7 +<cd-extra/>
  8 +<cd-artist>Various</cd-artist>
  9 +<cd-year>1998</cd-year>
  10 +<cd-genre>Alternative</cd-genre>
  11 +<track>
  12 +<track-number>1</track-number>
  13 +<track-time>3:42.20</track-time>
  14 +<track-start-sector>32</track-start-sector>
  15 +<track-artist>Guano Apes</track-artist>
  16 +<track-title>Lords Of The Boards</track-title>
  17 +<track-comment/>
  18 +</track>
  19 +<track>
  20 +<track-number>2</track-number>
  21 +<track-time>4:45.70</track-time>
  22 +<track-start-sector>16702</track-start-sector>
  23 +<track-artist>Rammstein</track-artist>
  24 +<track-title>Das Modell</track-title>
  25 +<track-comment/>
  26 +</track>
  27 +<track>
  28 +<track-number>3</track-number>
  29 +<track-time>4:11.08</track-time>
  30 +<track-start-sector>38147</track-start-sector>
  31 +<track-artist>Faith No More</track-artist>
  32 +<track-title>Last Cup Of Sorrow</track-title>
  33 +<track-comment/>
  34 +</track>
  35 +</cdinfo>
... ...
  1 +Files in this package
  2 +---------------------
  3 + getcd.sh (The main script that does most of the work)
  4 + rton.c (A VERY small c-prog, that converts \r (carriage return)
  5 + to \n (line feed). It is needed to fetch the percent
  6 + complete messages from cdda2wav)
  7 + flac2mp3.xsl (xml stylesheet to convert cdinfo.xml in shell commands
  8 + that will create .flac from .mp3 files)
  9 + flac2wav.xsl (xml stylesheet to convert cdinfo.xml in shell commands
  10 + that will create .flac from .wav files)
  11 + mp32wav.xsl (xml stylesheet to convert cdinfo.xml in shell commands
  12 + that will create .wav from .mp3 files)
  13 + cdinfo2xinf.xsl (xml stylesheet to convert cdinfo.xml in shell commands
  14 + that create the .xinf Files used by xcdroast)
  15 + CDDB_get-2.23p1.patch (a patch for cddb.pl that makes it possible to
  16 + select one of multiple cddb-entrys at calltime)
  17 + README (Overview and Information)
  18 + INSTALL (This file, howto make something useful from it)
  19 + USAGE (How to use the script)
  20 +
  21 +
  22 +Requirments
  23 +-----------
  24 +first you need some software to run this script.
  25 + CDDB_get-2.23 (http://armin.emx.at/cddb/)
  26 + lame (http://lame.sourceforge.net/)
  27 + bladeenc (http://bladeenc.mp3.no/)
  28 + flac (http://flac.sourceforge.net/)
  29 + vorbis-tools (http://www.vorbis.com/download_unix_1.0.1.psp)
  30 + libxml2 (http://xmlsoft.org/)
  31 +
  32 +I assume you have a working sed and awk, else you need to install them too.
  33 +
  34 +Install lame, bladeenc, flac, vorbis-tools and libxml2 as discribed within
  35 +these packages.
  36 +
  37 +unpack CDDB_get-2.23.tar.gz and patch it with CDDB_get-2.23p1.patch.
  38 +For this copy both files in a directory dir then do the following:
  39 +
  40 +me@house:~> cd dir
  41 +me@house:~/dir> tar xfvz CDDB_get-2.23.tar.gz
  42 +me@house:~/dir/CDDB_get-2.23> patch -p1 -E < ../CDDB_get-2.23p1.patch
  43 +
  44 +now install it as usual (and described within the README from CDDB_get)
  45 +
  46 +now go in the directory where rton.c exists.
  47 +type here: gcc -o rton rton.c
  48 +and then copy rton in a directory in your path.
  49 +
  50 +Finally copy getcd.sh somewhere in you path.
  51 +
  52 +now you can use getcd.sh. For a short description how to use it either
  53 +read USAGE or type getcd.sh -h.
  54 +
  55 +IMPORTANT: Any user who should use this script needs read-access to the
  56 +cdrom device, additional it is actually necessary to create a symlink
  57 +/dev/cdrom to your real device eg. /dev/sr0 or /dev/hdb. And the user must have
  58 +access to the internet.
  59 +
  60 +Note
  61 +----
  62 +Please note that this is not a release. You can use it and it will not harm
  63 +anything as for as I can say, but it might not work with some configurations
  64 +or CDs.
  65 +In the release there will be some kind of detection which tools are present and
  66 +witch not and the script will use only present tools or give an error
  67 +description.
  68 +Note further that it is desired to modify the script for your needs. It is not
  69 +very complex and with some error and trial it will be possible to tailor it
  70 +exactly for your needs. In future there will be configuration files to make it
  71 +even more ease to configure the script for your situation. (I am thinking
  72 +about reqriting the script in c)
... ...
  1 +<?xml version="1.0" encoding="ISO-8859-15"?>
  2 +<xsl:stylesheet version="1.0"
  3 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4 +
  5 + <xsl:output method="text" indent="no" encoding="ISO-8859-15" />
  6 +
  7 + <xsl:template match="/">
  8 +outdir="../../../wav/<xsl:value-of select="/cdinfo/cd-artist"/>"
  9 +outdir="$outdir/<xsl:value-of select="/cdinfo/cd-title"/>"
  10 +mkdirhier &quot;$outdir&quot;
  11 + <xsl:apply-templates select="/cdinfo/track"/>
  12 + </xsl:template>
  13 +
  14 + <xsl:template match="track">
  15 +tracknum=`echo <xsl:value-of select="track-number"/> | \
  16 + awk &apos;{printf(&quot;%02d&quot;, $0)}&apos;`
  17 +title=&quot;<xsl:value-of select="track-title"/>&quot;
  18 +lame --decode &quot;$tracknum-$title.flac&quot; \
  19 + &quot;$outdir/$tracknum-$title.wav&quot;
  20 + </xsl:template>
  21 +</xsl:stylesheet>
... ...
  1 +This is another shell script that combines cdda2wav with various encoders.
  2 +
  3 +As I started this i was not pleased by any of the existent grabber/encoder
  4 +frontends. So I decided to create my own one. The goal was to rip and encode in
  5 +one step without creating any temporary .wav file and to have a simple command
  6 +with only a few easy arguments to control this command.
  7 +
  8 +Now getcd.sh is a not to complicated bash script that uses awk, sed, cdda2wav,
  9 +flac, lame, bladeenc, ogg/vorbis, cddb.pl (in a slightly patched version).
  10 +It encodes tracks from the cd to a spcifiable base directory without creating
  11 +any temporary files.
  12 +It creates subdirectorys basedir/[mp3|flac|ogg|wav]/artist/cd-title for the
  13 +corresponding encoding-method and save files with the name
  14 +trackno-tracktitle.[mp3|flac|ogg|wav] again corresponding to the used
  15 +encoding-method.
  16 +If one encodes a sampler-cd (cd with various artists) it is often so, that
  17 +the artist of the track is mentioned in the cddb-track-title. For this reason
  18 +one can specify a delimiting character and the order (artist or title first) to
  19 +split the cddb-track-info and generate correct id3tags or similar.
  20 +
  21 +Additional to the encoded files getcd.sh creates an file cdinfo.xml which
  22 +contains all essential information of the original CD. I have written also
  23 +some xslt files that can be used to create .xinf files for xcdroast and to
  24 +create .wav from .flac or .mp3. It is planned to create additional xslt files
  25 +to make html-information about the CD, create insert scripts for postgres and
  26 +or mysql (or other rdbs) and converter-scripts that use these xslt-files.
  27 +To use the xslt-files one needs an xslt-processor, like xsltproc from
  28 +libxml2 (thats the one i used)
  29 +
  30 +for help use getcd.sh -h
... ...
No preview for this file type
  1 +/* Achtung unter dos ist \n in wirklichkeit \r\n bei den meisten
  2 + Compilern, da funktioniert das natürlich nicht!!!! */
  3 +#include <stdio.h>
  4 +
  5 +int main(int argc, char* argv[]) {
  6 + int c=0;
  7 +
  8 + while(fread(&c, 1, 1, stdin)) {
  9 + putchar((c=='\r')?'\n':c);
  10 + fflush(stdout);
  11 + }
  12 +
  13 + return 0;
  14 +}
  15 +
... ...
  1 +usage: ./getcd.sh [-d delimiter [-o {t|a}]] [-t {m|f|o}] [-p path] [-e encoder] [-c cddb-entry] [-h]
  2 + -d : A single character delimiting trackname from
  3 + artistname with sampler cds
  4 +
  5 + -o : specifies if theres the track or the artist first
  6 + Must be:
  7 + t for titel first or
  8 + a for artist first
  9 + If there is none specified t is assumed
  10 + -t : you can specify either m for encoding to mp3
  11 + using lame, or f for making lossless encoding using flac,
  12 + or o for making ogg/vorbis, or w for uncompressed wav.
  13 + Omitting this results in encoding to flac.
  14 + mp3s will be placed under a subfolder mp3 and flacs
  15 + under a subfolder flac
  16 + -p : specifies the path to save the encoded data.
  17 + Defaults to the users home directory.
  18 + -e : specifies the mp3 encoder to use.
  19 + valid encoders are actually: lame,bladeenc
  20 + Defaults to lame.
  21 + -c : specifies the CDDB-Entry to use.
  22 + sometimes there is more than 1 entry for a cd in cddb.
  23 + Then you can specify wich one to use by this option.
  24 + You can checkout all entries using cddb.pl.
  25 + -h : Shows this help.
... ...
Please register or login to post a comment