+ def _duration(me, title, start_chapter, end_chapter):
+ path = OS.path.join(ROOT, me.fn)
+ ntitle = int(program_output(["dvd-info", path, "titles"]))
+ if not 1 <= title <= ntitle:
+ raise ExpectedError("bad title %d for `%s': must be in 1 .. %d" %
+ (title, me.fn, ntitle))
+ if start_chapter is None:
+ durq = "duration:%d" % title
+ else:
+ nch = int(program_output(["dvd-info", path, "chapters:%d" % title]))
+ if end_chapter is None: end_chapter = nch
+ else: end_chapter -= 1
+ if not 1 <= start_chapter <= end_chapter <= nch:
+ raise ExpectedError("bad chapter range %d .. %d for `%s' title %d: "
+ "must be in 1 .. %d" %
+ (start_chapter, end_chapter, me.fn, title, nch))
+ durq = "duration:%d.%d-%d" % (title, start_chapter, end_chapter)
+ duration = int(program_output(["dvd-info", path, durq]))
+ return duration
+