Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight


by strredwolf (Chaplain)
on May 17, 2001 at 22:30 UTC ( #81329=sourcecode: print w/replies, xml ) Need Help??
Category: Audio Related Programs
Author/Contact Info strredwolf
Description: I got tired of other scripts/etc which took info from CDDB and failed to rip a CD into MP3's. So I wrote up my own scripts! The first one (wscd2wav) gets the CDDB info, uses cdparanoia, and puts the .wav into it's own directory, setting a symlink for each one. The second one (scan4wav2mp3) looks for the symlinks, reads where the .wav is, and uses lame on the .wav. So far it's working very well.

To use, open up two xterms (or use splitvt or screen) and change into the directory you want the MP3's to go to in both. Run wscd2wav in the first, scan4wav2mp3 in the second.


### Some of this code came from CHOAD (especially the CDDB handler)

### Modules
use CDDB;

### Stuff
my $HOME = $ENV{HOME};
my $USER = $ENV{USER};
my $HOST = `hostname`; $HOST =~ s/\n//;

while(!$done) {
  ### Check the CDDB info on this person.

  open(IN,"cdparanoia -Q 2>&1 |") || die $1;
  while(<IN>) {
+d+)\]/) {
      $toc[$i++] = "$1 $2 $3 $4";
    } elsif (/^TOTAL\s+[0-9]+\s+\[([0-9]+):([0-9]+)\.([0-9]+)\]/) {
      $toc[$i++] = "999 $1 $2 $3";  # lead-out track
  close IN;

  ### Now get CDDB...
  my $cddb = new CDDB( Host  => "",
               Port  => 888,
               Login => "$USER\@$HOST",
             ) or die $!;

  my ($cddb_id, $track_numbers, $track_lengths, $track_offsets, 
      $total_seconds) = $cddb->calculate_id(@toc);
  my @discs = $cddb->get_discs($cddb_id, $track_offsets, $total_second
  if (scalar @discs > 0) {
    ($genre, my $cddb_id, my $title) = @{$discs[0]};
    $title=~/([^\/]*) \/ (.*)/; 
    $artist = $1; $album = $2;
    my $disc_info     = $cddb->get_disc_details($genre, $cddb_id);
    @tracks  = @{$disc_info->{'ttitles'}};

  ### Work out the prefixes...
  $prefix = "$artist/$album";
  $prefix =~ tr/ ,.\'\"&//d;
  system "mkdir -p $prefix";
  for($i=0; $i<$ntracks; $i++) {
    $f =~ s/\/[^\/]+$//;
    $f =~ tr/ ,.\'\"&//d;
    $f =~ s/\([^\)]+\)//g;

    print "$t>$fname\n";
    system "cdparanoia $t $fname.wav";
    symlink "$fname.wav", "$currcd-$i.trk";

  system "eject -r /dev/hdc";
  print "Pausing...";



print "Scanning for MP3's...\n";
    sleep 10;
    @d=grep {/\.trk$/} ( readdir(DIR) );
    if(@d) {
    $f=readlink $d[0];
    print "Reencoding $f...\n";
    system "lame -b 128 $f";
    unlink $f;
    unlink $d[0];

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://81329]
[jedikaiti]: Hi Monks
[GrandFather]: HI jedikaiti. Collected more 73p data this morning. Rubbish sky though. Seeing was between 5 and 9 arc seconds FWHM with thin cloud drifting through :(
[GrandFather]: Still, at least some of the images are good enough to get reasonable astrometry. Well, good enough for a good plate solve anyway
[Cow1337killr]: Hello, jedikaiti
[jedikaiti]: Cool!

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2017-02-20 20:52 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (302 votes). Check out past polls.