summaryrefslogtreecommitdiff
path: root/hacks/splitchapters
blob: 1e5cff084796423c6a7e44900ad759260221a3e8 (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
25
26
27
28
29
30
#!/usr/bin/python

import os
import sys

if len(sys.argv) < 2:
    print 'Syntax: %s <DVD-image>' % sys.argv[0]
    sys.exit(1)

lsdvd = os.popen('lsdvd -c "%s"' % sys.argv[1])
lines = lsdvd.readlines()

N = None

for l in lines:
    w = l.split()
    if len(w) > 5 and w[4] == 'Chapters:':
        N = int(w[5][:-1])

if N == None:
    print 'Could not get chapter count.'
    sys.exit(1)

for i in range(1, N + 1):
    os.mkdir('%d' % i)
    c = 'mplayer dvd:// -chapter %d-%d -dvd-device "%s" -dumpstream -dumpfile %d/%d.vob' % (i, i, sys.argv[1], i, i)
    print c
    os.system(c)