an idea might be to add cddb support to write the read_title file - I wouldn't know anything about how to implement this but it would make the script even cooler.
You guys wanted to see it when I had it done (for the most part). Here it is. Try it out, let me know of any problems, or go ahead and change it and send it back to me. Give some feedback, as this is my first script project.
Code:#!/bin/bash ############################################################ #This is my first attempt at writing a bash script #Special thanks goes to Feztaa and Pam at LJR (www.linuxjunior.org) #I took part of one Feztaa's scripts that automated mp3 to ogg #and added a little to it here and there, changed a little, etc. #This script uses cdparanoia to encode files from the cd-rom into #wav files and then into Ogg Vorbis format, renaming them as it goes #from a name file that you specify at the start of the script. #I may add more to it later, I'll let you know. #This is cd2ogg v 0.5 #and is covered by the GNU Public License 8) ############################################################ #!/bin/bash ROOT_UID=0 #Only users with $UID 0 have Root priveledges E_NOTROOT=67 if [ "$UID" -ne "$ROOT_UID" ] #Checking for root then echo "Must be Root to run this script." exit $E_NOTROOT fi echo "What is the file holding the titles called?" #This is the file that holds read title_file #the song names echo "Do you wish to encode an entire cd to .wav(y/n) ?" #encode or already encoded? read answer if [ $answer = y ] then cdparanoia -Q cdparanoia -vwB fi if [ $answer = n ] then declare -a track #this makes an array to hold the track# in echo "Enter the track you want encoded seperated by a space?" echo "For example, 1 2 4 6 7" read -a track #This is where the input gets taken and stored in the array element_count=${#track[@]} #This counts the # of tracks entered. index=0 while [ "$index" -lt "$element_count" ] do cdparanoia -Q echo `cdparanoia -vw ${track[$index]} "track_$index.wav"` #this does the work let "index = $index + 1" #to make the .wavs done fi for t in `cat $title_file` #This was submitted by Pam at LJR do #www.linuxjunior.org. He is a much better a=`ls -tr *.wav | head -1` #coder that I am. 8) oggenc "$a" -q 5 -t "$t" rm *.wav done rm $title_file exit 0
an idea might be to add cddb support to write the read_title file - I wouldn't know anything about how to implement this but it would make the script even cooler.
I was thinking along the same lines as you Lovechild, and I thought it would probably be easy (more fool me!). Could I find a nice little utility that just outputs a nice track listing after querying a cd? If it exists I'd like to know about it.
After digging around I came up with a solution that involves the use of the following:
cd-discid - returns info about a cd which can be used to query a cddb server.
cddbcmd - sends commands to a cddb server.
Both of these were available as debian packages.
This is my mini script which queries the cd (in my case /dev/cdrom) and gets the info from a cddb server (in this case the default of freedb.org is used).
Along with some other info, this will list the track names as TITLE1=...,TITLE2=.... etc. This means that with a bit of manipulation, you can relate these TITLE names directly to "track" files and throw away my contribution to the script! :'(Code:discidfull=`cd-discid /dev/cdrom` discid=`echo $discid | head --bytes=8` # I only use http because it gets through my firewall # Query the cddb server so as to get the correct parameters for a full read - # those being music category followed by discid, we throw the rest of the query # away. readparam=`cddbcmd -m http "cddb query $discidfull" | awk '{ print $1, $2; }'` # do the full read, for now just let it go to stdout cddbcmd -m http "cddb read $readparam"
Edit: Oops, I didn't need that discid shell variable in the end.
I had thought about that when I was first starting this task, but the prog to query the freedb server was in c or c++ (not sure). For now, make sure that this works with no errors, dont remember if I had any or not, but it did encode seperate tracks and whole cds. I might add a query to set the quality level for the ogg encoding, just candy stuff mostly. The freedb thing is worth looking into. I will get back with you guys. Again, let me know how it goes. ;D(Yay! I did my first script) ;D
I gave the script a try (cut n paste straight from this thread) and I fell foul of that 4th last line:
which removed all my freshly ripped wav filesCode:rm *.wavI think it should read:
Also, on my suggested cddb querying script, I have found that the initial query can return more than one possible id that can be used to get a track listing for the same cd. Therefore it is necessary to throw all the records away bar one. This is an updated version:Code:rm $a
Code:#!/bin/bash # Get discid string discid=`cd-discid /dev/cdrom` # Query cddb server to get parameters required for a full read readparam=`cddbcmd -m http "cddb query $discid" | head -1 | awk '{ print $1, $2; }'` # Do the full read, for now just let it go to stdout cddbcmd -m http "cddb read $readparam"
That should remove the wav files after it has encoded them to ogg. Either way, I will change it and try it out. I found a cd-disk id rpm for mandrake but not one for redhat. Havent got it installed yet. But, yeah I will change it to $a and try it out.
I cant get this thing to work on my laptop now. Can you believe that? works fine at home, and gets errors running the same version of linux redhat on my laptop. WTH?
Bookmarks