View Single Post
Old 08-02-2004   #34 (permalink)
TonyDennis
New on Forum
 
Join Date: Feb 2004
Posts: 10
Alright. Anyone running mIRC 5.91+ (http://mirc.co.uk/) can use this script. It takes the large .aud file and the data.TXT file and splits the file by the bytes indicated in the data file. One small note, though, make sure in the data file you remove all the extra Programs. Only use the [ProgramAll] section. You can delete everything else.

I scripted two commands, audData and audSplt. audData parses the data file and verifys the artist's name. (I name my files a la "FirstName LastName - Song", Starbucks uses "LastName, First Name".) The commandd is mildly intelligent, as in it will assume you want to switch what is after the comma with what is before, but on some of the songs with multiple artists it messes up and you have to rename the artist yourself (by click No and entering it). I recommend you run the command even if you don't want to rename the files because some of the artists (multiple artist songs) have /'s in them, and you can't have a filename with a /. Also, some of the song titles have invalid characters in them. You may wish to manually (via notepad) search and find those characters (such as quotes, question marks, etc).

audSplt goes through the aud file and splits it according to the Start and Length parameters of the datafile, then renames the file to Artist - Title.mp3.

Syntax:
/audData start_song end_song "c:\file\data.txt"
/audSplt start_song end_song "c:\file\data.txt" "c:\file\playdisc.aud" "c:\output\"

Example:
Code:
/audData 1 295 "C:\Documents and Settings\Tony Dennis\Desktop\data.TXT
/audSplt 1 295 "C:\Documents and Settings\Tony Dennis\Desktop\data.TXT" "C:\Documents and Settings\Tony Dennis\Desktop\playdisc.aud" "C:\Documents and Settings\Tony Dennis\Desktop\output\"

If any of the paths have a space in it, you have to use quotes on all three paths. Otherwise you don't need the quotes.

Here is the code that you need to paste into your aliases (alt+a):
Code:
sleep {
  var %a = $ticks $+ .wsf
  write %a <job id="js"><script language="jscript">WScript.Sleep( $+ $$1 $+ );</script></job>
  .comopen %a WScript.Shell
  if !$comerr { .comclose %a $com(%a,Run,3,bstr,%a,uint,0,bool,true) }
  .remove %a
}
audData {
  if ($3) {
    var %first_song = $1
    var %last_song = $2
    if ($chr(34) isin $3-) {
      var %datafile = $gettok($3-, 1, 34)
    }
    else {
      var %datafile = $3
    }
  }
  else {
    echo -a 04audData, error: invalid parameters. (audSplt first_song last_song "data file")
    return
  }
  if (%last_song < %first_song) { 
    echo -a 03audData, warning: last_song comes before first_song, switching... 
    var %switch = %first_song
    var %first_song = %last_song
    var %last_song = %switch
  }
  if ($readini(%datafile,n,Song $+ %last_song,Start) == $null) { echo -a 04audDataerror: last_song does not exist, aborting... | return }
  var %i = %first_song
  while (%i <= %last_song) {
    var %artist = $readini(%datafile, Song $+ %i, Artist)
    var %newartist = %artist
    if ($chr(44) isin %artist) {
      var %first_name = $gettok(%artist,2,44)
      var %last_name = $gettok(%artist,1,44)
      var %newartist = %first_name %last_name
    }
    var %okay = $?!="Is this the artist? $crlf $crlf %artist to $crlf %newartist "
    if (%okay == $false) {
      var %newartist = $?="Rename artist: %artist "
    }
    writeini -n " $+ %datafile $+ " Song [ $+ [ %i ] ] Artist %newartist
    inc %i
  }
}

audSplt { 
  echo -a 02audSplt: beginning... | var %start_ticks = $ticks
  if ($3) {
    var %first_song = $1
    var %last_song = $2
    if ($chr(34) isin $3-) {
      var %datafile = $gettok($3-, 1, 34)
      var %audiofile = $gettok($3-, 3, 34)
      var %output_dir = $gettok($3-, 5, 34)
    }
    else {
      var %datafile = $3
      var %audiofile = $4
      var %output_dir = $5
    }
  }
  else {
    echo -a 04audSplt, error: invalid parameters. (audSplt first_song last_song "data file" "audio file" "output_dir)
    return
  }
  if (%last_song < %first_song) { 
    echo -a 03audSplt, warning: last_song comes before first_song, switching... 
    var %switch = %first_song
    var %first_song = %last_song
    var %last_song = %switch
  }
  if ($readini(%datafile,n,Song $+ %last_song,Start) == $null) { echo -a 04audSplt, error: last_song does not exist, aborting... | return }
  if ($isdir(%output_dir) == $false) { echo -a 04audSplt, error: output_dir does not exist, aborting... | return }
  if ($right(%output_dir,1) != \) { var %output_dir = %output_dir $+ \ }
  echo -a 02audSplt: entering ripping process...
  var %i = %first_song
  while (%i <= %last_song) {
    var %start_byte = $readini(%datafile,Song $+ %i, Start)
    var %end_byte = $calc($readini(%datafile,Song $+ %i, Length) + %start_byte)
    var %title = $readini(%datafile,Song $+ %i, Title)
    var %artist = $readini(%datafile,Song $+ %i, Artist)
    var %output_file = %output_dir $+ %artist - %title $+ .mp2
    .remove " $+ %output_file $+ "
    bread " $+ %audiofile $+ " %start_byte 1 &contents
    bwrite " $+ %output_file $+ " 0 1 &contents
    %cur_byte = $calc(%start_byte + 1)
    while (%cur_byte < %end_byte) {
      if ($calc(%cur_byte + 8192) > %end_byte) {
        var %byte_inc = $calc(%end_byte - %cur_byte)
      }
      else { var %byte_inc = 8192 }
      bread " $+ %audiofile $+ " %cur_byte %byte_inc &contents
      bwrite " $+ %output_file $+ " -1 -1 &contents
      inc %cur_byte %byte_inc
    }
    echo -a 02audSplt: finished track %i $+ ,02 %title by02 %artist
    /sleep 1
    inc %i
  }
  echo -a 02audSplt: all done! completed in $round($calc($calc($ticks - %start_ticks) / 1000),2) secs.
}
Perhaps I will simply make a .mrc file that you can /load. Anyway, good luck. If you need any help using it, you can either message me on *edit*.

Edit: Changed .mp3 extention to .mp2, as that is what it seems to be. I used winLAME to convert from .mp2->mp3.

Last edited by C0deKing; 04-03-2006 at 12:51.
TonyDennis is offline   Reply With Quote