def __init__(self, service): self.__name = service and service.getName() or "" self.path = path = service and service.getPath() #self.isLink = os.path.islink(path) self.isfile = os.path.isfile(path) isreal = os.path.isdir(path) ext = path and os.path.splitext(path)[1].lower() self.isdir = isreal and hasattr(service, "ext") and ext == "DIR" or False #TODO dynamic or not #if config.EMC.movie_metaload.value: meta = path and MetaList(path) #else: # meta = None #TODO dynamic or not #if config.EMC.movie_eitload.value: eit = path and EitList(path) #else: # eit = None # Information which we need later self.__cutlist = path and CutList(path) or [] #TODO dynamic or not self.__size = self.isfile and os.stat(path).st_size \ or self.isdir and config.EMC.directories_info.value and self.getFolderSize(path) \ or None #TODO or isdvd self.__mtime = self.isfile and hasattr(service, "date") and mktime( service.date.timetuple( )) or None #long(os.stat(path).st_mtime) or 0 #TODO show same time as list #TODO or isdir but show only start date self.__reference = service or "" self.__rec_ref_str = meta and meta.getMetaServiceReference() or "" #TODO dynamic or not self.__shortdescription = meta and meta.getMetaDescription() \ or eit and eit.getEitShortDescription() \ or self.__name self.__tags = meta and meta.getMetaTags() or "" self.__eventname = meta and meta.getMetaName() \ or eit and eit.getEitName() \ or self.__name #TODO dynamic or not # #self.__extendeddescription = meta and meta.getMetaDescription() \ # or eit and eit.getEitDescription() \ # or "" ## meta file has no extendeddescrition # self.__extendeddescription = eit and eit.getEitDescription() \ # or meta and meta.getMetaDescription() \ # or "" #Show txt-Information in ExtendedDescription if meta but no eit self.__extendeddescription = eit and eit.getEitDescription() \ or "" #No Description in *.eit file or no *.eit file exists #Try reading description from *.txt file if not self.__extendeddescription: exts = [".txt"] txtpath = getInfoFile(path, exts)[1] if os.path.exists(txtpath): txtdescarr = open(txtpath).readlines() txtdesc = "" for line in txtdescarr: txtdesc += line self.__extendeddescription = txtdesc elif config.EMC.show_path_extdescr.value: if config.EMC.movie_real_path.value: desc = os.path.realpath(path) else: desc = path # Very bad but there can be both encodings # E2 recordings are always in utf8 # User files can be in cp1252 #TODO Is there no other way? try: desc.decode('utf-8') except UnicodeDecodeError: try: desc = path.decode("cp1252").encode("utf-8") except UnicodeDecodeError: desc = path.decode("iso-8859-1").encode("utf-8") self.__extendeddescription = desc else: # self.__extendeddescription = "No eit or txt file found" self.__extendeddescription = "" self.__id = 0 #TODO move upto ServiceInfo service.cueSheet = self.cueSheet
def __init__(self, service): self.__name = service and service.getName() or "" self.path = path = service and service.getPath() self.isfile = os.path.isfile(path) self.isdir = os.path.isdir(path) ext = path and os.path.splitext(path)[1].lower() meta = path and MetaList(path) eit = path and EitList(path) # Information which we need later self.__cutlist = path and CutList(path) or [] self.__size = self.isfile and os.stat(path).st_size or self.isdir and ( config.EMC.directories_info.value or config.EMC.directories_size_skin.value ) and self.getFolderSize(path) or None self.__mtime = self.isfile and hasattr(service, "date") and mktime( service.date.timetuple()) or None self.__reference = service or "" self.__rec_ref_str = meta and meta.getMetaServiceReference() or "" self.__shortdescription = meta and meta.getMetaDescription( ) or eit and eit.getEitShortDescription() or "" self.__tags = meta and meta.getMetaTags() or "" self.__eventname = meta and meta.getMetaName( ) or eit and eit.getEitName() or self.__name self.__extendeddescription = eit and eit.getEitDescription() or "" #No Description in *.eit file or no *.eit file exists #Try reading description from *.txt file if not self.__extendeddescription: exts = [".txt"] txtpath = getInfoFile(path, exts)[1] # read the playlist-entrys to show the list as overview if ext == ".e2pls": from EMCPlayList import readPlaylist plistdesc = "" plist = readPlaylist(service.getPath()) for x in plist: plistdesc += x self.__extendeddescription = plistdesc else: if os.path.exists(txtpath): txtdescarr = open(txtpath).readlines() txtdesc = "" for line in txtdescarr: txtdesc += line self.__extendeddescription = txtdesc elif config.EMC.show_path_extdescr.value: if config.EMC.movie_real_path.value: desc = os.path.realpath(path) else: desc = path # Very bad but there can be both encodings # E2 recordings are always in utf8 # User files can be in cp1252 #TODO Is there no other way? try: desc.decode('utf-8') except UnicodeDecodeError: try: desc = path.decode("cp1252").encode("utf-8") except UnicodeDecodeError: desc = path.decode("iso-8859-1").encode("utf-8") self.__extendeddescription = desc else: self.__extendeddescription = "" self.__id = 0 service.cueSheet = self.cueSheet
def __init__(self, session, playlist, playall=None, lastservice=None): # The CutList must be initialized very first CutList.__init__(self) Screen.__init__(self, session) HelpableScreen.__init__(self) InfoBarSupport.__init__(self) # Skin self.skinName = "EMCMediaCenter" skin = None CoolWide = getDesktop(0).size().width() if CoolWide == 720: skin = "/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/CoolSkin/EMCMediaCenter_720.xml" elif CoolWide == 1024: skin = "/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/CoolSkin/EMCMediaCenter_1024.xml" elif CoolWide == 1280: skin = "/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/CoolSkin/EMCMediaCenter_1280.xml" if skin: Cool = open(skin) self.skin = Cool.read() Cool.close() self.serviceHandler = ServiceCenter.getInstance() # EMC Source self["Service"] = EMCCurrentService(session.nav, self) # Events self.__event_tracker = ServiceEventTracker(screen=self, eventmap= { # Disabled for tests # If we enable them, the sound will be delayed for about 2 seconds ? iPlayableService.evStart: self.__serviceStarted, iPlayableService.evStopped: self.__serviceStopped, #iPlayableService.evEnd: self.__evEnd, #iPlayableService.evEOF: self.__evEOF, #iPlayableService.evUser: self.__timeUpdated, #iPlayableService.evUser+1: self.__statePlay, #iPlayableService.evUser+2: self.__statePause, iPlayableService.evUser+3: self.__osdFFwdInfoAvail, iPlayableService.evUser+4: self.__osdFBwdInfoAvail, #iPlayableService.evUser+5: self.__osdStringAvail, iPlayableService.evUser+6: self.__osdAudioInfoAvail, iPlayableService.evUser+7: self.__osdSubtitleInfoAvail, iPlayableService.evUser+8: self.__chapterUpdated, iPlayableService.evUser+9: self.__titleUpdated, iPlayableService.evUser+11: self.__menuOpened, iPlayableService.evUser+12: self.__menuClosed, iPlayableService.evUser+13: self.__osdAngleInfoAvail }) # Keymap # self["SeekActions"] = HelpableActionMap(self, "InfobarSeekActions", -1 higher priority # self["MovieListActions"] = HelpableActionMap(self, "InfobarMovieListActions", 0 # self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] , 0 # self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions", 0 # self["CueSheetActions"] = HelpableActionMap(self, actionmap, 1 lower priority # self["InstantExtensionsActions"] = HelpableActionMap(self, "InfobarExtensions", 1 lower priority # self["NumberActions"] = NumberActionMap( [ "NumberActions"], 0 Set by EMC to 2 very lower priority # self["TeletextActions"] = HelpableActionMap(self, "InfobarTeletextActions", 0 Set by EMC to 2 very lower priority # self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions", 0 Set by EMC to 2 very lower priority if config.EMC.movie_exit.value: self["actions"] = HelpableActionMap(self, "CoolPlayerActions", { "leavePlayer": (self.leavePlayer, _("Stop playback")), }) # default priority else: self["actions"] = HelpableActionMap(self, "CoolPlayerActions2", { "leavePlayer": (self.leavePlayer, _("Stop playback")), }) # default priority self["DVDPlayerPlaybackActions"] = HelpableActionMap(self, "EMCDVDPlayerActions", { "dvdMenu": (self.enterDVDMenu, _("show DVD main menu")), #"showInfo": (self.showInfo, _("toggle time, chapter, audio, subtitle info")), "nextChapter": (self.nextChapter, _("forward to the next chapter")), "prevChapter": (self.prevChapter, _("rewind to the previous chapter")), "nextTitle": (self.nextTitle, _("jump forward to the next title")), "prevTitle": (self.prevTitle, _("jump back to the previous title")), "dvdAudioMenu": (self.enterDVDAudioMenu, _("(show optional DVD audio menu)")), "nextAudioTrack": (self.nextAudioTrack, _("switch to the next audio track")), "nextSubtitleTrack": (self.nextSubtitleTrack, _("switch to the next subtitle language")), "nextAngle": (self.nextAngle, _("switch to the next angle")), }, 1) # lower priority # Only enabled if playing a dvd self["DVDPlayerPlaybackActions"].setEnabled(False) self["DVDMenuActions"] = ActionMap(["WizardActions"], { "left": self.keyLeft, "right": self.keyRight, "up": self.keyUp, "down": self.keyDown, "ok": self.keyOk, "back": self.keyBack, }, 2) # lower priority # Only enabled during DVD Menu self["DVDMenuActions"].setEnabled(False) self["GeneralPlayerPlaybackActions"] = HelpableActionMap(self, "EMCGeneralPlayerActions", { "showExtensions": (self.openExtensions, _("view extensions...")), "EMCGreen": (self.CoolAVSwitch, _("Format AVSwitch")), "seekFwd": (self.seekFwd, _("Seek forward")), "seekBack": (self.seekBack, _("Seek backward")), "movieInfo": (self.infoMovie, _("Movie information")), }, 2) # lower priority self["MenuActions"].prio = 2 if "TeletextActions" in self: self["TeletextActions"].prio = 2 self["NumberActions"].prio = 2 # Cover Anzeige self["Cover"] = Pixmap() # DVD Player self["audioLabel"] = Label("") self["subtitleLabel"] = Label("") self["angleLabel"] = Label("") self["chapterLabel"] = Label("") self["anglePix"] = Pixmap() self["anglePix"].hide() self.last_audioTuple = None self.last_subtitleTuple = None self.last_angleTuple = None self.totalChapters = 0 self.currentChapter = 0 self.totalTitles = 0 self.currentTitle = 0 self.in_menu = None self.dvdScreen = None # Further initialization self.firstStart = True self.stopped = False self.closedByDelete = False self.closeAll = False self.lastservice = lastservice or self.session.nav.getCurrentlyPlayingServiceReference() self.playlist = playlist self.playall = playall self.playcount = -1 self.service = None self.picload = ePicLoad() self.picload.PictureData.get().append(self.showCoverCallback) # Record events try: NavigationInstance.instance.RecordTimer.on_state_change.append(self.recEvent) except Exception, e: emcDebugOut("[EMCMediaCenter] Record observer add exception:\n" + str(e))
def __init__(self, session, playlist, playall=None, lastservice=None): # The CutList must be initialized very first CutList.__init__(self) Screen.__init__(self, session) HelpableScreen.__init__(self) InfoBarSupport.__init__(self) # Skin self.skinName = "EMCMediaCenter" skin = None CoolWide = getDesktop(0).size().width() if CoolWide == 720: skin = "/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/CoolSkin/EMCMediaCenter_720.xml" elif CoolWide == 1024: skin = "/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/CoolSkin/EMCMediaCenter_1024.xml" elif CoolWide == 1280: skin = "/usr/lib/enigma2/python/Plugins/Extensions/EnhancedMovieCenter/CoolSkin/EMCMediaCenter_1280.xml" if skin: Cool = open(skin) self.skin = Cool.read() Cool.close() self.serviceHandler = ServiceCenter.getInstance() # EMC Source self["Service"] = EMCCurrentService(session.nav, self) # Events self.__event_tracker = ServiceEventTracker( screen=self, eventmap={ # Disabled for tests # If we enable them, the sound will be delayed for about 2 seconds ? iPlayableService.evStart: self.__serviceStarted, iPlayableService.evStopped: self.__serviceStopped, #iPlayableService.evEnd: self.__evEnd, #iPlayableService.evEOF: self.__evEOF, #iPlayableService.evUser: self.__timeUpdated, #iPlayableService.evUser+1: self.__statePlay, #iPlayableService.evUser+2: self.__statePause, iPlayableService.evUser + 3: self.__osdFFwdInfoAvail, iPlayableService.evUser + 4: self.__osdFBwdInfoAvail, #iPlayableService.evUser+5: self.__osdStringAvail, iPlayableService.evUser + 6: self.__osdAudioInfoAvail, iPlayableService.evUser + 7: self.__osdSubtitleInfoAvail, iPlayableService.evUser + 8: self.__chapterUpdated, iPlayableService.evUser + 9: self.__titleUpdated, iPlayableService.evUser + 11: self.__menuOpened, iPlayableService.evUser + 12: self.__menuClosed, iPlayableService.evUser + 13: self.__osdAngleInfoAvail }) # Keymap # self["SeekActions"] = HelpableActionMap(self, "InfobarSeekActions", -1 higher priority # self["MovieListActions"] = HelpableActionMap(self, "InfobarMovieListActions", 0 # self["ShowHideActions"] = ActionMap( ["InfobarShowHideActions"] , 0 # self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions", 0 # self["CueSheetActions"] = HelpableActionMap(self, actionmap, 1 lower priority # self["InstantExtensionsActions"] = HelpableActionMap(self, "InfobarExtensions", 1 lower priority # self["NumberActions"] = NumberActionMap( [ "NumberActions"], 0 Set by EMC to 2 very lower priority # self["TeletextActions"] = HelpableActionMap(self, "InfobarTeletextActions", 0 Set by EMC to 2 very lower priority # self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions", 0 Set by EMC to 2 very lower priority if config.EMC.movie_exit.value: self["actions"] = HelpableActionMap(self, "CoolPlayerActions", { "leavePlayer": (self.leavePlayer, _("Stop playback")), }) # default priority else: self["actions"] = HelpableActionMap(self, "CoolPlayerActions2", { "leavePlayer": (self.leavePlayer, _("Stop playback")), }) # default priority self["DVDPlayerPlaybackActions"] = HelpableActionMap( self, "EMCDVDPlayerActions", { "dvdMenu": (self.enterDVDMenu, _("show DVD main menu")), #"showInfo": (self.showInfo, _("toggle time, chapter, audio, subtitle info")), "nextChapter": (self.nextChapter, _("forward to the next chapter")), "prevChapter": (self.prevChapter, _("rewind to the previous chapter")), "nextTitle": (self.nextTitle, _("jump forward to the next title")), "prevTitle": (self.prevTitle, _("jump back to the previous title")), "dvdAudioMenu": (self.enterDVDAudioMenu, _("(show optional DVD audio menu)")), "nextAudioTrack": (self.nextAudioTrack, _("switch to the next audio track")), "nextSubtitleTrack": (self.nextSubtitleTrack, _("switch to the next subtitle language")), "nextAngle": (self.nextAngle, _("switch to the next angle")), }, 1) # lower priority # Only enabled if playing a dvd self["DVDPlayerPlaybackActions"].setEnabled(False) self["DVDMenuActions"] = ActionMap( ["WizardActions"], { "left": self.keyLeft, "right": self.keyRight, "up": self.keyUp, "down": self.keyDown, "ok": self.keyOk, "back": self.keyBack, }, 2) # lower priority # Only enabled during DVD Menu self["DVDMenuActions"].setEnabled(False) self["GeneralPlayerPlaybackActions"] = HelpableActionMap( self, "EMCGeneralPlayerActions", { "showExtensions": (self.openExtensions, _("view extensions...")), "EMCGreen": (self.CoolAVSwitch, _("Format AVSwitch")), "seekFwd": (self.seekFwd, _("Seek forward")), "seekBack": (self.seekBack, _("Seek backward")), "movieInfo": (self.infoMovie, _("Movie information")), }, 2) # lower priority self["MenuActions"].prio = 2 if "TeletextActions" in self: self["TeletextActions"].prio = 2 self["NumberActions"].prio = 2 # Cover Anzeige self["Cover"] = Pixmap() # DVD Player self["audioLabel"] = Label("") self["subtitleLabel"] = Label("") self["angleLabel"] = Label("") self["chapterLabel"] = Label("") self["anglePix"] = Pixmap() self["anglePix"].hide() self.last_audioTuple = None self.last_subtitleTuple = None self.last_angleTuple = None self.totalChapters = 0 self.currentChapter = 0 self.totalTitles = 0 self.currentTitle = 0 self.in_menu = None self.dvdScreen = None # Further initialization self.firstStart = True self.stopped = False self.closedByDelete = False self.closeAll = False self.lastservice = lastservice or self.session.nav.getCurrentlyPlayingServiceReference( ) self.playlist = playlist self.playall = playall self.playcount = -1 self.service = None self.picload = ePicLoad() self.picload.PictureData.get().append(self.showCoverCallback) # Record events try: NavigationInstance.instance.RecordTimer.on_state_change.append( self.recEvent) except Exception, e: emcDebugOut("[EMCMediaCenter] Record observer add exception:\n" + str(e))