Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-10-2004, 08:39 AM
|
#1
|
Senior Member
Registered: Jun 2004
Location: the Netherlands
Distribution: debian SID
Posts: 2,170
Rep:
|
is there a way to let cdda2wav write files and dirs with cddb names?
All graphical tools seem to screw up the files (only 1 second of sound and then nothing) so I'm using cdda2wav in the command line. Though I've set it to use cddb it only creates files like audio1.wav. Is there a way to make it write the title of the song and artist onto the file (and not in the loose .inf files?)
Which frontends are there cause I tried grip (ripper configuration error) ripperx (no sound) grip with paranoia (no sound) and I can't get grip to use cdda2wav
|
|
|
10-10-2004, 05:58 PM
|
#2
|
Member
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900
Rep:
|
I use a Python script to do this with the CDDB modules. I could paste the code here if you're interested, though you'd have to modify it a little if you actually want wav files - my script creates FLAC and OGG files directly with the CDDB names (in the hierarchy: (flacdir)/artist/album/00 - track name.flac)
|
|
|
10-11-2004, 02:22 AM
|
#3
|
Senior Member
Registered: Jun 2004
Location: the Netherlands
Distribution: debian SID
Posts: 2,170
Original Poster
Rep:
|
If you could I'd very much like to at least have a look at it  I know some python myself so I might be able to do it but otherwise the other format is ok too, it's because my computer sound is better than my CD player so I want to listen my CDs on the computer. And on the fly it makes my CDs less used so they don't break anymore.
|
|
|
10-11-2004, 05:58 AM
|
#4
|
Member
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900
Rep:
|
OK, I've edited this a tiny bit to remove some unnecessary fluff, and it's not the best code, but I stopped as soon as it worked, since no-one else would ever need it... so much for that idea 
I've also added a few comments to make it easier to weed out the stuff you don't care about.
Code:
#!/usr/bin/python
import os, sys, traceback
import DiscID, CDDB
import time
# The LISTFILE stuff is to keep a record of which CDs have been ripped already - I didn't want any mistakes or duplicates
LISTFILE = "rippedcd.lst"
os.system( 'touch ' + LISTFILE ) # Make sure it exists
# Handle problem characters - just replaces every first string with the matching second string
def safe( name ):
badchars = [('?', ''), ('\\', ''), ('/', ''), (':', '-'), ('"', "'")]
for x in badchars:
name = name.replace( x[0], x[1] )
return name
# I'm almost positive there is a 'right' way to do this...
def direxists( name ):
try:
os.stat( name )
return 1
except:
return 0
# Function that checks the CD serial against those in LISTFILE and aborts if necessary
def check_cd():
try:
dev = DiscID.open()
id = DiscID.disc_id(dev)
dev.close()
idhex = id[0].__hex__()
try:
f = open(LISTFILE, 'r')
except:
print os.getcwd()
for line in f:
if line.strip('\n') == idhex:
print idhex, "CD already ripped"
f.close()
return 0
f.close()
return id
except:
inf = sys.exc_info()
traceback.print_tb( inf[2] )
return 0
details = check_cd()
if details:
try:
# Get the track and album names - may need some alterations for abnormal CDDB entries
cddb = CDDB.query( details )
cddb = cddb[1]
if type(cddb) == type([]):
cddb = cddb[0]
names = CDDB.read( cddb['category'], cddb['disc_id'] )
names = names[1]
titles = [ safe(x.strip()) for x in names['DTITLE'].split(' / ', 1) ]
if len(titles) == 1:
titles = ['Various'] + titles
n = 0
while names.has_key( 'TTITLE%d' % n ):
titles.append(safe(names['TTITLE%d' % n]))
n+=1
# I have flac and ogg directories already created - adjust for your needs
dir1 = 'flac/' + titles[0]
dir2 = 'ogg/' + titles[0]
if not direxists( dir1 ):
print "*%s* does not exist" % dir1
os.mkdir( dir1 )
if not direxists( dir2 ):
print "*%s* does not exist" % dir2
os.mkdir( dir2 )
dir1 += '/' + titles[1]
dir2 += '/' + titles[1]
if not direxists( dir1 ):
print "*%s* does not exist" % dir1
os.mkdir( dir1 )
if not direxists( dir2 ):
print "*%s* does not exist" % dir2
os.mkdir( dir2 )
for x in range( 1, len(titles)-1 ):
# Build command line...
cmd = "cdda2wav -Q -q -D /dev/cdrom -t %d - " % x
cmd += " | flac --best -c -s -"
# This is silly, but it saves me escaping spaces on the command line
finput = os.popen( cmd )
fname = dir1 + "/%02d - %s.flac" % (x, titles[x+1])
foutput = open( fname, 'w' )
foutput.write( finput.read() )
finput.close()
foutput.close()
# First command creates the FLAC file, this recompresses to OGG without using the CD again (faster)
cmd = "flac -d -c -s \"%s\"" % fname
cmd += " | oggenc -Q -b 192 - 2>/dev/null"
finput = os.popen( cmd )
fname = dir2 + "/%02d - %s.ogg" % (x, titles[x+1])
foutput = open( fname, 'w' )
foutput.write( finput.read() )
finput.close()
foutput.close()
# Add the CD serial to LISTFILE
f = open(LISTFILE, 'a')
f.write(details[0].__hex__() + "\n")
f.flush()
f.close()
except:
traceback.print_exc()
|
|
|
10-11-2004, 08:03 AM
|
#5
|
Senior Member
Registered: Jun 2004
Location: the Netherlands
Distribution: debian SID
Posts: 2,170
Original Poster
Rep:
|
Awesome thank you very much! I think I might even be able to make it output wavs 
|
|
|
10-11-2004, 03:34 PM
|
#6
|
Member
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900
Rep:
|
You should be able to just by removing the "| flac" portion of the command and changing the fname parameter (and removing the second part that does the ogg stuff)
|
|
|
All times are GMT -5. The time now is 03:21 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|