Ejemplo n.º 1
0
 def getSeekPlayPosition(self):
     try:
         # InfoBarCueSheetSupport
         return self.cueGetCurrentPosition() or 0
     except Exception, e:
         emcDebugOut("[EMCMC] getSeekPlayPosition exception:" + str(e))
         return 0
	def uploadCuesheet(self):
		try:
			# Always check for saving the last marker
			if config.EMC.movie_save_lastplayed.value is True:
				self.__saveOldLast()

			# Is there native cuesheet support
			cue = InfoBarCueSheetSupport._InfoBarCueSheetSupport__getCuesheet(self)

			if cue is None or (cue and not cue.getCutList()):
				# No native cuesheet support
				# Update local cut list, maybe there is a newer one
				#TODO to be tested
				#self.__readCutFile(True)
				if hasattr(self, "service") and self.service:
					path = self.service.getPath()
					self.__newPath(path)
					self.__writeCutFile()
			else:
				# Native cuesheet support
				if isDreamOS and self.service:
					if self.service.getPath().rsplit('.')[-1] == "mkv":
						path = self.service.getPath()
						self.__newPath(path)
						self.__writeCutFile()
					else:
						cue.setCutList(self.cut_list)
				else:
					cue.setCutList(self.cut_list)
		except Exception, e:
			emcDebugOut("[CUTS] uploadCuesheet exception:" + str(e))
	def showMovies(self):
		try:
			from MovieSelection import EMCSelection
			#self.session.openWithCallback(showMoviesCallback, EMCSelection)
			self.session.open(EMCSelection, returnService=self.service, playerInstance=self)
		except Exception, e:
			emcDebugOut("[EMCPlayer] showMovies exception:\n" + str(e))
	def trashCleanupSetup(self, dummy=None):
		if not os.path.exists(config.EMC.movie_trashcan_path.value):
			try:
				os.makedirs(config.EMC.movie_trashcan_path.value)
			except Exception, e:
				self.session.open(MessageBox, _("Trashcan create failed. Check mounts and permissions."), MessageBox.TYPE_ERROR)
				emcDebugOut("[EMCMS] trashcanCreate exception:\n" + str(e))
	def __readISOFile(self):
		try:
			# Attention: Read can be very slow !!!
			name = ""
			path = self.iso_file
			if path and os.path.exists(path) and path.endswith(".iso"):
				mtime = os.path.getmtime(path)
				if self.iso_mtime == mtime:
					# File has not changed
					pass

				else:
					#print "EMC TEST count Eit " + str(path)

					# New path or file has changed
					self.iso_mtime = mtime

					# Read data from file
					f = None
					try:
						f = open(path, 'rb')
						# This is very slow
						# Any ideas do speed up
						f.seek(0x10019)
						name = f.readline()
					except Exception, e:
						emcDebugOut("[ISO] Exception in __readISOFile: " + str(e))
					finally:
						if f is not None:
							f.close()

					# Parse the name
					self.iso_name = name.split('\0')[0]
Ejemplo n.º 6
0
    def getMetaTitle(self):
        #TODO make it better and --> for example get the right title from other meta like "title only"
        title = ""
        desc = self.getMetaDescription()
        try:
            x1 = len(desc.split(',', -1)) - 1
            x2 = x1 - 1
            title = desc.replace(desc.split(',', -1)[x1],
                                 '').replace(desc.split(',', -1)[x2],
                                             '').replace(',,', '')
            if title == ",":
                if re.match('(\w+(?:/\w+|)(?:/\w+|)(?:/\w+|)(?:/\w+|)\s\d{4})',
                            desc.rsplit(',', 1)[1].strip(), re.S):
                    title = ''
                else:
                    if len(desc) > 50:
                        title = desc[:47] + "..."
                    else:
                        title = desc
            elif (len(title) >= 50) or (len(title) < 3):
                if len(desc) > 50:
                    title = desc[:47] + "..."
                else:
                    title = desc

        except Exception, e:
            emcDebugOut("[EMC] getMetaTitle failed !!!\n" + str(e))
def pluginOpen(session, *args, **kwargs):
    try:
        from EnhancedMovieCenter import EnhancedMovieCenterMenu

        session.open(EnhancedMovieCenterMenu)
    except Exception, e:
        emcDebugOut("[pluginOpen] exception:\n" + str(e))
def autostart(reason, **kwargs):
    if reason == 0:  # start
        if kwargs.has_key("session"):
            global gSession
            from EnhancedMovieCenter import EMCStartup

            gSession = kwargs["session"]
            EMCStartup(gSession)
            emcTasker.Initialize(gSession)

            if not config.EMC.ml_disable.value:
                try:
                    from Screens.InfoBar import InfoBar

                    value = config.EMC.movie_launch.value
                    if value == "showMovies":
                        InfoBar.showMovies = showMoviesNew
                    elif value == "showTv":
                        InfoBar.showTv = showMoviesNew
                    elif value == "showRadio":
                        InfoBar.showRadio = showMoviesNew
                    elif value == "openQuickbutton":
                        InfoBar.openQuickbutton = showMoviesNew
                    elif value == "timeshiftStart":
                        InfoBar.startTimeshift = showMoviesNew
                except Exception, e:
                    emcDebugOut("[spStartup] MovieCenter launch override exception:\n" + str(e))
	def downloadCuesheet(self):
		try:
			service = hasattr(self, "service") and self.service
			
			# Is there native cuesheet support
			cue = self.__getCuesheet() #InfoBarCueSheetSupport._InfoBarCueSheetSupport__getCuesheet(self)
			if cue:
				# Native cuesheet support
				self.cut_list = cue.getCutList()
			else:
				# No native cuesheet support
				if service:
					path = service.getPath()
					self.__newPath(path)
					self.__readCutFile()
			
			#print "CUTSTEST0 ", self.cut_list
			if config.EMC.cutlist_at_download.value:
				if service and hasCutlistDownloader:
					try:
						bestCutlist(service, self.cutlistDownloaded)
					except Exception, e:
						emcDebugOut("[EMC] Plugin CutlistDownloader exception:" + str(e))
			
			#MAYBE: If the cutlist is empty we can check the EPG NowNext Events
		except Exception, e:
			emcDebugOut("[CUTS] downloadCutList exception:" + str(e))
	def showMovies(self):
		try:
			from MovieSelection import EMCSelection
			#self.session.openWithCallback(showMoviesCallback, EMCSelection)
			self.session.open(EMCSelection, returnService=self.service, playerInstance=self)
		except Exception, e:
			emcDebugOut("[EMCPlayer] showMovies exception:\n" + str(e))
	def __readEitFile(self):
		data = ""
		path = self.eit_file
		
		#lang = language.getLanguage()[:2]
		lang = language_iso639_2to3( config.EMC.epglang.value.lower()[:2] )

		if path and os.path.exists(path):
			mtime = os.path.getmtime(path)
			if self.eit_mtime == mtime:
				# File has not changed
				pass

			else:
				#print "EMC TEST count Eit " + str(path)

				# New path or file has changed
				self.eit_mtime = mtime

				# Read data from file
				# OE1.6 with Pyton 2.6
				#with open(self.eit_file, 'r') as file: lines = file.readlines()
				f = None
				try:
					f = open(path, 'rb')
					#lines = f.readlines()
					data = f.read()
				except Exception, e:
					emcDebugOut("[META] Exception in readEitFile: " + str(e))
				finally:
					if f is not None:
	def __readCutFileWithPath(self, path, update=False):
		data = ""
		if path and os.path.exists(path):
			mtime = os.path.getmtime(path)
			if self.cut_mtime == mtime:
				# File has not changed
				pass
				
			else:
				# New path or file has changed
				self.cut_mtime = mtime
				
				if not update:
					# No update clear all
					self.cut_list = []
				
				# Read data from file
				# OE1.6 with Pyton 2.6
				#with open(path, 'rb') as f: data = f.read()	
				f = None
				try:
					f = open(path, 'rb')
					data = f.read()
				except Exception, e:
					emcDebugOut("[CUTS] Exception in __readCutFile: " + str(e))
				finally:
def showMoviesNew(dummy_self = None):
	try:
		global gSession
		from MovieSelection import EMCSelection
		gSession.openWithCallback(showMoviesCallback, EMCSelection)
	except Exception, e:
		emcDebugOut("[showMoviesNew] exception:\n" + str(e))
 def updateFromCuesheet(self):
     print "Cutlist updateCuesheet"
     try:
         # Use non native cuesheet support
         self.__readCutFile(True)
     except Exception, e:
         emcDebugOut("[CUTS] updateCuesheet exception:" + str(e))
	def updateFromCuesheet(self):
		print "Cutlist updateCuesheet"
		try:
			# Use non native cuesheet support
			self.__readCutFile(True)
		except Exception, e:
			emcDebugOut("[CUTS] updateCuesheet exception:" + str(e))
 def __writePermanentSortCfgFile(self, data):
     f = None
     try:
         f = open(CFG_FILE, "wb")
         pickle.dump(data, f)
     except Exception, e:
         emcDebugOut("[EMC] Exception in writePermanentSortCfgFile: " + str(e))
def autostart(reason, **kwargs):
    if reason == 0:  # start
        if kwargs.has_key("session"):
            global gSession
            from EnhancedMovieCenter import EMCStartup
            gSession = kwargs["session"]
            EMCStartup(gSession)
            emcTasker.Initialize(gSession)

            if not config.EMC.ml_disable.value:
                try:
                    from Screens.InfoBar import InfoBar
                    value = config.EMC.movie_launch.value
                    if value == "showMovies":
                        InfoBar.showMovies = showMoviesNew
                    elif value == "showTv":
                        InfoBar.showTv = showMoviesNew
                    elif value == "showRadio":
                        InfoBar.showRadio = showMoviesNew
                    elif value == "openQuickbutton":
                        InfoBar.openQuickbutton = showMoviesNew
                    elif value == "timeshiftStart":
                        InfoBar.startTimeshift = showMoviesNew
                except Exception, e:
                    emcDebugOut(
                        "[spStartup] MovieCenter launch override exception:\n"
                        + str(e))
 def setAudioTrack(self):
     try:
         if not config.EMC.autoaudio.value: return
         from Tools.ISO639 import LanguageCodes as langC
         service = self.session.nav.getCurrentService()
         #tracks = service and service.audioTracks()
         tracks = service and self.getServiceInterface("audioTracks")
         nTracks = tracks and tracks.getNumberOfTracks() or 0
         if not nTracks: return
         trackList = []
         for i in xrange(nTracks):
             audioInfo = tracks.getTrackInfo(i)
             lang = audioInfo.getLanguage()
             if langC.has_key(lang):
                 lang = langC[lang][0]
             desc = audioInfo.getDescription()
             trackList += [str(lang) + " " + str(desc)]
         for audiolang in [
                 config.EMC.audlang1.value, config.EMC.audlang2.value,
                 config.EMC.audlang3.value
         ]:
             # Joe Debug
             if self.tryAudioEnable(trackList, audiolang, tracks): break
     except Exception, e:
         emcDebugOut("[EMCPlayer] audioTrack exception:\n" + str(e))
Ejemplo n.º 19
0
 def getSeekLength(self):
     try:
         # Call private InfoBarCueSheetSupport function
         seek = InfoBarCueSheetSupport._InfoBarCueSheetSupport__getSeekable(
             self)
     except Exception, e:
         emcDebugOut("[EMCMC] getSeekLength exception:" + str(e))
    def __readMetaFile(self):
        lines = []
        path = self.meta_file
        if path and os.path.exists(path):
            mtime = os.path.getmtime(path)
            if self.meta_mtime == mtime:
                # File has not changed
                pass

            else:
                #print "EMC TEST count Meta " + str(path)

                # New path or file has changed
                self.meta_mtime = mtime

                # Read data from file
                # OE1.6 with Pyton 2.6
                #with open(self.meta_file, 'r') as file: lines = file.readlines()
                f = None
                try:
                    f = open(path, 'r')
                    lines = f.readlines()
                except Exception, e:
                    emcDebugOut("[META] Exception in readMetaFile: " + str(e))
                finally:
	def __writePermanentSortCfgFile(self, data):
		f = None
		try:
			f = open(CFG_FILE, "wb")
			pickle.dump(data, f)
		except Exception, e:
			emcDebugOut("[EMC] Exception in writePermanentSortCfgFile: " + str(e))
	def trashCleanupSetup(self, dummy=None):
		if not os.path.exists(config.EMC.movie_trashcan_path.value):
			try:
				os.makedirs(config.EMC.movie_trashcan_path.value)
			except Exception, e:
				self.session.open(MessageBox, _("Trashcan create failed. Check mounts and permissions."), MessageBox.TYPE_ERROR)
				emcDebugOut("[EMCMS] trashcanCreate exception:\n" + str(e))
	def getSeekPlayPosition(self):
		try:
			# InfoBarCueSheetSupport
			return self.cueGetCurrentPosition() or 0
		except Exception, e:
			emcDebugOut("[EMCMC] getSeekPlayPosition exception:" + str(e))
			return 0
	def __init__(self, callback):
		self.callback = callback

		try:
			NavigationInstance.instance.RecordTimer.on_state_change.append(self.recEvent)
		except Exception, e:
			emcDebugOut("[spRO] Record observer add exception:\n" + str(e))
	def __readISOFile(self):
		try:
			# Attention: Read can be very slow !!!
			name = ""
			path = self.iso_file
			if path and os.path.exists(path) and path.lower().endswith(".iso"):
				mtime = os.path.getmtime(path)
				if self.iso_mtime == mtime:
					# File has not changed
					pass

				else:
					#print "EMC TEST count Eit " + str(path)

					# New path or file has changed
					self.iso_mtime = mtime

					# Read data from file
					f = None
					try:
						f = open(path, 'rb')
						# This is very slow
						# Any ideas do speed up
						f.seek(0x10019)
						name = f.readline()
					except Exception, e:
						emcDebugOut("[ISO] Exception in __readISOFile: " + str(e))
					finally:
						if f is not None:
							f.close()

					# Parse the name
					self.iso_name = name.split('\0')[0]
    def uploadCuesheet(self):
        try:
            # Always check for saving the last marker
            if config.EMC.movie_save_lastplayed.value is True:
                self.__saveOldLast()

            # Is there native cuesheet support
            cue = InfoBarCueSheetSupport._InfoBarCueSheetSupport__getCuesheet(
                self)

            if cue is None or (cue and not cue.getCutList()):
                # No native cuesheet support
                # Update local cut list, maybe there is a newer one
                #TODO to be tested
                #self.__readCutFile(True)
                if hasattr(self, "service") and self.service:
                    path = self.service.getPath()
                    self.__newPath(path)
                    self.__writeCutFile()
            else:
                # Native cuesheet support
                if isDreamOS and self.service:
                    if self.service.getPath().rsplit('.')[-1] == "mkv":
                        path = self.service.getPath()
                        self.__newPath(path)
                        self.__writeCutFile()
                    else:
                        cue.setCutList(self.cut_list)
                else:
                    cue.setCutList(self.cut_list)
        except Exception, e:
            emcDebugOut("[CUTS] uploadCuesheet exception:" + str(e))
	def __readMetaFile(self):
		lines = []
		path = self.meta_file
		if path and os.path.exists(path):
			mtime = os.path.getmtime(path)
			if self.meta_mtime == mtime:
				# File has not changed
				pass

			else:
				#print "EMC TEST count Meta " + str(path)

				# New path or file has changed
				self.meta_mtime = mtime

				# Read data from file
				# OE1.6 with Pyton 2.6
				#with open(self.meta_file, 'r') as file: lines = file.readlines()
				f = None
				try:
					f = open(path, 'r')
					lines = f.readlines()
				except Exception, e:
					emcDebugOut("[META] Exception in readMetaFile: " + str(e))
				finally:
def showMoviesNew(dummy_self=None):
    try:
        global gSession
        from MovieSelection import EMCSelection
        gSession.openWithCallback(showMoviesCallback, EMCSelection)
    except Exception, e:
        emcDebugOut("[showMoviesNew] exception:\n" + str(e))
    def __init__(self, callback):
        self.callback = callback

        try:
            NavigationInstance.instance.RecordTimer.on_state_change.append(
                self.recEvent)
        except Exception, e:
            emcDebugOut("[spRO] Record observer add exception:\n" + str(e))
 def isRemoteRecording(self, filename):
     try:
         if filename[0] == "/": filename = os.path.basename(filename)
         if filename.endswith(".ts"): filename = filename[:-3]
         return filename in self.recRemoteList
     except Exception, e:
         emcDebugOut("[emcRC] isRemoteRecording exception:\n" + str(e))
         return False
def showMoviesCallback(*args):
	try:
		if args:
			global gSession
			from EMCMediaCenter import EMCMediaCenter
			gSession.openWithCallback(playerCallback, EMCMediaCenter, *args)
	except Exception, e:
		emcDebugOut("[showMoviesCallback] exception:\n" + str(e))
	def isRemoteRecording(self, filename):
		try:
			if filename[0] == "/": 			filename = os.path.basename(filename)
			if filename.endswith(".ts"):	filename = filename[:-3]
			return filename in self.recRemoteList
		except Exception, e:
			emcDebugOut("[emcRC] isRemoteRecording exception:\n" + str(e))
			return False
def showMoviesCallback(*args):
    try:
        if args:
            global gSession
            from EMCMediaCenter import EMCMediaCenter
            gSession.openWithCallback(playerCallback, EMCMediaCenter, *args)
    except Exception, e:
        emcDebugOut("[showMoviesCallback] exception:\n" + str(e))
 def remoteInit(self, ip):
     try:
         if not os.path.exists(config.EMC.folder.value):
             emcTasker.shellExecute("mkdir " + config.EMC.folder.value)
         if ip is not None:
             rec = "/db_%s.rec" % str(ip).replace(", ", ".")[1:-1]
             self.recFile = os.path.join(config.EMC.folder.value, rec)
     except Exception, e:
         emcDebugOut("[emcRC] remoteInit exception:\n" + str(e))
 def recFileUpdate(self):
     recf = None
     try:
         if self.recFile is None: self.remoteInit(spNET.whatIsMyIP())
         if self.recFile is None: return  # was not able to get IP
         recf = open(self.recFile, "wb")
         pickle.dump(self.recDict.keys(), recf)
     except Exception, e:
         emcDebugOut("[emcRC] recFileUpdate exception:\n" + str(e))
 def tryAudioEnable(self, alist, match, tracks):
     index = 0
     for e in alist:
         if e.find(match) >= 0:
             emcDebugOut("[EMCPlayer] audio track match: " + str(e))
             tracks.selectTrack(index)
             return True
         index += 1
     return False
	def recFileUpdate(self):
		recf = None
		try:
			if self.recFile is None: self.remoteInit( spNET.whatIsMyIP() )
			if self.recFile is None: return	# was not able to get IP
			recf = open(self.recFile, "wb")
			pickle.dump(self.recDict.keys(), recf)
		except Exception, e:
			emcDebugOut("[emcRC] recFileUpdate exception:\n" + str(e))
	def remoteInit(self, ip):
		try:
			if not os.path.exists(config.EMC.folder.value):
				emcTasker.shellExecute("mkdir " + config.EMC.folder.value)
			if ip is not None:
				rec = "/db_%s.rec" %str(ip).replace(", ", ".")[1:-1]
				self.recFile = os.path.join(config.EMC.folder.value, rec)
		except Exception, e:
			emcDebugOut("[emcRC] remoteInit exception:\n" + str(e))
	def isCutting(self, filename):
		try:
			if filename.endswith("_.ts"):
				if not os.path.exists(filename[:-2]+"eit"):
					return True
			return False
		except Exception, e:
			emcDebugOut("[emcRC] isCutting exception:\n" + str(e))
			return False
 def isCutting(self, filename):
     try:
         if filename.endswith("_.ts"):
             if not os.path.exists(filename[:-2] + "eit"):
                 return True
         return False
     except Exception, e:
         emcDebugOut("[emcRC] isCutting exception:\n" + str(e))
         return False
	def cancel(self):
		try:
			global instanceTab
			instanceTab.remove(self)
			self.timer.stop()
			self.timer.timeout.get().remove(self.timerLaunch)
			self.timer = None
		except Exception, e:
			emcDebugOut("[spDF] timer cancel exception:\n%s:%s" %(str(self.function),str(e)))
Ejemplo n.º 42
0
 def isRecording(self, filename):
     try:
         if filename[0] == "/": filename = os.path.basename(filename)
         if not isDreamOS:
             if filename.lower().endswith(".ts"): filename = filename[:-3]
         return filename in self.recDict
     except Exception, e:
         emcDebugOut("[emcRC] isRecording exception:\n" + str(e))
         return False
	def tryAudioEnable(self, alist, match, tracks):
		index = 0
		for e in alist:
			if e.find(match) >= 0:
				emcDebugOut("[EMCPlayer] audio track match: " + str(e))
				tracks.selectTrack(index)
				return True
			index += 1
		return False
	def setSubtitleState(self, enabled):
		try:
			if not config.EMC.autosubs.value or not enabled: return

			if isDreamOS:
				subs = isinstance(self, InfoBarSubtitleSupport) and self.getCurrentServiceSubtitle() or None
				n = subs and subs.getNumberOfSubtitleTracks() or 0
				if n == 0:
					return
				from enigma import iSubtitleType_ENUMS
				from Screens.AudioSelection import SUB_FORMATS, GST_SUB_FORMATS
				self.sub_format_dict = {}
				self.gstsub_format_dict= {}
				for idx, (short, text, rank) in sorted(SUB_FORMATS.items(), key=lambda x: x[1][2]):
					if rank > 0:
						self.sub_format_dict[idx] = short
				for idx, (short, text, rank) in sorted(GST_SUB_FORMATS.items(), key=lambda x: x[1][2]):
					if rank > 0:
						self.gstsub_format_dict[idx] = short
				lt = []
				l = []
				for idx in range(n):
					info = subs.getSubtitleTrackInfo(idx)
					languages = info.getLanguage().split('/')
					print "lang",languages
					iType = info.getType()
					print "type",iType
					if iType == iSubtitleType_ENUMS.GST:
						iType = info.getGstSubtype()
						codec = iType in self.gstsub_format_dict and self.gstsub_format_dict[iType] or "?"
					else:
						codec = iType in self.sub_format_dict and self.sub_format_dict[iType] or "?"
					print "codec",codec

					lt.append((idx, (iType == 1 and "DVB" or iType == 2 and "TTX" or "???"), languages))
				if lt:
					print lt
					for e in lt:
						l.append((e[0], e[1], langC.has_key(e[2][0]) and langC[e[2][0]][0] or e[2][0]))
						if l:
							print l
							for sublang in [config.EMC.sublang1.value, config.EMC.sublang2.value, config.EMC.sublang3.value]:
								if self.trySubEnable(l, sublang): break
			else:
				subs = self.getCurrentServiceSubtitle() or self.getServiceInterface("subtitle")
				if subs:
					print "############################subs"
					print subs.getSubtitleList()
					lt = [ (e, (e[0] == 0 and "DVB" or e[0] == 1 and "TXT" or "???")) for e in (subs and subs.getSubtitleList() or []) ]
					if lt:
						l = [ [e[0], e[1], langC.has_key(e[0][4]) and langC[e[0][4]][0] or e[0][4] ] for e in lt ]
						if l:
							print l
							for sublang in [config.EMC.sublang1.value, config.EMC.sublang2.value, config.EMC.sublang3.value]:
								if self.trySubEnable(l, sublang): break
		except Exception, e:
			emcDebugOut("[EMCPlayer] setSubtitleState exception:\n" + str(e))
	def setSubtitleState(self, enabled):
		try:
			if not config.EMC.autosubs.value or not enabled: return

			if isDreamOS:
				subs = isinstance(self, InfoBarSubtitleSupport) and self.getCurrentServiceSubtitle() or None
				n = subs and subs.getNumberOfSubtitleTracks() or 0
				if n == 0:
					return
				from enigma import iSubtitleType_ENUMS
				from Screens.AudioSelection import SUB_FORMATS, GST_SUB_FORMATS
				self.sub_format_dict = {}
				self.gstsub_format_dict= {}
				for idx, (short, text, rank) in sorted(SUB_FORMATS.items(), key=lambda x: x[1][2]):
					if rank > 0:
						self.sub_format_dict[idx] = short
				for idx, (short, text, rank) in sorted(GST_SUB_FORMATS.items(), key=lambda x: x[1][2]):
					if rank > 0:
						self.gstsub_format_dict[idx] = short
				lt = []
				l = []
				for idx in range(n):
					info = subs.getSubtitleTrackInfo(idx)
					languages = info.getLanguage().split('/')
					print "lang",languages
					iType = info.getType()
					print "type",iType
					if iType == iSubtitleType_ENUMS.GST:
						iType = info.getGstSubtype()
						codec = iType in self.gstsub_format_dict and self.gstsub_format_dict[iType] or "?"
					else:
						codec = iType in self.sub_format_dict and self.sub_format_dict[iType] or "?"
					print "codec",codec

					lt.append((idx, (iType == 1 and "DVB" or iType == 2 and "TTX" or "???"), languages))
				if lt:
					print lt
					for e in lt:
						l.append((e[0], e[1], langC.has_key(e[2][0]) and langC[e[2][0]][0] or e[2][0]))
						if l:
							print l
							for sublang in [config.EMC.sublang1.value, config.EMC.sublang2.value, config.EMC.sublang3.value]:
								if self.trySubEnable(l, sublang): break
			else:
				subs = self.getCurrentServiceSubtitle() or self.getServiceInterface("subtitle")
				if subs:
					print "############################subs"
					print subs.getSubtitleList()
					lt = [ (e, (e[0] == 0 and "DVB" or e[0] == 1 and "TXT" or "???")) for e in (subs and subs.getSubtitleList() or []) ]
					if lt:
						l = [ [e[0], e[1], langC.has_key(e[0][4]) and langC[e[0][4]][0] or e[0][4] ] for e in lt ]
						if l:
							print l
							for sublang in [config.EMC.sublang1.value, config.EMC.sublang2.value, config.EMC.sublang3.value]:
								if self.trySubEnable(l, sublang): break
		except Exception, e:
			emcDebugOut("[EMCPlayer] setSubtitleState exception:\n" + str(e))
	def isRecording(self, filename):
		try:
			if filename[0] == "/": 			filename = os.path.basename(filename)
			if not isDreamOS:
				if filename.lower().endswith(".ts"):
					filename = filename[:-3]
			return filename in self.recDict
		except Exception, e:
			emcDebugOut("[emcRC] isRecording exception:\n" + str(e))
			return False
	def trySubEnable(self, slist, match):
		for e in slist:
			if match == e[2]:
				emcDebugOut("[EMCPlayer] subtitle match: " + str(e))
				if self.selected_subtitle != e[0]:
					self.subtitles_enabled = False
					self.selected_subtitle = e[0]
					self.subtitles_enabled = True
					return True
		return False
Ejemplo n.º 48
0
def getAudioFileSize(path):
	size = 0
	if not os.path.exists(path):
		return size
	try:
		if path:
			size += os.path.getsize(path)
			size /= (1024.0 * 1024.0)
	except Exception, e:
		emcDebugOut("[EMCMutagenSupport] Exception in getFileSize: " + str(e))
	def __onClose(self):
		if self.picload:
			del self.picload
		if self.lastservice:
			self.session.nav.playService(self.lastservice)
		# Record events
		try:
			NavigationInstance.instance.RecordTimer.on_state_change.remove(self.recEvent)
		except Exception, e:
			emcDebugOut("[EMCMediaCenter] Record observer remove exception:\n" + str(e))
	def __onClose(self):
		if self.picload:
			del self.picload
		if self.lastservice:
			self.session.nav.playService(self.lastservice)
		# Record events
		try:
			NavigationInstance.instance.RecordTimer.on_state_change.remove(self.recEvent)
		except Exception, e:
			emcDebugOut("[EMCMediaCenter] Record observer remove exception:\n" + str(e))
	def getEMCBookmarks(self):
		bm = []
		if os.access(CFG_FILE, os.R_OK):
			f = None
			try:
				f = open(CFG_FILE, "r")
				bm = f.readlines()
			except Exception, e:
				emcDebugOut("[EMCBookmarks] Exception in getEMCBookmarks: " + str(e))
			finally:
Ejemplo n.º 52
0
 def cancel(self):
     try:
         global instanceTab
         instanceTab.remove(self)
         self.timer.stop()
         self.timer.timeout.get().remove(self.timerLaunch)
         self.timer = None
     except Exception, e:
         emcDebugOut("[spDF] timer cancel exception:\n%s:%s" %
                     (str(self.function), str(e)))
 def trySubEnable(self, slist, match):
     for e in slist:
         if match == e[2]:
             emcDebugOut("[EMCPlayer] subtitle match: " + str(e))
             if self.selected_subtitle != e[0]:
                 self.subtitles_enabled = False
                 self.selected_subtitle = e[0]
                 self.subtitles_enabled = True
                 return True
     return False
 def setAudioTrack(self):
     try:
         if not config.EMC.autoaudio.value: return
         #	from Tools.ISO639 import LanguageCodes as langC
         service = self.session.nav.getCurrentService()
         #tracks = service and service.audioTracks()
         tracks = service and self.getServiceInterface("audioTracks")
         nTracks = tracks and tracks.getNumberOfTracks() or 0
         if not nTracks: return
         idx = 0
         trackList = []
         for i in xrange(nTracks):
             audioInfo = tracks.getTrackInfo(i)
             lang = audioInfo.getLanguage()
             #		if langC.has_key(lang):
             #			lang = langC[lang][0]
             desc = audioInfo.getDescription()
             track = idx, lang, desc
             idx += 1
             trackList += [track]
         seltrack = tracks.getCurrentTrack()
         # we need default selected language from image
         # to set the audiotrack if "config.EMC.autoaudio.value" are not set
         from Components.Language import language
         syslang = language.getLanguage()[:2]
         #	syslang = langC[syslang][0]
         if config.EMC.autoaudio.value:
             audiolang = [
                 config.EMC.audlang1.value, config.EMC.audlang2.value,
                 config.EMC.audlang3.value
             ]
             caudiolang = True
         else:
             audiolang = syslang
             caudiolang = False
         useAc3 = config.EMC.autoaudio_ac3.value  # emc has new value, in some images it gives different values for that
         if useAc3:
             matchedAc3 = self.tryAudioTrack(tracks, audiolang, caudiolang,
                                             trackList, seltrack, useAc3)
             if matchedAc3: return
             matchedMpeg = self.tryAudioTrack(tracks, audiolang, caudiolang,
                                              trackList, seltrack, False)
             if matchedMpeg: return
             tracks.selectTrack(0)  # fallback to track 1(0)
             return
         else:
             matchedMpeg = self.tryAudioTrack(tracks, audiolang, caudiolang,
                                              trackList, seltrack, False)
             if matchedMpeg: return
             matchedAc3 = self.tryAudioTrack(tracks, audiolang, caudiolang,
                                             trackList, seltrack, useAc3)
             if matchedAc3: return
             tracks.selectTrack(0)  # fallback to track 1(0)
     except Exception, e:
         emcDebugOut("[EMCPlayer] audioTrack exception:\n" + str(e))
Ejemplo n.º 55
0
	def createDirCB(self, currentPath, name):
		if name is not None:
			name = os.path.join(currentPath, name)
			if os.path.exists(name):
				self.session.open(MessageBox, _("Directory %s already exists!") % (name), MessageBox.TYPE_ERROR)
			else:
				try:
					os.mkdir(name)
				except Exception, e:
					emcDebugOut("[EMCMM] createDir exception:\n" + str(e))
				self.close("reload")
	def infoMovie(self):
		try:
			from MovieSelection import IMDbEventViewSimple
			from ServiceReference import ServiceReference
			service = self.currentlyPlayedMovie()

			evt = self.getCurrentEvent()
			if evt:
				self.session.open(IMDbEventViewSimple, evt, ServiceReference(service))
		except Exception, e:
			emcDebugOut("[EMCPlayer] showMovies detail exception:\n" + str(e))