1 from Components.config import config, ConfigSubsection, ConfigSubList, ConfigInteger, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence, ConfigYesNo
3 class ConfigFixedText(ConfigText):
4 def __init__(self, text, visible_width=60):
5 ConfigText.__init__(self, default = text, fixed_size = True, visible_width = visible_width)
6 def handleKey(self, key):
9 class ConfigActiveTrack(ConfigYesNo):
10 def __init__(self, default = True):
11 ConfigYesNo.__init__(self, default)
15 self.properties = ConfigSubsection()
16 self.properties.menutitle = ConfigText(fixed_size = False, visible_width = 80)
17 self.properties.menusubtitle = ConfigText(fixed_size = False, visible_width = 80)
18 self.DVBname = _("Title")
19 self.DVBdescr = _("Description")
20 self.DVBchannel = _("Channel")
21 self.properties.aspect = ConfigSelection(choices = [("4:3", "4:3"), ("16:9", "16:9")])
22 self.properties.widescreen = ConfigSelection(choices = [("nopanscan", "nopanscan"), ("noletterbox", "noletterbox")])
23 self.properties.audiotracks = ConfigSubList()
27 self.estimatedDiskspace = 0
30 self.chaptermarks = [ ]
31 self.timeCreate = None
34 def addService(self, service):
36 from enigma import eServiceCenter, iServiceInformation
37 from ServiceReference import ServiceReference
38 from time import localtime, time
40 serviceHandler = eServiceCenter.getInstance()
41 info = serviceHandler.info(service)
42 sDescr = info and " " + info.getInfoString(service, iServiceInformation.sDescription) or ""
43 self.DVBdescr = sDescr
44 sTimeCreate = info.getInfo(service, iServiceInformation.sTimeCreate)
46 self.timeCreate = localtime(sTimeCreate)
47 serviceref = ServiceReference(info.getInfoString(service, iServiceInformation.sServiceref))
48 name = info and info.getName(service) or "Title" + sDescr
50 self.DVBchannel = serviceref.getServiceName()
51 self.inputfile = service.getPath()
52 self.filesize = path.getsize(self.inputfile)
53 self.estimatedDiskspace = self.filesize
54 self.length = info.getLength(service)
56 def initDVDmenuText(self, project, track):
57 self.properties.menutitle.setValue(self.formatDVDmenuText(project.settings.titleformat.getValue(), track))
58 self.properties.menusubtitle.setValue(self.formatDVDmenuText(project.settings.subtitleformat.getValue(), track))
60 def formatDVDmenuText(self, template, track):
61 properties = self.properties
62 template = template.replace("$i", str(track))
63 template = template.replace("$t", self.DVBname)
64 template = template.replace("$d", self.DVBdescr)
65 template = template.replace("$c", str(len(self.chaptermarks)+1))
66 template = template.replace("$f", self.inputfile)
67 template = template.replace("$C", self.DVBchannel)
69 #if template.find("$A") >= 0:
70 from TitleProperties import languageChoices
72 for audiotrack in self.properties.audiotracks:
73 active = audiotrack.active.getValue()
75 trackstring = audiotrack.format.getValue()
76 language = audiotrack.language.getValue()
77 if languageChoices.langdict.has_key(language):
78 trackstring += ' (' + languageChoices.langdict[language] + ')'
79 audiolist.append(trackstring)
80 audiostring = ', '.join(audiolist)
81 template = template.replace("$A", audiostring)
83 if template.find("$l") >= 0:
85 lengthstring = "%d:%02d:%02d" % (l/3600, l%3600/60, l%60)
86 template = template.replace("$l", lengthstring)
88 template = template.replace("$Y", str(self.timeCreate[0]))
89 template = template.replace("$M", str(self.timeCreate[1]))
90 template = template.replace("$D", str(self.timeCreate[2]))
91 timestring = "%d:%02d" % (self.timeCreate[3], self.timeCreate[4])
92 template = template.replace("$T", timestring)
94 template = template.replace("$Y", "").replace("$M", "").replace("$D", "").replace("$T", "")
97 def produceFinalCuesheet(self):
108 self.chaptermarks = [ ]
110 # our demuxer expects *strictly* IN,OUT lists.
111 currently_in = not any(type == CUT_TYPE_IN for pts, type in self.cuesheet)
113 self.cutlist.append(0) # emulate "in" at first
115 for (pts, type) in self.cuesheet:
116 #print "pts=", pts, "type=", type, "accumulated_in=", accumulated_in, "accumulated_at=", accumulated_at, "last_in=", last_in
117 if type == CUT_TYPE_IN and not currently_in:
118 self.cutlist.append(pts)
122 if type == CUT_TYPE_OUT and currently_in:
123 self.cutlist.append(pts)
125 # accumulate the segment
126 accumulated_in += pts - last_in
130 if type == CUT_TYPE_MARK and currently_in:
131 # relocate chaptermark against "in" time. This is not 100% accurate,
132 # as the in/out points are not.
133 reloc_pts = pts - last_in + accumulated_in
134 self.chaptermarks.append(reloc_pts)
136 if len(self.cutlist) > 1:
137 part = accumulated_in / (self.length*90000.0)
138 usedsize = int ( part * self.filesize )
139 self.estimatedDiskspace = usedsize
140 self.length = accumulated_in / 90000
142 def produceAutoChapter(self, minutes):
143 if len(self.chaptermarks) < 1:
144 chapterpts = self.cutlist[0]
145 while chapterpts < self.length*90000:
146 chapterpts += 90000 * 60 * minutes
147 self.chaptermarks.append(chapterpts)
149 def getChapterMarks(self):
151 for p in self.chaptermarks:
152 h = p / (90000 * 3600)
153 m = p % (90000 * 3600) / (90000 * 60)
154 s = p % (90000 * 60) / 90000
155 ms = (p % 90000) / 90
156 timestamps.append("%d:%02d:%02d.%03d" % (h, m, s, ms))