Move things round a bit.
[dcpomatic.git] / splitchapters
1 #!/usr/bin/python
2
3 import os
4 import sys
5
6 if len(sys.argv) < 2:
7     print 'Syntax: %s <DVD-image>' % sys.argv[0]
8     sys.exit(1)
9
10 lsdvd = os.popen('lsdvd -c "%s"' % sys.argv[1])
11 lines = lsdvd.readlines()
12
13 N = None
14
15 for l in lines:
16     w = l.split()
17     if len(w) > 5 and w[4] == 'Chapters:':
18         N = int(w[5][:-1])
19
20 if N == None:
21     print 'Could not get chapter count.'
22     sys.exit(1)
23
24 for i in range(1, N + 1):
25     os.mkdir('%d' % i)
26     c = 'mplayer dvd:// -chapter %d-%d -dvd-device "%s" -dumpstream -dumpfile %d/%d.vob' % (i, i, sys.argv[1], i, i)
27     print c
28     os.system(c)
29
30