CD Burning

  • Thread starter Albert Leibbrandt
  • Start date
A

Albert Leibbrandt

Hi

Can anybody tell me which windows API or python module they are using
for writing cd's / dvd's with python?

Thanks
Albert
 
S

Sybren Stuvel

Albert Leibbrandt enlightened us with:
Can anybody tell me which windows API or python module they are
using for writing cd's / dvd's with python?

I'd install cygwin and use cdrecord. That seems the easiest way to go
about burning disks to me.

Sybren
 
H

hugonz

Hi,

I used cdrecord, albeit on Linux, to do it. Someone already suggested
to use Cygwin for that.

I'll just drop a piece of code I wrote for getting the percentage of
advance when recording sound, with cdrecord. Here it is (wraps
cdrecord):

#!/usr/bin/env python
"""
Canonizer: will open up a program and try to canonize its output.

Output is program dependent (different information is needed) but
always
canonical (messages are one line long, and parsable through splitting)

Currently only cdrecord will be implemented, but will be tailored for
anything.


Usage:

canonizer.py <myprogram and options>


"""

import re
import sys
import os


track_regexp = re.compile(r"^Track\s+(\d+):\s+(\d+)\s+of\s+(\d+)")
total_regexp = re.compile(r"^Total size:\s+(\d+)")
fixating_regexp = re.compile(r"^Fixating\.")
done_regexp = re.compile(r"^Fixating time")


def loop_cdrecord(filep):
"""Loop over cdrecord's output"""
mycharbuf = ""


exitstatus = ""
burning = 0

#progress in Mbytes
progress = 0
newinterval = oldinterval = 0

while True:
data = filep.read(1)

if not data:
return exitstatus
mycharbuf+= data

if mycharbuf.endswith("\n") or mycharbuf.endswith("\r"):
#sys.stdout.write(mycharbuf)
#sys.stdout.flush()
mycharbuf = mycharbuf[:-1]

if not burning:
try:
totalsize =
int(total_regexp.match(mycharbuf).group(1))
burning = 1
except:
pass
else:
if (track_regexp.search(mycharbuf)):
reobj = track_regexp.match(mycharbuf)
mytrack, mynum, mydem = reobj.group(1, 2, 3)
oldinterval = newinterval
newinterval = int(mynum)
if (oldinterval <= newinterval):
progress += newinterval - oldinterval
else:
oldinterval = 0

print "CAN_PERCENT = %d"%((progress*98)/totalsize)

elif (fixating_regexp.search(mycharbuf)):
print "CAN_PERCENT = %d"%(98)
print "CAN_FIXATING"

elif (done_regexp.search(mycharbuf)):
progress = 100
print "CAN_PERCENT = %d"%(100)
exitstatus = "ok"
print "CAN_DONE"

sys.stdout.flush()

mycharbuf = ""

commandline = ""

#for i in sys.argv:
# print i

#Get the intended commandline
for i in sys.argv[1:]:
commandline += " " + i

pipe_filep = os.popen (commandline, "r")

exitstatus = loop_cdrecord(pipe_filep)

if (exitstatus != "ok"):
print "CAN_ERROR"
 
T

Tim Golden

Albert said:
Hi

Can anybody tell me which windows API or python module they are using
for writing cd's / dvd's with python?

Other people have offered sound suggestions about using
cdrecord etc. under Cygwin. Just to make the point, though,
XP (and above, presumably) does have an inbuilt interface
for burning CDs. I've never used it, and I don't know how feasible
it would be to access it from Python. (Helpful, eh?)

The interface is ICDBurn and it should be possible to wrap
it with ctypes / ctypes.com but I haven't the time at the
moment to try it out. (And I haven't a CD writer in this machine
either!)

Ultimately, it might still be easier to install Cygwin and use
the cdrecord approach. I just wanted to make the point that
there *was* an in-built mechanism.

ICDBurn:
http://msdn.microsoft.com/library/d...rm/shell/reference/ifaces/icdburn/icdburn.asp
ctypes.com: http://starship.python.net/crew/theller/ctypes/com.html

TJG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top