init
[open-duckbox-project-sh4:theseus-tdt.git] / tdt / cvs / apps / enigma2 / lib / python / Plugins / Extensions / DVDBurn / TitleCutter.py
1 from Plugins.Extensions.CutListEditor.plugin import CutListEditor
2 from Components.ServiceEventTracker import ServiceEventTracker
3 from enigma import iPlayableService, iServiceInformation
4 from Tools.Directories import fileExists
5
6 class TitleCutter(CutListEditor):
7         def __init__(self, session, t):
8                 CutListEditor.__init__(self, session, t.source)
9                 self.skin = CutListEditor.skin
10                 self.session = session
11                 self.t = t
12                 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
13                         {
14                                 iPlayableService.evUpdatedInfo: self.getPMTInfo,
15                                 iPlayableService.evCuesheetChanged: self.refillList
16                         })
17                 self.onExecBegin.remove(self.showTutorial)
18
19         def getPMTInfo(self):
20                 service = self.session.nav.getCurrentService()
21                 audio = service and service.audioTracks()
22                 n = audio and audio.getNumberOfTracks() or 0
23                 if n > 0:
24                         from DVDTitle import ConfigFixedText
25                         from TitleProperties import languageChoices
26                         from Components.config import config, ConfigSubsection, ConfigSubList, ConfigSelection, ConfigYesNo
27                         self.t.properties.audiotracks = ConfigSubList()
28                         for x in range(n):
29                                 i = audio.getTrackInfo(x)
30                                 DVB_lang = i.getLanguage()
31                                 description = i.getDescription()
32                                 pid = str(i.getPID())
33                                 if description == "MPEG":
34                                         description = "MP2"
35                                 print "[audiotrack] pid:", pid, "description:", description, "language:", DVB_lang
36                                 self.t.properties.audiotracks.append(ConfigSubsection())
37                                 self.t.properties.audiotracks[-1].active = ConfigYesNo(default = True)
38                                 self.t.properties.audiotracks[-1].format = ConfigFixedText(description)
39                                 self.t.properties.audiotracks[-1].language = ConfigSelection(choices = languageChoices.choices, default=languageChoices.getLanguage(DVB_lang))
40                                 self.t.properties.audiotracks[-1].pid = ConfigFixedText(pid)
41                                 self.t.properties.audiotracks[-1].DVB_lang = ConfigFixedText(DVB_lang)
42                 sAspect = service.info().getInfo(iServiceInformation.sAspect)
43                 if sAspect in ( 1, 2, 5, 6, 9, 0xA, 0xD, 0xE ):
44                         aspect = "4:3"
45                 else:
46                         aspect = "16:9"
47                 self.t.properties.aspect.setValue(aspect)
48                 self.t.VideoType = service.info().getInfo(iServiceInformation.sVideoType)
49
50         def checkAndGrabThumb(self):
51                 if not fileExists(self.t.inputfile.rsplit('.',1)[0] + ".png"):
52                         CutListEditor.grabFrame(self)
53
54         def exit(self):
55                 self.checkAndGrabThumb()
56                 self.session.nav.stopService()
57                 self.close(self.cut_list[:])
58
59 class CutlistReader(TitleCutter):
60         def __init__(self, session, t):
61                 TitleCutter.__init__(self, session, t)
62
63         def getPMTInfo(self):
64                 TitleCutter.getPMTInfo(self)
65                 TitleCutter.checkAndGrabThumb(self)
66                 self.close(self.cut_list[:])