summaryrefslogtreecommitdiffstats
path: root/Demo/sgi/cd/listcd.py
blob: 2cfadb6b5ec25af4b52d1b2c7eb81fc0bc0bfc97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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)):
		start, total = info[i]
		print 'Track', zfill(i+1), triple(start), triple(total)

def triple((a, b, c)):
	return zfill(a) + ':' + zfill(b) + ':' + zfill(c)

def zfill(n):
	s = `n`
	return '0' * (2 - len(s)) + s

main()