#!/usr/bin/env python ## this is a dirty, lame hack by a dirty, lame guy ## - reads a .m3u file (e.g. generated by xmms) ## - converts any audiofile to wavefiles using incredible mplayer ## - provides normalized wavefiles using transcode ## - burns an audio-cd # !!feel free to copy, modify, redistribute and at most _use_ it!! # comments to: age-at-systemausfall-dot-org 02004 import os import string m3ufile = "foo.m3u" wavdir = "/mnt/ionos/mugge/aufnahme/ready" recorder = "ATAPI:0,0,0" #fuer cdrecord mit 2.6 kernel und ide brenner print "\nDirty, lame hack in action:\n" ################ ### read m3u try: temp = open(m3ufile,"r") m3u = temp.read() temp.close() except: print "I can't find the .m3u file" # M's Kommentar Schnibbler notfound = 0 while notfound == 0: startpos = string.find(m3u,"#") if startpos <0: notfound +=1 endpos = string.find(m3u,"\n",startpos) cutme = m3u[startpos:endpos] m3u = string.replace(m3u,cutme,"") valuepairs = string.split(m3u,"\n") m3u = [] for i in valuepairs: if i != "": m3u.append(i) # im m3u-array stehen jetzt hoffentlich ;) nur noch pfadangaben # checken ob's stimmt for i in m3u: if not os.path.exists(i): print "===> %s not found!" % i print "I'll ignore it." m3u.remove(i) print "\nI found %i audiofiles to convert, normalize and burn:" % len(m3u) ############## ### ogg -> wav count = 0 for file in m3u: count+=1 #TODO: count braucht fuehrende nullen, damit die reihenfolge auf der cd stimmt!! command = "mplayer \""+file+"\" -ao pcm -aofile "+wavdir+"/"+str(count)+".wav &> /dev/null" print "\nexec: "+command session = os.popen(command,"w") session.write("") session.flush() session.close() ######################### ### wav -> normalized wav wavefiles = os.listdir(wavdir) for wave in wavefiles: command = "transcode -J normalize -y wav -i "+wavdir+"/"+wave+" -m "+wavdir+"/"+ wave+".norm &> /dev/null" print "\nexec: "+command session = os.popen(command,"w") session.write("") session.flush() session.close() ################## ### wav -> audiocd command = "sudo cdrecord -v -dev="+recorder+" -pad -audio "+wavdir+"/*.wav.norm" print "\nexec: "+command session = os.popen(command,"w") session.write("") session.flush() session.close() print "\n That's it! Eine Stunde coden und dafuer jetzt den Sommer geniessen..."