1992-04-13 15:38:20 -03:00
|
|
|
# List track info from CD player.
|
|
|
|
|
|
|
|
import cd
|
|
|
|
|
|
|
|
def main():
|
|
|
|
c = cd.open()
|
|
|
|
info = []
|
|
|
|
while 1:
|
|
|
|
try:
|
|
|
|
info.append(c.gettrackinfo(len(info) + 1))
|
|
|
|
except RuntimeError:
|
|
|
|
break
|
|
|
|
for i in range(len(info)):
|
1992-04-15 13:20:12 -03:00
|
|
|
start, total = info[i]
|
|
|
|
print 'Track', zfill(i+1), triple(start), triple(total)
|
1992-04-13 15:38:20 -03:00
|
|
|
|
1992-04-15 13:20:12 -03:00
|
|
|
def triple((a, b, c)):
|
|
|
|
return zfill(a) + ':' + zfill(b) + ':' + zfill(c)
|
|
|
|
|
|
|
|
def zfill(n):
|
1992-04-13 15:38:20 -03:00
|
|
|
s = `n`
|
|
|
|
return '0' * (2 - len(s)) + s
|
1992-04-14 08:05:59 -03:00
|
|
|
|
|
|
|
main()
|