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):
11 self.properties = ConfigSubsection()
12 self.properties.menutitle = ConfigText(fixed_size = False, visible_width = 80)
13 self.properties.menusubtitle = ConfigText(fixed_size = False, visible_width = 80)
14 self.DVBname = _("Title")
15 self.DVBdescr = _("Description")
16 self.DVBchannel = _("Channel")
17 self.properties.aspect = ConfigSelection(choices = [("4:3", _("4:3")), ("16:9", _("16:9"))])
18 self.properties.widescreen = ConfigSelection(choices = [("nopanscan", "nopanscan"), ("noletterbox", "noletterbox")])
19 self.properties.autochapter = ConfigInteger(default = 0, limits = (0, 60))
20 self.properties.audiotracks = ConfigSubList()
24 self.estimatedDiskspace = 0
27 self.chaptermarks = [ ]
28 self.timeCreate = None
31 def addService(self, service):
33 from enigma import eServiceCenter, iServiceInformation
34 from ServiceReference import ServiceReference
35 from time import localtime, time
37 serviceHandler = eServiceCenter.getInstance()
38 info = serviceHandler.info(service)
39 sDescr = info and " " + info.getInfoString(service, iServiceInformation.sDescription) or ""
40 self.DVBdescr = sDescr
41 sTimeCreate = info.getInfo(service, iServiceInformation.sTimeCreate)
43 self.timeCreate = localtime(sTimeCreate)
44 serviceref = ServiceReference(info.getInfoString(service, iServiceInformation.sServiceref))
45 name = info and info.getName(service) or "Title" + sDescr
47 self.DVBchannel = serviceref.getServiceName()
48 self.inputfile = service.getPath()
49 self.filesize = path.getsize(self.inputfile)
50 self.estimatedDiskspace = self.filesize
51 self.length = info.getLength(service)
53 def initDVDmenuText(self, project, track):
54 s = project.menutemplate.settings
55 self.properties.menutitle.setValue(self.formatDVDmenuText(s.titleformat.getValue(), track))
56 self.properties.menusubtitle.setValue(self.formatDVDmenuText(s.subtitleformat.getValue(), track))
58 def formatDVDmenuText(self, template, track):
59 template = template.replace("$i", str(track))
60 template = template.replace("$t", self.DVBname)
61 template = template.replace("$d", self.DVBdescr)
62 template = template.replace("$c", str(len(self.chaptermarks)+1))
63 template = template.replace("$f", self.inputfile)
64 template = template.replace("$C", self.DVBchannel)
66 #if template.find("$A") >= 0:
67 from TitleProperties import languageChoices
69 for audiotrack in self.properties.audiotracks:
70 active = audiotrack.active.getValue()
72 trackstring = audiotrack.format.getValue()
73 language = audiotrack.language.getValue()
74 if languageChoices.langdict.has_key(language):
75 trackstring += ' (' + languageChoices.langdict[language] + ')'
76 audiolist.append(trackstring)
77 audiostring = ', '.join(audiolist)
78 template = template.replace("$A", audiostring)
80 if template.find("$l") >= 0:
82 lengthstring = "%d:%02d:%02d" % (l/3600, l%3600/60, l%60)
83 template = template.replace("$l", lengthstring)
85 template = template.replace("$Y", str(self.timeCreate[0]))
86 template = template.replace("$M", str(self.timeCreate[1]))
87 template = template.replace("$D", str(self.timeCreate[2]))
88 timestring = "%d:%02d" % (self.timeCreate[3], self.timeCreate[4])
89 template = template.replace("$T", timestring)
91 template = template.replace("$Y", "").replace("$M", "").replace("$D", "").replace("$T", "")
94 def produceFinalCuesheet(self):
105 self.chaptermarks = [ ]
107 # our demuxer expects *strictly* IN,OUT lists.
108 currently_in = not any(type == CUT_TYPE_IN for pts, type in self.cuesheet)
110 self.cutlist.append(0) # emulate "in" at first
112 for (pts, type) in self.cuesheet:
113 #print "pts=", pts, "type=", type, "accumulated_in=", accumulated_in, "accumulated_at=", accumulated_at, "last_in=", last_in
114 if type == CUT_TYPE_IN and not currently_in:
115 self.cutlist.append(pts)
119 if type == CUT_TYPE_OUT and currently_in:
120 self.cutlist.append(pts)
122 # accumulate the segment
123 accumulated_in += pts - last_in
127 if type == CUT_TYPE_MARK and currently_in:
128 # relocate chaptermark against "in" time. This is not 100% accurate,
129 # as the in/out points are not.
130 reloc_pts = pts - last_in + accumulated_in
131 self.chaptermarks.append(reloc_pts)
133 if len(self.cutlist) > 1:
134 part = accumulated_in / (self.length*90000.0)
135 usedsize = int ( part * self.filesize )
136 self.estimatedDiskspace = usedsize
137 self.length = accumulated_in / 90000
139 def getChapterMarks(self, template="$h:$m:$s.$t"):
142 minutes = self.properties.autochapter.getValue()
143 if len(self.chaptermarks) < 1 and minutes > 0:
145 while chapterpts < (self.length-60*minutes)*90000:
146 chapterpts += 90000 * 60 * minutes
147 chapters.append(chapterpts)
149 chapters = self.chaptermarks
151 timestring = template.replace("$h", str(p / (90000 * 3600)))
152 timestring = timestring.replace("$m", ("%02d" % (p % (90000 * 3600) / (90000 * 60))))
153 timestring = timestring.replace("$s", ("%02d" % (p % (90000 * 60) / 90000)))
154 timestring = timestring.replace("$t", ("%03d" % ((p % 90000) / 90)))
155 timestamps.append(timestring)