17 changed files with 1572 additions and 0 deletions
-
BINCDDB_get-2.23.tar.gz
-
70CDDB_get-2.23p1.patch
-
BINCDDB_get-2.27.tar.gz
-
70CDDB_get-2.27p1.patch
-
451cddb.pl
-
40cdinfo2xinf.xsl
-
28flac2mp3.xsl
-
21flac2wav.xsl
-
344getcd.sh
-
350getcd.sh.neu
-
35getcd.xml
-
72install
-
21mp32wav.xsl
-
30readme
-
BINrton
-
15rton.c
-
25usage
@ -0,0 +1,70 @@ |
|||||
|
diff -Naur CDDB_get-2.23/CDDB_get.pm CDDB_get-2.23p1/CDDB_get.pm
|
||||
|
--- CDDB_get-2.23/CDDB_get.pm 2003-09-07 15:49:27.000000000 +0000
|
||||
|
+++ CDDB_get-2.23p1/CDDB_get.pm 2004-06-30 08:37:28.000000000 +0000
|
||||
|
@@ -261,6 +261,7 @@
|
||||
|
|
||||
|
my $input = $config->{input}; |
||||
|
my $multi = $config->{multi}; |
||||
|
+ my $entry = $config->{entry} if (defined($config->{entry}));
|
||||
|
$input = 0 if $multi; |
||||
|
|
||||
|
print STDERR Dumper($config) if $debug; |
||||
|
@@ -426,7 +427,14 @@
|
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
- push @to_get,@list;
|
||||
|
+ unless(defined($entry)) {
|
||||
|
+ push @to_get,@list;
|
||||
|
+ }
|
||||
|
+ else {
|
||||
|
+ if($entry-1 >= 0 && $entry-1 <= $#list) {
|
||||
|
+ push @to_get,$list[$entry-1];
|
||||
|
+ }
|
||||
|
+ }
|
||||
|
} |
||||
|
|
||||
|
my $i=0; |
||||
|
diff -Naur CDDB_get-2.23/cddb.pl CDDB_get-2.23p1/cddb.pl
|
||||
|
--- CDDB_get-2.23/cddb.pl 2003-08-16 19:01:49.000000000 +0000
|
||||
|
+++ CDDB_get-2.23p1/cddb.pl 2004-06-30 08:33:03.000000000 +0000
|
||||
|
@@ -27,12 +27,13 @@
|
||||
|
use strict; |
||||
|
|
||||
|
my %option = (); |
||||
|
-getopts("oghdtsiSfDlOFc:", \%option);
|
||||
|
+getopts("oghdtsiSfDlOFe:c:", \%option);
|
||||
|
|
||||
|
if($option{h}) { |
||||
|
print "$0: gets CDDB info of a CD\n"; |
||||
|
print " no argument - gets CDDB info of CD in your drive\n"; |
||||
|
print " -c device (other than default device)\n"; |
||||
|
+ print " -e which cddb-entry to use\n";
|
||||
|
print " -o offline mode - just stores CD info\n"; |
||||
|
print " -d output in xmcd format\n"; |
||||
|
print " -s save in xmcd format\n"; |
||||
|
@@ -81,11 +82,19 @@
|
||||
|
$config{CD_DEVICE}=$option{c} if $option{c}; |
||||
|
|
||||
|
# user interaction welcome? |
||||
|
-
|
||||
|
-$config{input}=1; # 1: ask user if more than one possibility
|
||||
|
- # 0: no user interaction
|
||||
|
-$config{multi}=0; # 1: do not ask user and get all of them
|
||||
|
- # 0: just the first one
|
||||
|
+if($option{e}) {
|
||||
|
+ $config{entry}=$option{e};
|
||||
|
+ $config{input}=0; # 1: ask user if more than one possibility
|
||||
|
+ # 0: no user interaction
|
||||
|
+ $config{multi}=0; # 1: do not ask user and get all of them
|
||||
|
+ # 0: just the first one
|
||||
|
+}
|
||||
|
+else {
|
||||
|
+ $config{input}=1; # 1: ask user if more than one possibility
|
||||
|
+ # 0: no user interaction
|
||||
|
+ $config{multi}=0; # 1: do not ask user and get all of them
|
||||
|
+ # 0: just the first one
|
||||
|
+}
|
||||
|
|
||||
|
my %db; |
||||
|
|
||||
@ -0,0 +1,70 @@ |
|||||
|
diff -Naur CDDB_get-2.27/CDDB_get.pm CDDB_get-2.27.patched/CDDB_get.pm
|
||||
|
--- CDDB_get-2.27/CDDB_get.pm 2006-01-01 20:52:54.000000000 +0100
|
||||
|
+++ CDDB_get-2.27.patched/CDDB_get.pm 2006-05-27 09:54:30.733131044 +0200
|
||||
|
@@ -262,6 +262,7 @@
|
||||
|
|
||||
|
my $input = $config->{input}; |
||||
|
my $multi = $config->{multi}; |
||||
|
+ my $entry = $config->{entry} if (defined($config->{entry}));
|
||||
|
$input = 0 if $multi; |
||||
|
|
||||
|
print STDERR Dumper($config) if $debug; |
||||
|
@@ -441,7 +442,14 @@
|
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
- push @to_get,@list;
|
||||
|
+ unless(defined($entry)) {
|
||||
|
+ push @to_get,@list;
|
||||
|
+ }
|
||||
|
+ else {
|
||||
|
+ if($entry-1 >= 0 && $entry-1 <= $#list) {
|
||||
|
+ push @to_get,$list[$entry-1];
|
||||
|
+ }
|
||||
|
+ }
|
||||
|
} |
||||
|
|
||||
|
my $i=0; |
||||
|
diff -Naur CDDB_get-2.27/cddb.pl CDDB_get-2.27.patched/cddb.pl
|
||||
|
--- CDDB_get-2.27/cddb.pl 2005-10-06 08:00:59.000000000 +0200
|
||||
|
+++ CDDB_get-2.27.patched/cddb.pl 2006-05-27 09:56:17.798156565 +0200
|
||||
|
@@ -27,12 +27,13 @@
|
||||
|
use strict; |
||||
|
|
||||
|
my %option = (); |
||||
|
-getopts("oghdtsi:SfDlOFc:H:CIRGP", \%option);
|
||||
|
+getopts("oghdtsi:SfDlOFe:c:H:CIRGP", \%option);
|
||||
|
|
||||
|
if($option{h}) { |
||||
|
print "$0: gets CDDB info of a CD\n"; |
||||
|
print " no argument - gets CDDB info of CD in your drive\n"; |
||||
|
print " -c device (other than default device)\n"; |
||||
|
+ print " -e which cddb-entry to use\n";
|
||||
|
print " -o offline mode - just stores CD info\n"; |
||||
|
print " -d output in xmcd format\n"; |
||||
|
print " -s save in xmcd format\n"; |
||||
|
@@ -110,11 +111,19 @@
|
||||
|
$config{CD_DEVICE}=$option{c} if $option{c}; |
||||
|
|
||||
|
# user interaction welcome? |
||||
|
-
|
||||
|
-$config{input}=1; # 1: ask user if more than one possibility
|
||||
|
- # 0: no user interaction
|
||||
|
-$config{multi}=0; # 1: do not ask user and get all of them
|
||||
|
- # 0: just the first one
|
||||
|
+if($option{e}) {
|
||||
|
+ $config{entry}=$option{e};
|
||||
|
+ $config{input}=0; # 1: ask user if more than one possibility
|
||||
|
+ # 0: no user interaction
|
||||
|
+ $config{multi}=0; # 1: do not ask user and get all of them
|
||||
|
+ # 0: just the first one
|
||||
|
+}
|
||||
|
+else {
|
||||
|
+ $config{input}=1; # 1: ask user if more than one possibility
|
||||
|
+ # 0: no user interaction
|
||||
|
+ $config{multi}=0; # 1: do not ask user and get all of them
|
||||
|
+ # 0: just the first one
|
||||
|
+}
|
||||
|
|
||||
|
$config{input}=0 if($option{I}); |
||||
|
|
||||
@ -0,0 +1,451 @@ |
|||||
|
#!/usr/bin/perl -I. |
||||
|
# |
||||
|
# CDDB - Read the CDDB entry for an audio CD in your drive |
||||
|
# |
||||
|
# This module/script gets the CDDB info for an audio cd. You need |
||||
|
# LINUX, a cdrom drive and an active internet connection in order |
||||
|
# to do that. |
||||
|
# |
||||
|
# (c) 2004 Armin Obersteiner <armin@xos.net> |
||||
|
# |
||||
|
# LICENSE |
||||
|
# |
||||
|
# This library is released under the same conditions as Perl, that |
||||
|
# is, either of the following: |
||||
|
# |
||||
|
# a) the GNU General Public License Version 2 as published by the |
||||
|
# Free Software Foundation, |
||||
|
# |
||||
|
# b) the Artistic License. |
||||
|
# |
||||
|
|
||||
|
#use CDDB_get qw( get_cddb get_discids ); |
||||
|
|
||||
|
use Data::Dumper; |
||||
|
use Getopt::Std; |
||||
|
|
||||
|
use strict; |
||||
|
|
||||
|
my %option = (); |
||||
|
getopts("oghdtsi:SfDlOFe:c:H:CIRGP", \%option); |
||||
|
|
||||
|
if($option{h}) { |
||||
|
print "$0: gets CDDB info of a CD\n"; |
||||
|
print " no argument - gets CDDB info of CD in your drive\n"; |
||||
|
print " -c device (other than default device)\n"; |
||||
|
print " -e which cddb-entry to use\n"; |
||||
|
print " -o offline mode - just stores CD info\n"; |
||||
|
print " -d output in xmcd format\n"; |
||||
|
print " -s save in xmcd format\n"; |
||||
|
print " -i db. one of: mysql, pg, oracle, sqlite\n"; |
||||
|
print " -O overwrite file or db\n"; |
||||
|
print " -t output toc\n"; |
||||
|
print " -l output lame command\n"; |
||||
|
print " -f http mode (e.g. through firewalls)\n"; |
||||
|
print " -F some stateful firewalls/http proxies need additional newlines\n"; |
||||
|
print " -g get CDDB info for stored CDs\n"; |
||||
|
print " -I non interactive mode\n"; |
||||
|
print " -H CDDB hostname\n"; |
||||
|
print " -C use local cache\n"; |
||||
|
print " -R readonly cache\n"; |
||||
|
print " -G cache has not the diskid as filenames (much slower)\n"; |
||||
|
print " -P cache path (default: /tmp/xmcd)\n"; |
||||
|
print " -D put CDDB_get in debug mode\n"; |
||||
|
exit; |
||||
|
} |
||||
|
|
||||
|
my %config; |
||||
|
|
||||
|
my $diskid; |
||||
|
my $total; |
||||
|
my $toc; |
||||
|
my $savedir="/tmp/cddb"; |
||||
|
my $xmcddir="/tmp/xmcd"; |
||||
|
|
||||
|
if($option{C}) { |
||||
|
# use CDDB_cache qw( get_cddb get_discids ); |
||||
|
require CDDB_cache; |
||||
|
CDDB_cache->import( qw( get_cddb get_discids ) ); |
||||
|
|
||||
|
$CDDB_cache::debug=1 if($option{D}); |
||||
|
$CDDB_cache::readonly=1 if($option{R}); |
||||
|
$CDDB_cache::grep=1 if($option{G}); |
||||
|
|
||||
|
$CDDB_cache::dir="/tmp/xmcd"; # default |
||||
|
# $CDDB_cache::dir="/opt/kde2/share/apps/kscd/cddb"; |
||||
|
$CDDB_cache::dir=$option{P} if($option{P}); |
||||
|
|
||||
|
} else { |
||||
|
# use CDDB_get qw( get_cddb get_discids ); |
||||
|
require CDDB_get; |
||||
|
CDDB_get->import( qw( get_cddb get_discids ) ); |
||||
|
} |
||||
|
|
||||
|
$CDDB_get::debug=1 if($option{D}); |
||||
|
|
||||
|
# following variables just need to be declared if different from defaults |
||||
|
# defaults are listed below (cdrom default is os specific) |
||||
|
|
||||
|
# $config{CDDB_HOST}="freedb.freedb.org"; # set cddb host |
||||
|
if($option{H}) { |
||||
|
$config{CDDB_HOST}=$option{H}; |
||||
|
} |
||||
|
# $config{CDDB_PORT}=8880; # set cddb port |
||||
|
# $config{CDDB_MODE}="cddb"; # set cddb mode: cddb or http, this is switched with -f |
||||
|
# $config{CD_DEVICE}="/dev/cdrom"; # set cd device |
||||
|
|
||||
|
# $config{HELLO_ID} ="root nowhere.com fastrip 0.77"; # hello string: username hostname clientname version |
||||
|
# $config{PROTO_VERSION} = 5; # cddb protokol version |
||||
|
|
||||
|
|
||||
|
# get proxy settings for cddb mode |
||||
|
|
||||
|
$config{HTTP_PROXY}=$ENV{http_proxy} if $ENV{http_proxy}; # maybe wanna use a proxy ? |
||||
|
|
||||
|
$config{CDDB_MODE}="http" if($option{f}); |
||||
|
if($option{F}) { |
||||
|
$config{CDDB_MODE}="http"; |
||||
|
$config{FW}=1; |
||||
|
} |
||||
|
|
||||
|
$config{CD_DEVICE}=$option{c} if $option{c}; |
||||
|
|
||||
|
# user interaction welcome? |
||||
|
if($option{e}) { |
||||
|
$config{entry}=$option{e}; |
||||
|
$config{input}=0; # 1: ask user if more than one possibility |
||||
|
# 0: no user interaction |
||||
|
$config{multi}=0; # 1: do not ask user and get all of them |
||||
|
# 0: just the first one |
||||
|
} |
||||
|
else { |
||||
|
$config{input}=1; # 1: ask user if more than one possibility |
||||
|
# 0: no user interaction |
||||
|
$config{multi}=0; # 1: do not ask user and get all of them |
||||
|
# 0: just the first one |
||||
|
} |
||||
|
|
||||
|
$config{input}=0 if($option{I}); |
||||
|
|
||||
|
my %db; |
||||
|
|
||||
|
if($option{i}) { |
||||
|
require DBI; |
||||
|
|
||||
|
$db{table_cds} = "cds"; |
||||
|
$db{table_tracks} = "tracks"; |
||||
|
|
||||
|
# not needed for sqlite |
||||
|
$db{host} = "localhost"; |
||||
|
$db{port} = "3306"; |
||||
|
|
||||
|
# not needed for oracle/sqlite |
||||
|
$db{name} = "mp3-test"; |
||||
|
|
||||
|
# just for oracle |
||||
|
$db{sid} = "xxx"; |
||||
|
$db{home} = "xxx"; |
||||
|
|
||||
|
# just for sqlite |
||||
|
$db{file} = "xxx"; |
||||
|
|
||||
|
# not needed for sqlite |
||||
|
$db{user} = "root"; |
||||
|
$db{passwd} = "xxx"; |
||||
|
|
||||
|
|
||||
|
if($option{i} eq "mysql") { |
||||
|
$db{connect} = sub { "dbi:mysql:database=$db{name};host=$db{host};port=$db{port}", $db{user}, $db{passwd} }; |
||||
|
} elsif($option{i} eq "pg") { |
||||
|
$db{connect} = sub { "dbi:Pg:dbname=$db{dbname};host=$db{host};port=$db{port}", $db{user}, $db{passwd} }; |
||||
|
} elsif($option{i} eq "oracle") { |
||||
|
$db{connect} = sub { "dbi:Oracle:host=$db{host};sid=$db{sid};port=$db{port}", $db{user}, $db{passwd} }; |
||||
|
$ENV{ORACLE_HOME} = $db{home}; |
||||
|
} elsif($option{i} eq "sqlite") { |
||||
|
$db{connect} = sub { "dbi:SQLite:dbname=$db{file}","","" }; |
||||
|
} else { |
||||
|
die "unkown database: $option{i}"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if($option{o}) { |
||||
|
my $ids=get_discids($config{CD_DEVICE}); |
||||
|
|
||||
|
unless(-e $savedir) { |
||||
|
mkdir $savedir,0755 or die "cannot create $savedir"; |
||||
|
} |
||||
|
|
||||
|
open OUT,">$savedir/$ids->[0]\_$$" or die "cannot open outfile"; |
||||
|
print OUT Data::Dumper->Dump($ids,["diskid","total","toc"]); |
||||
|
close OUT; |
||||
|
|
||||
|
print STDERR "saved in: $savedir/$ids->[0]\_$$\n"; |
||||
|
exit; |
||||
|
} |
||||
|
|
||||
|
if($option{g}) { |
||||
|
print STDERR "retrieving stored cds ...\n"; |
||||
|
|
||||
|
opendir(DIR, $savedir) or die "cannot opendir $savedir"; |
||||
|
while (defined(my $file = readdir(DIR))) { |
||||
|
next if($file =~ /^\./); |
||||
|
print "\n"; |
||||
|
|
||||
|
my $in=`/bin/cat $savedir/$file`; |
||||
|
my $exit = $? >> 8; |
||||
|
|
||||
|
if($exit>0) { |
||||
|
die "error reading file"; |
||||
|
} |
||||
|
|
||||
|
unless($in=~ m/^\$diskid\s+=\s+('\d+'|\d+);\s+ # $diskid |
||||
|
\$total\s+=\s+('\d+'|\d+);\s+ # $total |
||||
|
\$toc\s+=\s+\[\s+ # $toc |
||||
|
(\{\s+ |
||||
|
('(frame|frames|min|sec|data)'\s+=\>\s+('\d+'|\d+)(,|)\s+){5} |
||||
|
\}(,|)\s+)+ |
||||
|
\];\s+$/xs) { |
||||
|
print "not a save file: $savedir/$file\n"; |
||||
|
next; |
||||
|
} |
||||
|
|
||||
|
eval $in; |
||||
|
|
||||
|
if($@) { |
||||
|
print "not a save file (eval error): $savedir/$file\n"; |
||||
|
next; |
||||
|
} |
||||
|
|
||||
|
my %cd=get_cddb(\%config,[$diskid,$total,$toc]); |
||||
|
|
||||
|
unless(defined $cd{title}) { |
||||
|
print "no cddb entry found: $savedir/$file\n"; |
||||
|
} |
||||
|
|
||||
|
unlink "$savedir/$file"; |
||||
|
|
||||
|
next unless defined $cd{title}; |
||||
|
|
||||
|
if($option{d} || $option{s}) { |
||||
|
print_xmcd(\%cd,$option{s}); |
||||
|
} elsif($option{i}) { |
||||
|
insert_db(\%cd,\%db); |
||||
|
} elsif($option{l}) { |
||||
|
print_lame(\%cd); |
||||
|
} else { |
||||
|
print_cd(\%cd); |
||||
|
} |
||||
|
} |
||||
|
closedir(DIR); |
||||
|
exit; |
||||
|
} |
||||
|
|
||||
|
# get it on |
||||
|
|
||||
|
unless($config{multi}) { |
||||
|
my %cd; |
||||
|
|
||||
|
# for those who don't like 'die' in modules ;-) |
||||
|
eval { |
||||
|
%cd = get_cddb(\%config); |
||||
|
}; |
||||
|
if ($@) { |
||||
|
print "fatal error: $!\n"; |
||||
|
exit; |
||||
|
} |
||||
|
|
||||
|
print Dumper(\%cd) if $option{D}; |
||||
|
|
||||
|
unless(defined $cd{title}) { |
||||
|
die "no cddb entry found"; |
||||
|
} |
||||
|
|
||||
|
# do somthing with the results |
||||
|
|
||||
|
if($option{d} || $option{s}) { |
||||
|
print_xmcd(\%cd,$option{s}); |
||||
|
} elsif($option{i}) { |
||||
|
insert_db(\%cd,\%db); |
||||
|
} elsif($option{l}) { |
||||
|
print_lame(\%cd); |
||||
|
} else { |
||||
|
print_cd(\%cd); |
||||
|
} |
||||
|
} else { |
||||
|
my @cd; |
||||
|
|
||||
|
# for those who don't like 'die' in modules ;-) |
||||
|
eval { |
||||
|
@cd=get_cddb(\%config); |
||||
|
}; |
||||
|
if ($@) { |
||||
|
print "fatal error: $!\n"; |
||||
|
exit; |
||||
|
} |
||||
|
|
||||
|
print Dumper(\@cd) if $option{D}; |
||||
|
|
||||
|
for my $c (@cd) { |
||||
|
unless(defined $c->{title}) { |
||||
|
die "no cddb entry found"; |
||||
|
} |
||||
|
|
||||
|
# do somthing with the results |
||||
|
|
||||
|
if($option{d} || $option{s}) { |
||||
|
print_xmcd($c,$option{s}); |
||||
|
} elsif($option{i}) { |
||||
|
insert_db($c,\%db); |
||||
|
} elsif($option{l}) { |
||||
|
print_lame($c); |
||||
|
print "\n"; |
||||
|
} else { |
||||
|
print_cd($c); |
||||
|
print "\n"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
exit; |
||||
|
|
||||
|
|
||||
|
# subroutines |
||||
|
|
||||
|
sub print_cd { |
||||
|
my $cd=shift; |
||||
|
|
||||
|
print "artist: $cd->{artist}\n"; |
||||
|
print "title: $cd->{title}\n"; |
||||
|
print "category: $cd->{cat}\n"; |
||||
|
print "genre: $cd->{genre}\n" if($cd->{genre}); |
||||
|
print "year: $cd->{year}\n" if($cd->{year}); |
||||
|
print "cddbid: $cd->{id}\n"; |
||||
|
print "trackno: $cd->{tno}\n"; |
||||
|
|
||||
|
my $n=1; |
||||
|
foreach my $i ( @{$cd->{track}} ) { |
||||
|
if($option{t}) { |
||||
|
my $from=$cd->{frames}[$n-1]; |
||||
|
my $to=$cd->{frames}[$n]-1; |
||||
|
my $dur=$to-$from; |
||||
|
my $min=int($dur/75/60); |
||||
|
my $sec=int($dur/75)-$min*60; |
||||
|
my $frm=($dur-$sec*75-$min*75*60)*100/75; |
||||
|
my $out=sprintf "track %2d: %8d - %8d [%2d:%.2d.%.2d]: $i\n",$n,$from,$to,$min,$sec,$frm; |
||||
|
print "$out"; |
||||
|
} else { |
||||
|
print "track $n: $i\n"; |
||||
|
} |
||||
|
$n++; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
sub print_xmcd { |
||||
|
my $cd=shift; |
||||
|
my $save=shift; |
||||
|
|
||||
|
*OUT=*STDOUT; |
||||
|
|
||||
|
if($save) { |
||||
|
unless(-e $xmcddir) { |
||||
|
mkdir $xmcddir,0755 or die "cannot create $savedir"; |
||||
|
} |
||||
|
|
||||
|
unless($option{O}) { |
||||
|
if(-e "$xmcddir/$cd->{id}") { |
||||
|
print "XMCD file exists\n"; |
||||
|
exit; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
open XMCD,">$xmcddir/$cd->{id}" or die "cannot open outfile"; |
||||
|
*OUT=*XMCD; |
||||
|
} |
||||
|
|
||||
|
for(@{$cd->{raw}}) { |
||||
|
print OUT "$_"; |
||||
|
} |
||||
|
|
||||
|
if($save) { |
||||
|
print STDERR "saved in: $xmcddir/$cd->{id}\n"; |
||||
|
close OUT; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
sub insert_db { |
||||
|
my $cd=shift; |
||||
|
my $db=shift; |
||||
|
|
||||
|
my ($artist, $title, $category, $cddbid, $trackno) = |
||||
|
($cd->{artist}, $cd->{title}, $cd->{cat}, $cd->{id}, $cd->{tno}); |
||||
|
|
||||
|
my $sql = "SELECT cddbid FROM $db->{table_cds} WHERE CDDBID = \'$cddbid\'"; |
||||
|
my $dbh = DBI->connect($db->{connect}->()) or die "cannot connect to db: $DBI::errstr"; |
||||
|
my $sth = $dbh->prepare($sql); |
||||
|
my $r = $sth->execute or die "cannot check for cd: $DBI::errstr"; |
||||
|
if ($r == 1) { |
||||
|
print "cd already in db\n"; |
||||
|
if($option{O}) { |
||||
|
my $sql = "DELETE FROM $db->{table_cds} WHERE CDDBID = \'$cddbid\'"; |
||||
|
my $sth = $dbh->prepare($sql); |
||||
|
my $r = $sth->execute or die "cannot delete from $db->{table_cds}: $DBI::errstr"; |
||||
|
$sql = "DELETE FROM $db->{table_tracks} WHERE CDDBID = \'$cddbid\'"; |
||||
|
$sth = $dbh->prepare($sql); |
||||
|
$r = $sth->execute or die "cannot delete from $db->{table_tracks}: $DBI::errstr"; |
||||
|
} else { |
||||
|
exit; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$title =~ s/'/\\'/g; |
||||
|
$artist =~ s/'/\\'/g; |
||||
|
$category =~ s/'/\\'/g; |
||||
|
|
||||
|
$sql = "INSERT INTO $db->{table_cds} (cddbid, artist, title, category, tracks) VALUES (\'$cddbid\', \'$artist\', \'$title\', \'$category\' , \'$trackno\')"; |
||||
|
$sth = $dbh->prepare($sql); |
||||
|
$r = $sth->execute or die "failed to insert cd: $DBI::errstr"; |
||||
|
|
||||
|
my $n=1; |
||||
|
|
||||
|
print "titel: $title\n"; |
||||
|
print "artist: $artist\n"; |
||||
|
print "category: $category\n\n"; |
||||
|
|
||||
|
for my $t ( @{$cd->{track}} ) { |
||||
|
$t =~ s/'/\\'/g; |
||||
|
my $dur=($cd->{frames}[$n]-1-$cd->{frames}[$n-1])/75; |
||||
|
my $hour=int($dur/3600); |
||||
|
my $min=int($dur/60-$hour*60); |
||||
|
my $sec=$dur-$hour*3600-$min*60; |
||||
|
my $fr=substr(sprintf("%5.2f",$sec-int($sec)),2,3); |
||||
|
my $time=sprintf "%.2d:%.2d:%.2d%s",$hour,$min,int($sec),$fr; |
||||
|
|
||||
|
print "track $n: $t [$time]\n"; |
||||
|
|
||||
|
my $sql = "INSERT INTO $db->{table_tracks} (cddbid, title, trackno, time) |
||||
|
VALUES (\'$cddbid\',\'$t\', \'$n\', \'$time\')"; |
||||
|
my $sth = $dbh->prepare($sql); |
||||
|
my $r = $sth->execute or die "failed to insert track $n: $DBI::errstr"; |
||||
|
$n++; |
||||
|
} |
||||
|
|
||||
|
$dbh->disconnect(); |
||||
|
} |
||||
|
|
||||
|
sub print_lame { |
||||
|
my $cd=shift; |
||||
|
|
||||
|
print_cd($cd); |
||||
|
print "\n"; |
||||
|
|
||||
|
my $n=1; |
||||
|
for my $i ( @{$cd->{track}} ) { |
||||
|
$i =~ s/"/'/g; |
||||
|
print 'lame --tl "'.$cd->{title}.'" --ta "'.$cd->{artist}.'" --tt "'.$i.'" '; |
||||
|
printf "audio_%02d.wav ",$n; |
||||
|
$i =~ s/[^\S]|['"\/]/_/g; |
||||
|
$i =~ s/_+-_+/-/g; |
||||
|
print " $i.mp3\n"; |
||||
|
$n++; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
<?xml version="1.0" encoding="ISO-8859-15"?> |
||||
|
<xsl:stylesheet version="1.0" |
||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
|
|
||||
|
<xsl:output method="text" indent="no" encoding="ISO-8859-15" /> |
||||
|
|
||||
|
<xsl:template match="/"> |
||||
|
cddb=`echo <xsl:value-of select="/cdinfo/cddb"/> | sed 's/0x\(.*\)/\1/g'` |
||||
|
date=`date` |
||||
|
|
||||
|
<xsl:apply-templates select="/cdinfo/track"/> |
||||
|
</xsl:template> |
||||
|
|
||||
|
<xsl:template match="track"> |
||||
|
track="`echo <xsl:value-of select="track-number"/> | /usr/bin/awk '{printf("%02d", $0)}'`" |
||||
|
track="${track}-<xsl:value-of select="track-title"/>" |
||||
|
|
||||
|
cat > "${track}.xinf" <<- end |
||||
|
# |
||||
|
# X-CD-Roast 0.98alpha15 - INF-File |
||||
|
# created: $date |
||||
|
# by: getcd.sh |
||||
|
# |
||||
|
file = "./${track}.wav" |
||||
|
track = <xsl:value-of select="track-number"/> of <xsl:value-of select="/cdinfo/cd-tracks"/> |
||||
|
title = "<xsl:value-of select="track-title"/>" |
||||
|
artist = "<xsl:value-of select="track-artist"/>" |
||||
|
size = <xsl:value-of select="track-length"/> |
||||
|
type = 1 |
||||
|
rec_type = 0 |
||||
|
preemp = 0 |
||||
|
copyperm = 0 |
||||
|
stereo = 1 |
||||
|
# from CD: |
||||
|
cd_title = "<xsl:value-of select="/cdinfo/cd-title"/>" |
||||
|
cd_artist = "<xsl:value-of select="/cdinfo/cd-artist"/>" |
||||
|
cd_discid = "$cddb" |
||||
|
end |
||||
|
</xsl:template> |
||||
|
</xsl:stylesheet> |
||||
@ -0,0 +1,28 @@ |
|||||
|
<?xml version="1.0" encoding="ISO-8859-15"?> |
||||
|
<xsl:stylesheet version="1.0" |
||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
|
|
||||
|
<xsl:output method="text" indent="no" encoding="ISO-8859-15" /> |
||||
|
|
||||
|
<xsl:template match="/"> |
||||
|
outdir="../../../mp3/<xsl:value-of select="/cdinfo/cd-artist"/>" |
||||
|
outdir="$outdir/<xsl:value-of select="/cdinfo/cd-title"/>" |
||||
|
mkdirhier "$outdir" |
||||
|
<xsl:apply-templates select="/cdinfo/track"/> |
||||
|
</xsl:template> |
||||
|
|
||||
|
<xsl:template match="track"> |
||||
|
tracknum=`echo <xsl:value-of select="track-number"/> | \ |
||||
|
awk '{printf("%02d", $0)}'` |
||||
|
title="<xsl:value-of select="track-title"/>" |
||||
|
flac -d -o - "$tracknum-$title.flac" | \ |
||||
|
lame -h --ta "<xsl:value-of select="track-artist"/>" \ |
||||
|
--tl "<xsl:value-of select="/cdinfo/cd-title"/>" \ |
||||
|
--tg "<xsl:value-of select="/cdinfo/cd-genre"/>" \ |
||||
|
--tt "<xsl:value-of select="track-title"/>" \ |
||||
|
--tn "<xsl:value-of select="track-number"/>" \ |
||||
|
--ty "<xsl:value-of select="/cdinfo/cd-year"/>" \ |
||||
|
--tc "<xsl:value-of select="track-comment"/>" - \ |
||||
|
"$outdir/$tracknum-$title.mp3" |
||||
|
</xsl:template> |
||||
|
</xsl:stylesheet> |
||||
@ -0,0 +1,21 @@ |
|||||
|
<?xml version="1.0" encoding="ISO-8859-15"?> |
||||
|
<xsl:stylesheet version="1.0" |
||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
|
|
||||
|
<xsl:output method="text" indent="no" encoding="ISO-8859-15" /> |
||||
|
|
||||
|
<xsl:template match="/"> |
||||
|
outdir="../../../wav/<xsl:value-of select="/cdinfo/cd-artist"/>" |
||||
|
outdir="$outdir/<xsl:value-of select="/cdinfo/cd-title"/>" |
||||
|
mkdirhier "$outdir" |
||||
|
<xsl:apply-templates select="/cdinfo/track"/> |
||||
|
</xsl:template> |
||||
|
|
||||
|
<xsl:template match="track"> |
||||
|
tracknum=`echo <xsl:value-of select="track-number"/> | \ |
||||
|
awk '{printf("%02d", $0)}'` |
||||
|
title="<xsl:value-of select="track-title"/>" |
||||
|
flac -d -o "$outdir/$tracknum-$title.wav" \ |
||||
|
"$tracknum-$title.flac" |
||||
|
</xsl:template> |
||||
|
</xsl:stylesheet> |
||||
@ -0,0 +1,344 @@ |
|||||
|
USAGE="usage: $0 [-d delimiter [-o {t|a}]] [-t {m|f|o}] [-p path] [-e encoder] [-c cddb-entry] [-h]\n" |
||||
|
USAGE="${USAGE} -d :\tA single character delimiting trackname from\n" |
||||
|
USAGE="${USAGE}\tartistname with sampler cds\n\n" |
||||
|
USAGE="${USAGE} -o :\tspecifies if theres the track or the artist first\n" |
||||
|
USAGE="${USAGE}\tMust be:\n" |
||||
|
USAGE="${USAGE}\t t for titel first or\n" |
||||
|
USAGE="${USAGE}\t a for artist first\n" |
||||
|
USAGE="${USAGE}\tIf there is none specified t is assumed\n" |
||||
|
USAGE="${USAGE} -t :\tyou can specify either m for encoding to mp3\n" |
||||
|
USAGE="${USAGE}\tusing lame, or f for making lossless encoding using flac,\n" |
||||
|
USAGE="${USAGE}\tor o for making ogg/vorbis, or w for uncompressed wav.\n" |
||||
|
USAGE="${USAGE}\tOmitting this results in encoding to flac.\n" |
||||
|
USAGE="${USAGE}\tmp3s will be placed under a subfolder mp3 and flacs\n" |
||||
|
USAGE="${USAGE}\tunder a subfolder flac\n" |
||||
|
USAGE="${USAGE} -p :\tspecifies the path to save the encoded data.\n" |
||||
|
USAGE="${USAGE}\tDefaults to the users home directory.\n" |
||||
|
USAGE="${USAGE} -e :\tspecifies the mp3 encoder to use.\n" |
||||
|
USAGE="${USAGE}\tvalid encoders are actually: lame,bladeenc\n" |
||||
|
USAGE="${USAGE}\tDefaults to lame.\n" |
||||
|
USAGE="${USAGE} -c :\tspecifies the CDDB-Entry to use.\n" |
||||
|
USAGE="${USAGE}\tsometimes there is more than 1 entry for a cd in cddb.\n" |
||||
|
USAGE="${USAGE}\tThen you can specify wich one to use by this option.\n" |
||||
|
USAGE="${USAGE}\tYou can checkout all entries using cddb.pl.\n" |
||||
|
USAGE="${USAGE} -h :\tShows this help." |
||||
|
|
||||
|
HAS_DELIMITER=0 |
||||
|
TA_ORDER="t" |
||||
|
ENCODING_DIR=$HOME |
||||
|
ENCODING_TYPE="f" |
||||
|
ENCODER="lame" |
||||
|
CDDB_ENTRY=1 |
||||
|
|
||||
|
while getopts d:o:t:p:he:c: option |
||||
|
do |
||||
|
case $option in |
||||
|
d) if [ ${#OPTARG} -gt 1 ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
HAS_DELIMITER=1 |
||||
|
TA_DELIMITER=$OPTARG |
||||
|
;; |
||||
|
o) if [ \( "${OPTARG}" != "t" -a "${OPTARG}" != "a" \) -o \ |
||||
|
${HAS_DELIMITER} -eq 0 ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
TA_ORDER=$OPTARG |
||||
|
;; |
||||
|
t) if [ ${OPTARG} != "m" -a ${OPTARG} != "f" -a ${OPTARG} != "o" -a \ |
||||
|
${OPTARG} != "w" ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
ENCODING_TYPE=$OPTARG |
||||
|
;; |
||||
|
p) if [ ! \( -d ${OPTARG} \) ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
ENCODING_DIR=$OPTARG |
||||
|
;; |
||||
|
e) if [ -z ${OPTARG} ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
ENCODER=$OPTARG |
||||
|
;; |
||||
|
c) if [ ${OPTARG} -lt 1 ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
CDDB_ENTRY=$OPTARG |
||||
|
;; |
||||
|
[h\?]) echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
;; |
||||
|
esac |
||||
|
done |
||||
|
|
||||
|
test "$ENCODING_TYPE" = "m" && ENCODING_DIR="$ENCODING_DIR/mp3" |
||||
|
test "$ENCODING_TYPE" = "f" && ENCODING_DIR="$ENCODING_DIR/flac" |
||||
|
test "$ENCODING_TYPE" = "o" && ENCODING_DIR="$ENCODING_DIR/ogg" |
||||
|
test "$ENCODING_TYPE" = "w" && ENCODING_DIR="$ENCODING_DIR/wav" |
||||
|
|
||||
|
indices[0]="album" |
||||
|
indices[1]="artist" |
||||
|
indices[2]="genre" |
||||
|
indices[3]="year" |
||||
|
indices[4]="comment" |
||||
|
|
||||
|
i=1 |
||||
|
max_track=30 |
||||
|
|
||||
|
while [ $i -le $max_track ]; do |
||||
|
indices[`expr \( $i \- 1 \) \* 2 \+ 5`]="`echo $i | \ |
||||
|
sed 's/^\([0-9]\)$/0\1/g;\ |
||||
|
s/\(.*\)/track-\1/g'`" |
||||
|
indices[`expr \( $i \- 1 \) \* 2 \+ 6`]="`echo $i | \ |
||||
|
sed 's/^\([0-9]\)$/0\1/g;\ |
||||
|
s/\(.*\)/tartist-\1/g'`" |
||||
|
i=`expr $i \+ 1` |
||||
|
done |
||||
|
|
||||
|
comment="" |
||||
|
|
||||
|
function idxof() { |
||||
|
str=$1 |
||||
|
idx=0 |
||||
|
|
||||
|
for i in "${indices[@]}"; do |
||||
|
test "$i" == "$str" && echo $idx && return 0 |
||||
|
idx=`expr $idx \+ 1` |
||||
|
done |
||||
|
|
||||
|
echo -1 |
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
title_pat="/^[^:]*: *(.*[^ ]).*/" |
||||
|
artist_pat="//" |
||||
|
|
||||
|
if [ $HAS_DELIMITER -ne 0 ] |
||||
|
then |
||||
|
if [ $TA_ORDER == "t" ] |
||||
|
then |
||||
|
title_pat="/^[^:]*: *([^\\${TA_DELIMITER}]*[^ \\${TA_DELIMITER}]).*/" |
||||
|
artist_pat="/^[^:]*: *[^\\${TA_DELIMITER}]*\\${TA_DELIMITER} *(.*[^ ]).*/" |
||||
|
else |
||||
|
artist_pat="/^[^:]*: *([^\\${TA_DELIMITER}]*[^ \\${TA_DELIMITER}]).*/" |
||||
|
title_pat="/^[^:]*: *[^\\${TA_DELIMITER}]*\\${TA_DELIMITER} *(.*[^ ]).*/" |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
echo "Preparing...." |
||||
|
|
||||
|
echo -n "getting cddb info..." |
||||
|
eval "`cddb.pl -e $CDDB_ENTRY | sed 's/ \([0-9]\):/ 0\1:/g;s/track /track-/g' |\ |
||||
|
awk -v has_delimiter=$HAS_DELIMITER \ |
||||
|
'/artist/||/title/||/genre/||/year/ { \ |
||||
|
cddb[gensub(/^([^:]*):.*/, \"\\\\1\", \"1\")]=\ |
||||
|
gensub(/^[^:]*: *(.*[^ ]).*/, \"\\\\1\", \"g\")\ |
||||
|
} \ |
||||
|
/trackno/ {\ |
||||
|
trackno=int(gensub(/^trackno: *([0-9]*).*/, \"\\\\1\", \"1\"))\ |
||||
|
}\ |
||||
|
/track-/ {\ |
||||
|
cddb[gensub(/^([^:]*):.*/, \"\\\\1\", \"1\")]=\ |
||||
|
gensub('\"$title_pat\"', \"\\\\1\", \"1\");\ |
||||
|
if(has_delimiter==0) \ |
||||
|
cddb[gensub(/^track([^:]*):.*/, \"tarti\\\\1\", \"1\")]=\ |
||||
|
cddb[\"artist\"]; \ |
||||
|
else \ |
||||
|
cddb[gensub(/^track([^:]*):.*/, \"tarti\\\\1\", \"1\")]=\ |
||||
|
gensub('\"$artist_pat\"', \"\\\\1\", \"1\");\ |
||||
|
} \ |
||||
|
END {\ |
||||
|
cddb_str=\"cddb=(\\\"\" cddb[\"title\"] \"\\\" \\\"\" \ |
||||
|
cddb[\"artist\"] \"\\\" \\\"\" \ |
||||
|
cddb[\"genre\"] \"\\\" \\\"\" \ |
||||
|
cddb[\"year\"] \"\\\" \\\"'$comment'\\\"\"; \ |
||||
|
for(i=1; i<=trackno; i++) {\ |
||||
|
cddb_str=cddb_str \" \\\"\" \ |
||||
|
cddb[\"track-\" sprintf(\"%02s\", i)] \"\\\"\";\ |
||||
|
cddb_str=cddb_str \" \\\"\" \ |
||||
|
cddb[\"tarti-\" sprintf(\"%02s\", i)] \"\\\"\"\ |
||||
|
}\ |
||||
|
print cddb_str \")\"\ |
||||
|
}'`" |
||||
|
echo "done" |
||||
|
|
||||
|
echo -n "getting CD info..." |
||||
|
cddainfo=`cdda2wav -H -D/dev/cdrom -J -v summary,toc,sectors 2>&1` |
||||
|
echo "done" |
||||
|
|
||||
|
track_num=`echo "$cddainfo" | \ |
||||
|
sed '/tracks/{s/^.*tracks:\([0-9]*\).*$/\1/g;p};d'` |
||||
|
cd_time=`echo "$cddainfo" | \ |
||||
|
sed '/tracks/{s/^.*time \([0-9:\.]*\).*$/\1/g;p};d'` |
||||
|
cddbid=`echo "$cddainfo" | \ |
||||
|
sed '/CDDB/{s/^.*discid: *\(0x[a-z0-9]*[^ ]\).*/\1/g;p};d'` |
||||
|
cdindex=`echo "$cddainfo" | \ |
||||
|
sed '/CDINDEX/{s/^.*discid: *\([a-zA-Z0-9_\.]*-\).*/\1/g;p};d'` |
||||
|
cdtext=`echo "$cddainfo" | sed '/CD-Text/{s/^[^:]*: *\(.*[^ ]\).*/\1/g |
||||
|
s/&/\&\;/g;s/\"/\"\;/g |
||||
|
s/</\<\;/g;s/>/\>\;/g |
||||
|
s/\o47/\&apos\;/g |
||||
|
p};d'` |
||||
|
cdextra=`echo "$cddainfo" | sed '/CD-Extra/{s/^[^:]*: *\(.*[^ ]\).*/\1/g |
||||
|
s/&/\&\;/g;s/\"/\"\;/g |
||||
|
s/</\<\;/g;s/>/\>\;/g |
||||
|
s/\o47/\&apos\;/g |
||||
|
p};d'` |
||||
|
|
||||
|
ENCODING_DIR="${ENCODING_DIR}/${cddb[`idxof "artist"`]}/" |
||||
|
ENCODING_DIR="${ENCODING_DIR}${cddb[`idxof "album"`]}/" |
||||
|
mkdirhier "$ENCODING_DIR" |
||||
|
echo "Output directory is: $ENCODING_DIR" |
||||
|
|
||||
|
xmlfile="${ENCODING_DIR}cdinfo.xml" |
||||
|
|
||||
|
# some special chars within xml must be converted to special syntax |
||||
|
# & => & |
||||
|
# " => " |
||||
|
# ' => ' |
||||
|
# < => < |
||||
|
# > => > |
||||
|
xmlartist=`echo ${cddb[\`idxof "artist"\`]} | \ |
||||
|
sed 's/&/\&\;/g |
||||
|
s/</\<\;/g |
||||
|
s/>/\>\;/g |
||||
|
s/\"/\"\;/g |
||||
|
s/\o47/\&apos\;/g'` |
||||
|
xmlalbum=`echo ${cddb[\`idxof "album"\`]} | \ |
||||
|
sed 's/&/\&\;/g |
||||
|
s/</\<\;/g |
||||
|
s/>/\>\;/g |
||||
|
s/\"/\"\;/g |
||||
|
s/\o47/\&apos\;/g'` |
||||
|
|
||||
|
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>" > "${xmlfile}" |
||||
|
echo "<!DOCTYPE cdInfo SYSTEM \"cdInfo.dtd\">" >> "${xmlfile}" |
||||
|
echo "<cdinfo>" >> "${xmlfile}" |
||||
|
echo " <cdindex>$cdindex</cdindex>" >> "${xmlfile}" |
||||
|
echo " <cddb>$cddbid</cddb>" >> "${xmlfile}" |
||||
|
echo " <cd-text>$cdtext</cd-text>" >> "${xmlfile}" |
||||
|
echo " <cd-extra>$cdextra</cd-extra>" >> "${xmlfile}" |
||||
|
echo " <cd-artist>${xmlartist}</cd-artist>" >> "${xmlfile}" |
||||
|
echo " <cd-title>${xmlalbum}</cd-title>" >> "${xmlfile}" |
||||
|
echo " <cd-year>${cddb[`idxof "year"`]}</cd-year>" >> "${xmlfile}" |
||||
|
echo " <cd-genre>${cddb[`idxof "genre"`]}</cd-genre>" >> "${xmlfile}" |
||||
|
echo " <cd-time>$cd_time</cd-time>" >> "${xmlfile}" |
||||
|
echo " <cd-tracks>$track_num</cd-tracks>" >> "${xmlfile}" |
||||
|
echo " <cd-comment></cd-comment>" >> "${xmlfile}" |
||||
|
|
||||
|
i=1; while [ $i -le $track_num ] |
||||
|
do |
||||
|
j=`expr $i \+ 1` |
||||
|
tracknr=`awk 'BEGIN{printf("%02d\n",'$i')}'` |
||||
|
track=${cddb[`idxof "track-$tracknr"`]} |
||||
|
tartist=${cddb[`idxof "tartist-$tracknr"`]} |
||||
|
|
||||
|
xmltrack=`echo ${track} | sed 's/&/\&\;/g |
||||
|
s/</\<\;/g |
||||
|
s/>/\>\;/g |
||||
|
s/\"/\"\;/g |
||||
|
s/\o47/\&apos\;/g'` |
||||
|
xmltartist=`echo ${tartist} | sed 's/&/\&\;/g |
||||
|
s/</\<\;/g |
||||
|
s/>/\>\;/g |
||||
|
s/\"/\"\;/g |
||||
|
s/\o47/\&apos\;/g'` |
||||
|
|
||||
|
tracklen=`echo "$cddainfo" | \ |
||||
|
sed '/ '"$i"'\.([0-9 ]*:/{s/.*'"$i"'\.( *\([0-9:\.]*\)).*/\1/g;p};d'` |
||||
|
trackstart=`echo "$cddainfo" | \ |
||||
|
sed '/ '"$i"'\.([0-9 ]*)/{s/.*'"$i"'\.( *\([0-9]*\)).*/\1/g;p};d'` |
||||
|
test $i -eq $track_num && \ |
||||
|
trackend=`echo "$cddainfo" | \ |
||||
|
sed '/ lead-out([0-9 ]*)/{s/.*lead-out( *\([0-9]*\)).*/\1/g;p};d'` || \ |
||||
|
trackend=`echo "$cddainfo" | \ |
||||
|
sed '/ '"$j"'\.([0-9 ]*)/{s/.*'"$j"'\.( *\([0-9]*\)).*/\1/g;p};d'` |
||||
|
|
||||
|
echo " <track>" >> "${xmlfile}" |
||||
|
echo " <track-number>$i</track-number>" >> "${xmlfile}" |
||||
|
echo " <track-time>$tracklen</track-time>" >> "${xmlfile}" |
||||
|
echo " <track-start-sector>$trackstart</track-start-sector>" >> "${xmlfile}" |
||||
|
echo " <track-length>`expr $trackend \- $trackstart`</track-length>" >> "${xmlfile}" |
||||
|
echo " <track-artist>$xmltartist</track-artist>" >> "${xmlfile}" |
||||
|
echo " <track-title>$xmltrack</track-title>" >> "${xmlfile}" |
||||
|
echo " <track-comment></track-comment>" >> "${xmlfile}" |
||||
|
echo " </track>" >> "${xmlfile}" |
||||
|
|
||||
|
# outfile="${ENCODING_DIR}The Wall/Disk2/" |
||||
|
outfile="${ENCODING_DIR}${tracknr}-${track}" |
||||
|
|
||||
|
test "$ENCODING_TYPE" = "f" && \ |
||||
|
outstr="track-$tracknr => ${tracknr}-${track}.flac" |
||||
|
test "$ENCODING_TYPE" = "m" && \ |
||||
|
outstr="track-$tracknr => ${tracknr}-${track}.mp3" |
||||
|
test "$ENCODING_TYPE" = "o" && \ |
||||
|
outstr="track-$tracknr => ${tracknr}-${track}.ogg" |
||||
|
test "$ENCODING_TYPE" = "w" && \ |
||||
|
outstr="track-$tracknr => ${tracknr}-${track}.wav" |
||||
|
|
||||
|
if [ "$ENCODING_TYPE" = "f" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D/dev/cdrom -H -t$i - | \ |
||||
|
flac -c \ |
||||
|
-T artist=\"${tartist}\" -T album=\"${cddb[`idxof "album"`]}\" \ |
||||
|
-T genre=\"${cddb[`idxof "genre"`]}\" -T title=\"${track}\" \ |
||||
|
-T tnum=\"`expr ${tracknr} \+ 0`\" -T date=\"${cddb[`idxof "year"`]}\" \ |
||||
|
-T comment=\"${cddb[`idxof "comment"`]}\" \ |
||||
|
-o \"${outfile}.flac\" - 2>/dev/null" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
if [ "$ENCODING_TYPE" = "m" -a "$ENCODER" = "lame" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D/dev/cdrom -t$i - | \ |
||||
|
lame -h \ |
||||
|
--ta \"${tartist}\" --tl \"${cddb[`idxof "album"`]}\" \ |
||||
|
--tg \"${cddb[`idxof "genre"`]}\" --tt \"${track}\" \ |
||||
|
--tn \"`expr ${tracknr} \+ 0`\" --ty \"${cddb[`idxof "year"`]}\" \ |
||||
|
--tc \"${cddb[`idxof "comment"`]}\" \ |
||||
|
- \"${outfile}.mp3\" 2>/dev/null" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
if [ "$ENCODING_TYPE" = "m" -a "$ENCODER" = "bladeenc" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D/dev/cdrom -t$i - | \ |
||||
|
bladeenc -progress=0 STDIN \"${outfile}.mp3\" 2>/dev/null" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
if [ "$ENCODING_TYPE" = "o" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D/dev/cdrom -t$i - | \ |
||||
|
oggenc -a \"${tartist}\" -l \"${cddb[`idxof "album"`]}\" \ |
||||
|
-G \"${cddb[`idxof "genre"`]}\" -t \"${track}\" \ |
||||
|
-N \"`expr ${tracknr} \+ 0`\" -d \"${cddb[`idxof "year"`]}\" \ |
||||
|
-c \"${cddb[`idxof "comment"`]}\" \ |
||||
|
-o \"${outfile}.ogg\" - 2>/dev/null" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
if [ "$ENCODING_TYPE" = "w" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D/dev/cdrom -t$i - > \"${outfile}.wav\"" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
|
||||
|
i=`expr $i + 1` |
||||
|
done |
||||
|
|
||||
|
echo "</cdinfo>" >> "${xmlfile}" |
||||
@ -0,0 +1,350 @@ |
|||||
|
USAGE="usage: $0 [-d delimiter [-o {t|a}]] [-t {m|f|o}] [-p path] [-e encoder] [-c cddb-entry] [-h]\n" |
||||
|
USAGE="${USAGE} -d :\tA single character delimiting trackname from\n" |
||||
|
USAGE="${USAGE}\tartistname with sampler cds\n\n" |
||||
|
USAGE="${USAGE} -o :\tspecifies if theres the track or the artist first\n" |
||||
|
USAGE="${USAGE}\tMust be:\n" |
||||
|
USAGE="${USAGE}\t t for titel first or\n" |
||||
|
USAGE="${USAGE}\t a for artist first\n" |
||||
|
USAGE="${USAGE}\tIf there is none specified t is assumed\n" |
||||
|
USAGE="${USAGE} -t :\tyou can specify either m for encoding to mp3\n" |
||||
|
USAGE="${USAGE}\tusing lame, or f for making lossless encoding using flac,\n" |
||||
|
USAGE="${USAGE}\tor o for making ogg/vorbis, or w for uncompressed wav.\n" |
||||
|
USAGE="${USAGE}\tOmitting this results in encoding to flac.\n" |
||||
|
USAGE="${USAGE}\tmp3s will be placed under a subfolder mp3 and flacs\n" |
||||
|
USAGE="${USAGE}\tunder a subfolder flac\n" |
||||
|
USAGE="${USAGE} -p :\tspecifies the path to save the encoded data.\n" |
||||
|
USAGE="${USAGE}\tDefaults to the users home directory.\n" |
||||
|
USAGE="${USAGE} -e :\tspecifies the mp3 encoder to use.\n" |
||||
|
USAGE="${USAGE}\tvalid encoders are actually: lame,bladeenc\n" |
||||
|
USAGE="${USAGE}\tDefaults to lame.\n" |
||||
|
USAGE="${USAGE} -c :\tspecifies the CDDB-Entry to use.\n" |
||||
|
USAGE="${USAGE}\tsometimes there is more than 1 entry for a cd in cddb.\n" |
||||
|
USAGE="${USAGE}\tThen you can specify wich one to use by this option.\n" |
||||
|
USAGE="${USAGE}\tYou can checkout all entries using cddb.pl.\n" |
||||
|
USAGE="${USAGE} -h :\tShows this help." |
||||
|
|
||||
|
PATH="$PATH:." |
||||
|
|
||||
|
HAS_DELIMITER=0 |
||||
|
TA_ORDER="t" |
||||
|
ENCODING_DIR=$HOME |
||||
|
ENCODING_TYPE="f" |
||||
|
ENCODER="lame" |
||||
|
CDDB_ENTRY=1 |
||||
|
|
||||
|
while getopts d:o:t:p:he:c: option |
||||
|
do |
||||
|
case $option in |
||||
|
d) if [ ${#OPTARG} -gt 1 ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
HAS_DELIMITER=1 |
||||
|
TA_DELIMITER=$OPTARG |
||||
|
;; |
||||
|
o) if [ \( "${OPTARG}" != "t" -a "${OPTARG}" != "a" \) -o \ |
||||
|
${HAS_DELIMITER} -eq 0 ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
TA_ORDER=$OPTARG |
||||
|
;; |
||||
|
t) if [ ${OPTARG} != "m" -a ${OPTARG} != "f" -a ${OPTARG} != "o" -a \ |
||||
|
${OPTARG} != "w" ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
ENCODING_TYPE=$OPTARG |
||||
|
;; |
||||
|
p) if [ ! \( -d ${OPTARG} \) ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
ENCODING_DIR=$OPTARG |
||||
|
;; |
||||
|
e) if [ -z ${OPTARG} ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
ENCODER=$OPTARG |
||||
|
;; |
||||
|
c) if [ ${OPTARG} -lt 1 ] |
||||
|
then |
||||
|
echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
fi |
||||
|
CDDB_ENTRY=$OPTARG |
||||
|
;; |
||||
|
[h\?]) echo -e "$USAGE" |
||||
|
exit 1 |
||||
|
;; |
||||
|
esac |
||||
|
done |
||||
|
|
||||
|
test "$ENCODING_TYPE" = "m" && ENCODING_DIR="$ENCODING_DIR/mp3" |
||||
|
test "$ENCODING_TYPE" = "f" && ENCODING_DIR="$ENCODING_DIR/flac" |
||||
|
test "$ENCODING_TYPE" = "o" && ENCODING_DIR="$ENCODING_DIR/ogg" |
||||
|
test "$ENCODING_TYPE" = "w" && ENCODING_DIR="$ENCODING_DIR/wav" |
||||
|
|
||||
|
indices[0]="album" |
||||
|
indices[1]="artist" |
||||
|
indices[2]="genre" |
||||
|
indices[3]="year" |
||||
|
indices[4]="comment" |
||||
|
|
||||
|
i=1 |
||||
|
max_track=30 |
||||
|
|
||||
|
while [ $i -le $max_track ]; do |
||||
|
indices[`expr \( $i \- 1 \) \* 2 \+ 5`]="`echo $i | \ |
||||
|
sed 's/^\([0-9]\)$/0\1/g;\ |
||||
|
s/\(.*\)/track-\1/g'`" |
||||
|
indices[`expr \( $i \- 1 \) \* 2 \+ 6`]="`echo $i | \ |
||||
|
sed 's/^\([0-9]\)$/0\1/g;\ |
||||
|
s/\(.*\)/tartist-\1/g'`" |
||||
|
i=`expr $i \+ 1` |
||||
|
done |
||||
|
|
||||
|
comment="" |
||||
|
|
||||
|
function idxof() { |
||||
|
str=$1 |
||||
|
idx=0 |
||||
|
|
||||
|
for i in "${indices[@]}"; do |
||||
|
test "$i" == "$str" && echo $idx && return 0 |
||||
|
idx=`expr $idx \+ 1` |
||||
|
done |
||||
|
|
||||
|
echo -1 |
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
title_pat="/^[^:]*: *(.*[^ ]).*/" |
||||
|
artist_pat="//" |
||||
|
|
||||
|
if [ $HAS_DELIMITER -ne 0 ] |
||||
|
then |
||||
|
if [ $TA_ORDER == "t" ] |
||||
|
then |
||||
|
title_pat="/^[^:]*: *([^\\${TA_DELIMITER}]*[^ \\${TA_DELIMITER}]).*/" |
||||
|
artist_pat="/^[^:]*: *[^\\${TA_DELIMITER}]*\\${TA_DELIMITER} *(.*[^ ]).*/" |
||||
|
else |
||||
|
artist_pat="/^[^:]*: *([^\\${TA_DELIMITER}]*[^ \\${TA_DELIMITER}]).*/" |
||||
|
title_pat="/^[^:]*: *[^\\${TA_DELIMITER}]*\\${TA_DELIMITER} *(.*[^ ]).*/" |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
echo "Preparing...." |
||||
|
|
||||
|
echo -n "getting cddb info..." |
||||
|
eval "`cddb.pl -c /dev/cdrom1 -e $CDDB_ENTRY | sed 's/ \([0-9]\):/ 0\1:/g;s/track /track-/g' |\ |
||||
|
awk -v has_delimiter=$HAS_DELIMITER \ |
||||
|
'/artist/||/title/||/genre/||/year/ { \ |
||||
|
cddb[gensub(/^([^:]*):.*/, \"\\\\1\", \"1\")]=\ |
||||
|
gensub(/^[^:]*: *(.*[^ ]).*/, \"\\\\1\", \"g\")\ |
||||
|
} \ |
||||
|
/trackno/ {\ |
||||
|
trackno=int(gensub(/^trackno: *([0-9]*).*/, \"\\\\1\", \"1\"))\ |
||||
|
}\ |
||||
|
/track-/ {\ |
||||
|
cddb[gensub(/^([^:]*):.*/, \"\\\\1\", \"1\")]=\ |
||||
|
gensub('\"$title_pat\"', \"\\\\1\", \"1\");\ |
||||
|
if(has_delimiter==0) \ |
||||
|
cddb[gensub(/^track([^:]*):.*/, \"tarti\\\\1\", \"1\")]=\ |
||||
|
cddb[\"artist\"]; \ |
||||
|
else \ |
||||
|
cddb[gensub(/^track([^:]*):.*/, \"tarti\\\\1\", \"1\")]=\ |
||||
|
gensub('\"$artist_pat\"', \"\\\\1\", \"1\");\ |
||||
|
} \ |
||||
|
END {\ |
||||
|
cddb_str=\"cddb=(\\\"\" cddb[\"title\"] \"\\\" \\\"\" \ |
||||
|
cddb[\"artist\"] \"\\\" \\\"\" \ |
||||
|
cddb[\"genre\"] \"\\\" \\\"\" \ |
||||
|
cddb[\"year\"] \"\\\" \\\"'$comment'\\\"\"; \ |
||||
|
for(i=1; i<=trackno; i++) {\ |
||||
|
cddb_str=cddb_str \" \\\"\" \ |
||||
|
cddb[\"track-\" sprintf(\"%02s\", i)] \"\\\"\";\ |
||||
|
cddb_str=cddb_str \" \\\"\" \ |
||||
|
cddb[\"tarti-\" sprintf(\"%02s\", i)] \"\\\"\"\ |
||||
|
}\ |
||||
|
print cddb_str \")\"\ |
||||
|
}'`" |
||||
|
echo "done" |
||||
|
|
||||
|
echo -n "getting CD info..." |
||||
|
cddainfo=`cdda2wav -H -D/dev/cdrom1 -J -v summary,toc,sectors 2>&1` |
||||
|
echo "done" |
||||
|
|
||||
|
track_num=`echo "$cddainfo" | \ |
||||
|
sed '/tracks/{s/^.*tracks:\([0-9]*\).*$/\1/g;p};d'` |
||||
|
cd_time=`echo "$cddainfo" | \ |
||||
|
sed '/tracks/{s/^.*time \([0-9:\.]*\).*$/\1/g;p};d'` |
||||
|
cddbid=`echo "$cddainfo" | \ |
||||
|
sed '/CDDB/{s/^.*discid: *\(0x[a-z0-9]*[^ ]\).*/\1/g;p};d'` |
||||
|
cdindex=`echo "$cddainfo" | \ |
||||
|
sed '/CDINDEX/{s/^.*discid: *\([a-zA-Z0-9_\.]*-\).*/\1/g;p};d'` |
||||
|
cdtext=`echo "$cddainfo" | sed '/CD-Text/{s/^[^:]*: *\(.*[^ ]\).*/\1/g |
||||
|
s/&/\&\;/g;s/\"/\"\;/g |
||||
|
s/</\<\;/g;s/>/\>\;/g |
||||
|
s/\o47/\&apos\;/g |
||||
|
p};d'` |
||||
|
cdextra=`echo "$cddainfo" | sed '/CD-Extra/{s/^[^:]*: *\(.*[^ ]\).*/\1/g |
||||
|
s/&/\&\;/g;s/\"/\"\;/g |
||||
|
s/</\<\;/g;s/>/\>\;/g |
||||
|
s/\o47/\&apos\;/g |
||||
|
p};d'` |
||||
|
|
||||
|
# cddb[`idxof "artist"`]="Blue Öyster Cult" |
||||
|
ENCODING_DIR="${ENCODING_DIR}/${cddb[`idxof "artist"`]}/" |
||||
|
ENCODING_DIR="${ENCODING_DIR}${cddb[`idxof "album"`]}/" |
||||
|
mkdirhier "$ENCODING_DIR" |
||||
|
echo "Output directory is: $ENCODING_DIR" |
||||
|
|
||||
|
xmlfile="${ENCODING_DIR}cdinfo.xml" |
||||
|
|
||||
|
# some special chars within xml must be converted to special syntax |
||||
|
# & => & |
||||
|
# " => " |
||||
|
# ' => ' |
||||
|
# < => < |
||||
|
# > => > |
||||
|
xmlartist=`echo ${cddb[\`idxof "artist"\`]} | \ |
||||
|
sed 's/&/\&\;/g |
||||
|
s/</\<\;/g |
||||
|
s/>/\>\;/g |
||||
|
s/\"/\"\;/g |
||||
|
s/\o47/\&apos\;/g'` |
||||
|
xmlalbum=`echo ${cddb[\`idxof "album"\`]} | \ |
||||
|
sed 's/&/\&\;/g |
||||
|
s/</\<\;/g |
||||
|
s/>/\>\;/g |
||||
|
s/\"/\"\;/g |
||||
|
s/\o47/\&apos\;/g'` |
||||
|
|
||||
|
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>" > "${xmlfile}" |
||||
|
echo "<!DOCTYPE cdInfo SYSTEM \"cdInfo.dtd\">" >> "${xmlfile}" |
||||
|
echo "<cdinfo>" >> "${xmlfile}" |
||||
|
echo " <cdindex>$cdindex</cdindex>" >> "${xmlfile}" |
||||
|
echo " <cddb>$cddbid</cddb>" >> "${xmlfile}" |
||||
|
echo " <cd-text>$cdtext</cd-text>" >> "${xmlfile}" |
||||
|
echo " <cd-extra>$cdextra</cd-extra>" >> "${xmlfile}" |
||||
|
echo " <cd-artist>${xmlartist}</cd-artist>" >> "${xmlfile}" |
||||
|
echo " <cd-title>${xmlalbum}</cd-title>" >> "${xmlfile}" |
||||
|
echo " <cd-year>${cddb[`idxof "year"`]}</cd-year>" >> "${xmlfile}" |
||||
|
echo " <cd-genre>${cddb[`idxof "genre"`]}</cd-genre>" >> "${xmlfile}" |
||||
|
echo " <cd-time>$cd_time</cd-time>" >> "${xmlfile}" |
||||
|
echo " <cd-tracks>$track_num</cd-tracks>" >> "${xmlfile}" |
||||
|
echo " <cd-comment></cd-comment>" >> "${xmlfile}" |
||||
|
|
||||
|
i=1; while [ $i -le $track_num ] |
||||
|
do |
||||
|
j=`expr $i \+ 1` |
||||
|
tracknr=`awk 'BEGIN{printf("%02d\n",'$i')}'` |
||||
|
track=${cddb[`idxof "track-$tracknr"`]} |
||||
|
tartist=${cddb[`idxof "tartist-$tracknr"`]} |
||||
|
|
||||
|
xmltrack=`echo ${track} | sed 's/&/\&\;/g |
||||
|
s/</\<\;/g |
||||
|
s/>/\>\;/g |
||||
|
s/\"/\"\;/g |
||||
|
s/\o47/\&apos\;/g'` |
||||
|
xmltartist=`echo ${tartist} | sed 's/&/\&\;/g |
||||
|
s/</\<\;/g |
||||
|
s/>/\>\;/g |
||||
|
s/\"/\"\;/g |
||||
|
s/\o47/\&apos\;/g'` |
||||
|
|
||||
|
tracklen=`echo "$cddainfo" | \ |
||||
|
sed '/ '"$i"'\.([0-9 ]*:/{s/.*'"$i"'\.( *\([0-9:\.]*\)).*/\1/g;p};d'` |
||||
|
trackstart=`echo "$cddainfo" | \ |
||||
|
sed '/ '"$i"'\.([0-9 ]*)/{s/.*'"$i"'\.( *\([0-9]*\)).*/\1/g;p};d'` |
||||
|
test $i -eq $track_num && \ |
||||
|
trackend=`echo "$cddainfo" | \ |
||||
|
sed '/ lead-out([0-9 ]*)/{s/.*lead-out( *\([0-9]*\)).*/\1/g;p};d'` || \ |
||||
|
trackend=`echo "$cddainfo" | \ |
||||
|
sed '/ '"$j"'\.([0-9 ]*)/{s/.*'"$j"'\.( *\([0-9]*\)).*/\1/g;p};d'` |
||||
|
|
||||
|
test -z "$trackstart" -o -z "$trackend" && echo "Disk Error" && exit 1 |
||||
|
|
||||
|
echo " <track>" >> "${xmlfile}" |
||||
|
echo " <track-number>$i</track-number>" >> "${xmlfile}" |
||||
|
echo " <track-time>$tracklen</track-time>" >> "${xmlfile}" |
||||
|
echo " <track-start-sector>$trackstart</track-start-sector>" >> "${xmlfile}" |
||||
|
echo " <track-length>`expr $trackend \- $trackstart`</track-length>" >> "${xmlfile}" |
||||
|
echo " <track-artist>$xmltartist</track-artist>" >> "${xmlfile}" |
||||
|
echo " <track-title>$xmltrack</track-title>" >> "${xmlfile}" |
||||
|
echo " <track-comment></track-comment>" >> "${xmlfile}" |
||||
|
echo " </track>" >> "${xmlfile}" |
||||
|
|
||||
|
# outfile="${ENCODING_DIR}The Wall/Disk2/" |
||||
|
outfile="${ENCODING_DIR}${tracknr}-${track}" |
||||
|
|
||||
|
test "$ENCODING_TYPE" = "f" && \ |
||||
|
outstr="track-$tracknr => ${tracknr}-${track}.flac" |
||||
|
test "$ENCODING_TYPE" = "m" && \ |
||||
|
outstr="track-$tracknr => ${tracknr}-${track}.mp3" |
||||
|
test "$ENCODING_TYPE" = "o" && \ |
||||
|
outstr="track-$tracknr => ${tracknr}-${track}.ogg" |
||||
|
test "$ENCODING_TYPE" = "w" && \ |
||||
|
outstr="track-$tracknr => ${tracknr}-${track}.wav" |
||||
|
|
||||
|
if [ "$ENCODING_TYPE" = "f" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D0,4,0 -t$i - | \ |
||||
|
flac -c \ |
||||
|
-T artist=\"${tartist}\" -T album=\"${cddb[`idxof "album"`]}\" \ |
||||
|
-T genre=\"${cddb[`idxof "genre"`]}\" -T title=\"${track}\" \ |
||||
|
-T tracknumber=\"`expr ${tracknr} \+ 0`\" \ |
||||
|
-T tracknum=\"`expr ${tracknr} \+ 0`\" -T date=\"${cddb[`idxof "year"`]}\" \ |
||||
|
-T comment=\"${cddb[`idxof "comment"`]}\" \ |
||||
|
-o \"${outfile}.flac\" - 2>/dev/null" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
if [ "$ENCODING_TYPE" = "m" -a "$ENCODER" = "lame" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D0,4,0 -t$i - | \ |
||||
|
lame -h \ |
||||
|
--ta \"${tartist}\" --tl \"${cddb[`idxof "album"`]}\" \ |
||||
|
--tg \"${cddb[`idxof "genre"`]}\" --tt \"${track}\" \ |
||||
|
--tn \"`expr ${tracknr} \+ 0`\" --ty \"${cddb[`idxof "year"`]}\" \ |
||||
|
--tc \"${cddb[`idxof "comment"`]}\" \ |
||||
|
- \"${outfile}.mp3\" 2>/dev/null" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
if [ "$ENCODING_TYPE" = "m" -a "$ENCODER" = "bladeenc" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D0,4,0 -t$i - | \ |
||||
|
bladeenc -progress=0 STDIN \"${outfile}.mp3\" 2>/dev/null" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
if [ "$ENCODING_TYPE" = "o" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D0,4,0 -t$i - | \ |
||||
|
oggenc -a \"${tartist}\" -l \"${cddb[`idxof "album"`]}\" \ |
||||
|
-G \"${cddb[`idxof "genre"`]}\" -t \"${track}\" \ |
||||
|
-N \"`expr ${tracknr} \+ 0`\" -d \"${cddb[`idxof "year"`]}\" \ |
||||
|
-c \"${cddb[`idxof "comment"`]}\" \ |
||||
|
-o \"${outfile}.ogg\" - 2>/dev/null" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
if [ "$ENCODING_TYPE" = "w" ] |
||||
|
then |
||||
|
bash -c "exec 2>&1;\ |
||||
|
cdda2wav -H -D0,4,0 -t$i - > \"${outfile}.wav\"" | rton | \ |
||||
|
awk '/ [0-9 ][0-9]%/ && percent!=$5{percent=$5;printf("\r'"$outstr"': %s", percent)}END{print "\r'"$outstr"': 100%"}' |
||||
|
fi |
||||
|
|
||||
|
i=`expr $i + 1` |
||||
|
done |
||||
|
|
||||
|
echo "</cdinfo>" >> "${xmlfile}" |
||||
@ -0,0 +1,35 @@ |
|||||
|
<?xml version="1.0" encoding="ISO-8859-15"?> |
||||
|
<!DOCTYPE cdInfo SYSTEM "cdInfo.dtd"> |
||||
|
<cdinfo> |
||||
|
<cdindex>2pGK39LLL22K6K8mFDegkBNR39M-</cdindex> |
||||
|
<cddb>0x0911a912</cddb> |
||||
|
<cd-text/> |
||||
|
<cd-extra/> |
||||
|
<cd-artist>Various</cd-artist> |
||||
|
<cd-year>1998</cd-year> |
||||
|
<cd-genre>Alternative</cd-genre> |
||||
|
<track> |
||||
|
<track-number>1</track-number> |
||||
|
<track-time>3:42.20</track-time> |
||||
|
<track-start-sector>32</track-start-sector> |
||||
|
<track-artist>Guano Apes</track-artist> |
||||
|
<track-title>Lords Of The Boards</track-title> |
||||
|
<track-comment/> |
||||
|
</track> |
||||
|
<track> |
||||
|
<track-number>2</track-number> |
||||
|
<track-time>4:45.70</track-time> |
||||
|
<track-start-sector>16702</track-start-sector> |
||||
|
<track-artist>Rammstein</track-artist> |
||||
|
<track-title>Das Modell</track-title> |
||||
|
<track-comment/> |
||||
|
</track> |
||||
|
<track> |
||||
|
<track-number>3</track-number> |
||||
|
<track-time>4:11.08</track-time> |
||||
|
<track-start-sector>38147</track-start-sector> |
||||
|
<track-artist>Faith No More</track-artist> |
||||
|
<track-title>Last Cup Of Sorrow</track-title> |
||||
|
<track-comment/> |
||||
|
</track> |
||||
|
</cdinfo> |
||||
@ -0,0 +1,72 @@ |
|||||
|
Files in this package |
||||
|
--------------------- |
||||
|
getcd.sh (The main script that does most of the work) |
||||
|
rton.c (A VERY small c-prog, that converts \r (carriage return) |
||||
|
to \n (line feed). It is needed to fetch the percent |
||||
|
complete messages from cdda2wav) |
||||
|
flac2mp3.xsl (xml stylesheet to convert cdinfo.xml in shell commands |
||||
|
that will create .flac from .mp3 files) |
||||
|
flac2wav.xsl (xml stylesheet to convert cdinfo.xml in shell commands |
||||
|
that will create .flac from .wav files) |
||||
|
mp32wav.xsl (xml stylesheet to convert cdinfo.xml in shell commands |
||||
|
that will create .wav from .mp3 files) |
||||
|
cdinfo2xinf.xsl (xml stylesheet to convert cdinfo.xml in shell commands |
||||
|
that create the .xinf Files used by xcdroast) |
||||
|
CDDB_get-2.23p1.patch (a patch for cddb.pl that makes it possible to |
||||
|
select one of multiple cddb-entrys at calltime) |
||||
|
README (Overview and Information) |
||||
|
INSTALL (This file, howto make something useful from it) |
||||
|
USAGE (How to use the script) |
||||
|
|
||||
|
|
||||
|
Requirments |
||||
|
----------- |
||||
|
first you need some software to run this script. |
||||
|
CDDB_get-2.23 (http://armin.emx.at/cddb/) |
||||
|
lame (http://lame.sourceforge.net/) |
||||
|
bladeenc (http://bladeenc.mp3.no/) |
||||
|
flac (http://flac.sourceforge.net/) |
||||
|
vorbis-tools (http://www.vorbis.com/download_unix_1.0.1.psp) |
||||
|
libxml2 (http://xmlsoft.org/) |
||||
|
|
||||
|
I assume you have a working sed and awk, else you need to install them too. |
||||
|
|
||||
|
Install lame, bladeenc, flac, vorbis-tools and libxml2 as discribed within |
||||
|
these packages. |
||||
|
|
||||
|
unpack CDDB_get-2.23.tar.gz and patch it with CDDB_get-2.23p1.patch. |
||||
|
For this copy both files in a directory dir then do the following: |
||||
|
|
||||
|
me@house:~> cd dir |
||||
|
me@house:~/dir> tar xfvz CDDB_get-2.23.tar.gz |
||||
|
me@house:~/dir/CDDB_get-2.23> patch -p1 -E < ../CDDB_get-2.23p1.patch |
||||
|
|
||||
|
now install it as usual (and described within the README from CDDB_get) |
||||
|
|
||||
|
now go in the directory where rton.c exists. |
||||
|
type here: gcc -o rton rton.c |
||||
|
and then copy rton in a directory in your path. |
||||
|
|
||||
|
Finally copy getcd.sh somewhere in you path. |
||||
|
|
||||
|
now you can use getcd.sh. For a short description how to use it either |
||||
|
read USAGE or type getcd.sh -h. |
||||
|
|
||||
|
IMPORTANT: Any user who should use this script needs read-access to the |
||||
|
cdrom device, additional it is actually necessary to create a symlink |
||||
|
/dev/cdrom to your real device eg. /dev/sr0 or /dev/hdb. And the user must have |
||||
|
access to the internet. |
||||
|
|
||||
|
Note |
||||
|
---- |
||||
|
Please note that this is not a release. You can use it and it will not harm |
||||
|
anything as for as I can say, but it might not work with some configurations |
||||
|
or CDs. |
||||
|
In the release there will be some kind of detection which tools are present and |
||||
|
witch not and the script will use only present tools or give an error |
||||
|
description. |
||||
|
Note further that it is desired to modify the script for your needs. It is not |
||||
|
very complex and with some error and trial it will be possible to tailor it |
||||
|
exactly for your needs. In future there will be configuration files to make it |
||||
|
even more ease to configure the script for your situation. (I am thinking |
||||
|
about reqriting the script in c) |
||||
@ -0,0 +1,21 @@ |
|||||
|
<?xml version="1.0" encoding="ISO-8859-15"?> |
||||
|
<xsl:stylesheet version="1.0" |
||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
||||
|
|
||||
|
<xsl:output method="text" indent="no" encoding="ISO-8859-15" /> |
||||
|
|
||||
|
<xsl:template match="/"> |
||||
|
outdir="../../../wav/<xsl:value-of select="/cdinfo/cd-artist"/>" |
||||
|
outdir="$outdir/<xsl:value-of select="/cdinfo/cd-title"/>" |
||||
|
mkdirhier "$outdir" |
||||
|
<xsl:apply-templates select="/cdinfo/track"/> |
||||
|
</xsl:template> |
||||
|
|
||||
|
<xsl:template match="track"> |
||||
|
tracknum=`echo <xsl:value-of select="track-number"/> | \ |
||||
|
awk '{printf("%02d", $0)}'` |
||||
|
title="<xsl:value-of select="track-title"/>" |
||||
|
lame --decode "$tracknum-$title.flac" \ |
||||
|
"$outdir/$tracknum-$title.wav" |
||||
|
</xsl:template> |
||||
|
</xsl:stylesheet> |
||||
@ -0,0 +1,30 @@ |
|||||
|
This is another shell script that combines cdda2wav with various encoders. |
||||
|
|
||||
|
As I started this i was not pleased by any of the existent grabber/encoder |
||||
|
frontends. So I decided to create my own one. The goal was to rip and encode in |
||||
|
one step without creating any temporary .wav file and to have a simple command |
||||
|
with only a few easy arguments to control this command. |
||||
|
|
||||
|
Now getcd.sh is a not to complicated bash script that uses awk, sed, cdda2wav, |
||||
|
flac, lame, bladeenc, ogg/vorbis, cddb.pl (in a slightly patched version). |
||||
|
It encodes tracks from the cd to a spcifiable base directory without creating |
||||
|
any temporary files. |
||||
|
It creates subdirectorys basedir/[mp3|flac|ogg|wav]/artist/cd-title for the |
||||
|
corresponding encoding-method and save files with the name |
||||
|
trackno-tracktitle.[mp3|flac|ogg|wav] again corresponding to the used |
||||
|
encoding-method. |
||||
|
If one encodes a sampler-cd (cd with various artists) it is often so, that |
||||
|
the artist of the track is mentioned in the cddb-track-title. For this reason |
||||
|
one can specify a delimiting character and the order (artist or title first) to |
||||
|
split the cddb-track-info and generate correct id3tags or similar. |
||||
|
|
||||
|
Additional to the encoded files getcd.sh creates an file cdinfo.xml which |
||||
|
contains all essential information of the original CD. I have written also |
||||
|
some xslt files that can be used to create .xinf files for xcdroast and to |
||||
|
create .wav from .flac or .mp3. It is planned to create additional xslt files |
||||
|
to make html-information about the CD, create insert scripts for postgres and |
||||
|
or mysql (or other rdbs) and converter-scripts that use these xslt-files. |
||||
|
To use the xslt-files one needs an xslt-processor, like xsltproc from |
||||
|
libxml2 (thats the one i used) |
||||
|
|
||||
|
for help use getcd.sh -h |
||||
@ -0,0 +1,15 @@ |
|||||
|
/* Achtung unter dos ist \n in wirklichkeit \r\n bei den meisten |
||||
|
Compilern, da funktioniert das natürlich nicht!!!! */ |
||||
|
#include <stdio.h> |
||||
|
|
||||
|
int main(int argc, char* argv[]) { |
||||
|
int c=0; |
||||
|
|
||||
|
while(fread(&c, 1, 1, stdin)) { |
||||
|
putchar((c=='\r')?'\n':c); |
||||
|
fflush(stdout); |
||||
|
} |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,25 @@ |
|||||
|
usage: ./getcd.sh [-d delimiter [-o {t|a}]] [-t {m|f|o}] [-p path] [-e encoder] [-c cddb-entry] [-h] |
||||
|
-d : A single character delimiting trackname from |
||||
|
artistname with sampler cds |
||||
|
|
||||
|
-o : specifies if theres the track or the artist first |
||||
|
Must be: |
||||
|
t for titel first or |
||||
|
a for artist first |
||||
|
If there is none specified t is assumed |
||||
|
-t : you can specify either m for encoding to mp3 |
||||
|
using lame, or f for making lossless encoding using flac, |
||||
|
or o for making ogg/vorbis, or w for uncompressed wav. |
||||
|
Omitting this results in encoding to flac. |
||||
|
mp3s will be placed under a subfolder mp3 and flacs |
||||
|
under a subfolder flac |
||||
|
-p : specifies the path to save the encoded data. |
||||
|
Defaults to the users home directory. |
||||
|
-e : specifies the mp3 encoder to use. |
||||
|
valid encoders are actually: lame,bladeenc |
||||
|
Defaults to lame. |
||||
|
-c : specifies the CDDB-Entry to use. |
||||
|
sometimes there is more than 1 entry for a cd in cddb. |
||||
|
Then you can specify wich one to use by this option. |
||||
|
You can checkout all entries using cddb.pl. |
||||
|
-h : Shows this help. |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue