示例#1
0
    def keyBlue(self):
        printl("", self, "S")

        # now that we know the server we establish global plexInstance
        self.plexInstance = Singleton().getPlexInstance(
            PlexLibrary(self.session, self.current))

        token = self.plexInstance.getNewMyPlexToken()

        if token:
            self.session.openWithCallback(
                self.saveNow, MessageBox,
                (_("myPlex Token:") + "\n%s \n" + _("for the user:"******"\n%s \n" + _("with the id:") + "\n%s") %
                (token, self.current.myplexTokenUsername.value,
                 self.current.myplexId.value), MessageBox.TYPE_INFO)
        else:
            response = self.plexInstance.getLastResponse()
            self.session.openWithCallback(
                self.saveNow, MessageBox,
                (_("Error:") + "\n%s \n" + _("for the user:"******"\n%s") %
                (response, self.current.myplexTokenUsername.value),
                MessageBox.TYPE_INFO)

        printl("", self, "C")
示例#2
0
    def keyYellow(self):
        printl("", self, "S")

        if self.useMappings:
            serverID = self.currentId
            self.session.open(DPS_Mappings, serverID)

        elif self.current.localAuth.value:
            # now that we know the server we establish global plexInstance
            self.plexInstance = Singleton().getPlexInstance(
                PlexLibrary(self.session, self.current))

            ipInConfig = "%d.%d.%d.%d" % tuple(self.current.ip.value)
            token = self.plexInstance.getPlexUserTokenForLocalServerAuthentication(
                ipInConfig)

            if token:
                self.current.myplexLocalToken.value = token
                self.current.myplexLocalToken.save()
                self.session.open(
                    MessageBox,
                    (_("Local Token:") + "\n%s \n" + _("for the user:"******"\n%s") % (token, self.current.myplexTokenUsername.value),
                    MessageBox.TYPE_INFO)
            else:
                response = self.plexInstance.getLastResponse()
                self.session.open(
                    MessageBox,
                    (_("Error:") + "\n%s \n" + _("for the user:"******"\n%s") %
                    (response, self.current.myplexTokenUsername.value),
                    MessageBox.TYPE_INFO)

        printl("", self, "C")
示例#3
0
def registerSkinParamsInstance():
    printl("", "__init__::registerSkinParamsInstance", "S")

    boxResolution = str(getBoxResolution())
    skinName = str(config.plugins.dreamplex.skin.value)
    printl("current skin: " + skinName,
           "__common__::registerSkinParamsInstance", "S")

    # if we are our default we switch automatically between the resolutions
    if skinName == "default":
        if boxResolution == "FHD":
            skinfolder = "/usr/lib/enigma2/python/Plugins/Extensions/DreamPlex/skins/" + config.plugins.dreamplex.skin.value + "_FHD"
        else:
            skinfolder = "/usr/lib/enigma2/python/Plugins/Extensions/DreamPlex/skins/" + config.plugins.dreamplex.skin.value
    else:
        skinfolder = "/usr/lib/enigma2/python/Plugins/Extensions/DreamPlex/skins/" + config.plugins.dreamplex.skin.value

    setSkinFolder(currentSkinFolder=skinfolder)
    printl("current skinfolder: " + skinfolder,
           "__common__::checkSkinResolution", "S")

    configXml = getXmlContent(skinfolder + "/params")
    Singleton().getSkinParamsInstance(configXml)

    printl("", "__init__::registerSkinParamsInstance", "C")
示例#4
0
def writeToLog(dmode, out):
    '''
	singleton handler for the log file
	
	@param dmode: E, W, S, H, A, C, I
	@param out: message string
	@return: none
	'''
    try:
        #=======================================================================
        # if gLogFile is None:
        #	openLogFile()
        #=======================================================================
        instance = Singleton()
        if instance.getLogFileInstance() is "":
            openLogFile()
            gLogFile = instance.getLogFileInstance()
            gLogFile.truncate()
        else:
            gLogFile = instance.getLogFileInstance()

        now = datetime.datetime.now()
        gLogFile.write("%02d:%02d:%02d.%07d " %
                       (now.hour, now.minute, now.second, now.microsecond) +
                       " >>> " + str(dmode) + " <<<  " + str(out) + "\n")
        gLogFile.flush()

    except Exception, ex:
        printl2("Exception(" + str(type(ex)) + "): " + str(ex),
                "__common__::writeToLog", "E")
示例#5
0
def checkSkinResolution():
    printl("", "__init__::checkSkinResolution", "S")

    boxResolution = str(getBoxResolution())
    printl("boxResolution: " + boxResolution,
           "__common__::checkSkinResolution", "S")

    skinResolution = str(getSkinResolution())
    printl("skinResolution: " + skinResolution,
           "__common__::checkSkinResolution", "S")

    if boxResolution == "HD" and skinResolution == "FHD":
        # if there is setup another FHD skin but the box skin is HD we switch automatically to default HD skin to avoid wrong screen size
        # which leads to unconfigurable dreamplex
        skinfolder = "/usr/lib/enigma2/python/Plugins/Extensions/DreamPlex/skins/default"
        printl(
            "switching to default due to mismatch of box and skin resolution!")

        setSkinFolder(currentSkinFolder=skinfolder)
        printl("current skinfolder: " + skinfolder,
               "__common__::checkSkinResolution", "S")

        configXml = getXmlContent(skinfolder + "/params")
        Singleton().getSkinParamsInstance(configXml)

    printl("", "__init__::checkSkinResolution", "C")
示例#6
0
    def playMedia(self):
        printl("", self, "S")

        selection = self.listViewList[self.currentIndex]
        printl("selection: " + str(selection), self, "D")

        if "parentRatingKey" in selection[1]:  # this is the case with shows
            self.show_id = selection[1]['parentRatingKey']
            self.isShow = True
        else:
            self.isShow = False

        self.media_id = selection[1]['ratingKey']
        self.selection = selection
        server = selection[1]['server']

        self.setPoster()

        self.count, self.options, self.server = Singleton().getPlexInstance(
        ).getMediaOptionsToPlay(self.media_id,
                                server,
                                False,
                                myType=selection[1]['tagType'])

        self.selectMedia(self.count, self.options, self.server)

        printl("", self, "C")
示例#7
0
	def loadLibrary(self, params):
		'''
		'''
		printl ("", self, "S")
		printl("params =" + str(params), self, "D")
		
		url = self.g_url
		printl("url: " + str(url), self, "D")
		
		library, tmpAbc, tmpGenres = Singleton().getPlexInstance().getMoviesFromSection(url)

		# sort
		sort = [("by title", None, False), ("by year", "year", True), ("by rating", "rating", True), ]
		
		filter = [("All", (None, False), ("", )), ]
		
		# filter seen unseen
		#filter.append(("Seen", ("viewState", "seen", ), ("", )))
		
		# filter genres
		#if len(tmpGenres) > 0:
			#tmpGenres.sort()
			#filter.append(("Genre", ("genre", True), tmpGenres))
		
		printl ("", self, "C")
		return (library, ("viewMode", "ratingKey", ), None, None, sort, filter)
示例#8
0
def writeToLog(dmode, out):
	"""
	singleton handler for the log file
	
	@param dmode: E, W, S, H, A, C, I
	@param out: message string
	@return: none
	"""
	if config.plugins.dreamplex.writeDebugFile.value:
		try:
			instance = Singleton()
			if instance.getLogFileInstance() is "":
				openLogFile()
				gLogFile = instance.getLogFileInstance()
				gLogFile.truncate()
			else:
				gLogFile = instance.getLogFileInstance()

			now = datetime.datetime.now()
			gLogFile.write("%02d:%02d:%02d.%07d " % (now.hour, now.minute, now.second, now.microsecond) + " >>> " + str(
				dmode) + " <<<  " + str(out) + "\n")
			gLogFile.flush()

		except Exception, ex:
			config.plugins.dreamplex.writeDebugFile.value = False
			config.plugins.dreamplex.debugMode.save()

			printl2("Exception(" + str(type(ex)) + "): " + str(ex), "__common__::writeToLog", "E")
示例#9
0
def openLogFile():
    '''
	singleton instance for logfile
	
	@param: none
	@return: none
	'''
    #printl2("", "openLogFile", "S")

    logDir = config.plugins.dreamplex.logfolderpath.value

    now = datetime.datetime.now()
    try:
        if os.path.exists(logDir + "dreamplex_former.log"):
            os.remove(logDir + "dreamplex_former.log")

        if os.path.exists(logDir + "dreamplex.log"):
            shutil.copy2(logDir + "dreamplex.log",
                         logDir + "dreamplex_former.log")

        instance = Singleton()
        instance.getLogFileInstance(open(logDir + "dreamplex.log", "w"))

    except Exception, ex:
        printl2("Exception(" + str(type(ex)) + "): " + str(ex), "openLogFile",
                "E")
示例#10
0
def registerPlexFonts():
	"""
	registers fonts for skins
	
	@param: none 
	@return none
	"""
	printl2("", "__common__::registerPlexFonts", "S")

	printl2("adding fonts", "__common__::registerPlexFonts", "D")

	tree = Singleton().getSkinParamsInstance()

	for font in tree.findall('font'):
		path = str(font.get('path'))
		printl2("path: " + str(font.get('path')), "__common__::registerPlexFonts", "D")

		size = int(font.get('size'))
		printl2("size: " + str(font.get('size')), "__common__::registerPlexFonts", "D")

		name = str(font.get('name'))
		printl2("name: " + str(font.get('name')), "__common__::registerPlexFonts", "D")

		addFont(path, name, size, False)
		printl2("added => " + name, "__common__::registerPlexFonts", "D")

	printl2("", "__common__::registerPlexFonts", "C")
示例#11
0
def registerPlexFonts():
	"""
	registers fonts for skins
	
	@param: none 
	@return none
	"""
	printl2("", "__common__::registerPlexFonts", "S")

	printl2("adding fonts", "__common__::registerPlexFonts", "I")

	tree = Singleton().getSkinParamsInstance()
	#tree = getXmlContent("/usr/lib/enigma2/python/Plugins/Extensions/DreamPlex/skins/" + config.plugins.dreamplex.skins.value +"/params")
	for font in tree.findall('font'):
		path = str(font.get('path'))
		printl2("path: " + str(font.get('path')), "__common__::registerPlexFonts", "D")

		size = int(font.get('size'))
		printl2("size: " + str(font.get('size')), "__common__::registerPlexFonts", "D")

		name = str(font.get('name'))
		printl2("name: " + str(font.get('name')), "__common__::registerPlexFonts", "D")

		addFont(path, name, size, False)
		printl2("added => " + name, "__common__::registerPlexFonts", "I")

	printl2("", "__common__::registerPlexFonts", "C")
示例#12
0
    def getLibraryDataFromPlex(self, url, nextViewMode, currentViewMode):
        printl("", self, "S")

        printl("nextViewMode: " + str(nextViewMode), self, "D")
        printl("currentViewMode: " + str(currentViewMode), self, "D")
        library = None
        mediaContainer = None

        # MUSIC
        if nextViewMode == "artist":
            library, mediaContainer = Singleton().getPlexInstance(
            ).getMusicByArtist(url)

        elif nextViewMode == "ShowAlbums" or (currentViewMode == "ShowAlbums"
                                              and nextViewMode
                                              == "ShowDirectory"):
            library, mediaContainer = Singleton().getPlexInstance(
            ).getMusicByAlbum(url)

        elif nextViewMode == "ShowTracks":
            library, mediaContainer = Singleton().getPlexInstance(
            ).getMusicTracks(url)

        # MOVIES
        elif nextViewMode == "movie" or (currentViewMode == "ShowMovies"
                                         and nextViewMode == "ShowDirectory"):
            library, mediaContainer = Singleton().getPlexInstance(
            ).getMoviesFromSection(url)

        elif nextViewMode == "mixed":
            library, mediaContainer = Singleton().getPlexInstance(
            ).getMixedContentFromSection(url)

        # SHOWS
        elif nextViewMode == "show":
            library, mediaContainer = Singleton().getPlexInstance(
            ).getShowsFromSection(url)

        elif nextViewMode == "ShowEpisodesDirect":
            library, mediaContainer = Singleton().getPlexInstance(
            ).getEpisodesOfSeason(url, directMode=True)

        elif nextViewMode == "ShowSeasons":
            library, mediaContainer = Singleton().getPlexInstance(
            ).getSeasonsOfShow(url)

        elif nextViewMode == "ShowEpisodes":
            library, mediaContainer = Singleton().getPlexInstance(
            ).getEpisodesOfSeason(url)

        printl("", self, "C")
        return library, mediaContainer
示例#13
0
    def buildPlayerData(self, mediaFileUrl):
        printl("", self, "S")

        Singleton().getPlexInstance().setPlaybackType(str(self.playbackMode))

        if self.isExtraData:
            Singleton().getPlexInstance().setPlaybackType(str(1))

        self.playerData[self.currentIndex] = Singleton().getPlexInstance(
        ).playLibraryMedia(self.media_id, mediaFileUrl)

        # populate addional data
        self.setPlayerData()

        self.playSelectedMedia()

        printl("", self, "C")
示例#14
0
def registerSkinParamsInstance():
    printl("", "__init__::registerSkinParamsInstance", "S")

    configXml = getXmlContent(
        "/usr/lib/enigma2/python/Plugins/Extensions/DreamPlex/skins/" +
        config.plugins.dreamplex.skins.value + "/params")
    Singleton().getSkinParamsInstance(configXml)

    printl("", "__init__::registerSkinParamsInstance", "C")
示例#15
0
	def __init__(self, session, mode, serverConfig=None):
		Screen.__init__(self, session)
		DPH_ScreenHelper.__init__(self)
		DPH_PlexScreen.__init__(self)

		self.guiElements = getGuiElements()

		self.initScreen("syncer")
		self.serverConfig = serverConfig

		self.resolution = getSkinResolution()

		if serverConfig is not None:
			# now that we know the server we establish global plexInstance
			self.plexInstance = Singleton().getPlexInstance(PlexLibrary(self.session, self.serverConfig))

		# we are "sync" or "render"
		self._mode = mode

		# we use the global g_mediaSyncerInfo.instance to take care only having one instance
		self.mediaSyncerInfo = g_mediaSyncerInfo.instance

		self["output"] = ScrollLabel()
		self["progress"] = Label()

		# we use this counter to reset scorll label every x entries to stay responsive
		self.counter = 0

		self["btn_greenText"] = Label()
		if self._mode == "sync":
			self["btn_greenText"].setText(_("Start Sync"))
		else:
			self["btn_greenText"].setText(_("Start Rendering"))
		self["btn_green"] = Pixmap()

		self["btn_blueText"] = Label()
		self["btn_blueText"].setText(_("Background"))
		self["btn_blue"] = Pixmap()

		self["btn_redText"] = Label()
		self["btn_redText"].setText(_("Abort"))
		self["btn_red"] = Pixmap()

		self["setupActions"] = ActionMap(["DPS_Syncer"],
		{
			"red": self.keyRed,
			"blue": self.keyBlue,
			"yellow": self.keyYellow,
			"green": self.keyGreen,
			"bouquet_up": self.keyBouquetUp,
			"bouquet_down": self.keyBouquetDown,
			"cancel": self.exit,
		}, -2)

		self.onFirstExecBegin.append(self.startup)
		self.onShown.append(self.finishLayout)
		self.onClose.append(self.__onClose)
示例#16
0
    def keyRed(self):
        printl("", self, "S")

        if self.useHomeUsers:
            serverID = self.currentId
            plexInstance = Singleton().getPlexInstance(
                PlexLibrary(self.session, self.current))
            self.session.open(DPS_Users, serverID, plexInstance)

        #self.session.open(MessageBox,(_("myPlex Token:") + "\n%s \n" + _("myPlex Localtoken:") + "\n%s \n"+ _("for the user:"******"\n%s") % (self.current.myplexToken.value, self.current.myplexLocalToken.value, self.current.myplexTokenUsername.value), MessageBox.TYPE_INFO)

        printl("", self, "C")
示例#17
0
	def __init__(self, session, g_serverConfig ):
		printl("", self, "S")
		DPH_Screen.__init__(self, session)
		DPH_ScreenHelper.__init__(self)
		DPH_Filter.__init__(self)
		DPH_PlexScreen.__init__(self)

		self.selectionOverride = None
		printl("selectionOverride:" +str(self.selectionOverride), self, "D")
		self.session = session

		self.g_serverConfig = g_serverConfig
		self.plexInstance = Singleton().getPlexInstance()
		self.guiElements = getGuiElements()

		self.initScreen("server_menu")
		self.initMenu()

		if self.g_horizontal_menu:
			self.setHorMenuElements(depth=2)
			self.translateNames()

		self["title"] = StaticText()

		self["menu"]= List(enableWrapAround=True)

		self["actions"] = HelpableActionMap(self, "DP_MainMenuActions",
			{
				"ok":		(self.okbuttonClick, ""),
				"left":		(self.left, ""),
				"right":	(self.right, ""),
				"up":		(self.up, ""),
				"down":		(self.down, ""),
				"cancel":	(self.cancel, ""),
			    "red":		(self.onKeyRed, ""),
			    "green":    (self.onKeyGreen, ""),
			}, -2)

		self["btn_green"]		= Pixmap()
		self["btn_green"].hide()
		self["btn_greenText"]   = Label()

		self["text_HomeUserLabel"]   = Label()
		self["text_HomeUser"]   = Label()

		self.onLayoutFinish.append(self.finishLayout)
		self.onLayoutFinish.append(self.getInitialData)
		self.onLayoutFinish.append(self.checkSelectionOverride)

		printl("", self, "C")
示例#18
0
    def handleProgress(self, EOF=False):
        printl("", self, "S")

        currentTime = self.getPlayPosition()[1] / 90000
        totalTime = self.getPlayLength()[1] / 90000

        if not EOF and currentTime is not None and currentTime > 0 and totalTime is not None and totalTime > 0:
            progress = currentTime / float(totalTime / 100.0)
            printl(
                "played time is %s secs of %s @ %s%%" %
                (currentTime, totalTime, progress), self, "I")
        else:
            progress = 100
            printl("End of file reached", self, "I")

        instance = Singleton()
        plexInstance = instance.getPlexInstance()

        if self.multiUser:
            plexInstance.getTimelineURL(self.server,
                                        "/library/sections/onDeck", self.id,
                                        "stopped", str(currentTime * 1000),
                                        str(totalTime * 1000))

        #Legacy PMS Server server support before MultiUser version v0.9.8.0 and if we are not connected via myPlex
        else:
            if currentTime < 30:
                printl("Less that 30 seconds, will not set resume", self, "I")

            #If we are less than 95% complete, store resume time
            elif progress < 95:
                printl("Less than 95% progress, will store resume time", self,
                       "I")
                plexInstance.doRequest(
                    "http://" + self.server + "/:/progress?key=" + self.id +
                    "&identifier=com.plexapp.plugins.library&time=" +
                    str(currentTime * 1000))

            #Otherwise, mark as watched
            else:
                printl("Movie marked as watched. Over 95% complete", self, "I")
                plexInstance.doRequest(
                    "http://" + self.server + "/:/scrobble?key=" + self.id +
                    "&identifier=com.plexapp.plugins.library")

        if self.multiUser and self.timelinewatcherThread.isAlive():
            self.timelinewatcherthread_wait.set()
            self.timelinewatcherthread_stop.set()

        printl("", self, "C")
示例#19
0
	def playEntry(self, selection):
		printl("-> in DP_ListMain", self, "S")
		media_id = selection[1]['Id']

		server = selection[1]['ArtPoster']
		instance = Singleton()
		plexInstance = instance.getPlexInstance()
		print "server =>" + server
		url = plexInstance.playStream(media_id, server, False)

		sref = eServiceReference(0x1001, 0, str(url))
		sref.setName("DreamPlex")
		self.sref = sref
		self.session.open(DP_Player, sref, self)
示例#20
0
def getGuiElements():
    printl("", "DP_ViewFactory::getGuiElements", "S")

    tree = Singleton().getSkinParamsInstance()

    guiElements = {}
    for guiElement in tree.findall('guiElement'):
        name = str(guiElement.get('name'))
        path = str(guiElement.get('path'))
        guiElements[name] = path

    printl("guiElements: " + str(guiElements),
           "DP_ViewFactory::getGuiElements", "D")
    printl("", "DP_ViewFactory::getGuiElements", "C")
    return guiElements
示例#21
0
    def initMenu(self):
        printl("", self, "S")

        tree = Singleton().getSkinParamsInstance()

        for menuScreen in tree.findall('menuScreen'):
            name = str(menuScreen.get('name'))

            if name == self.screenName:
                myType = str(menuScreen.get('type'))
                if myType == "horizontal":
                    self.g_horizontal_menu = True
                    self.highlightedColor = str(menuScreen.get('highlighted'))
                    self.normalColor = str(menuScreen.get('normal'))

        printl("", self, "C")
示例#22
0
    def keySave(self, stayOpen=False):
        printl("", self, "S")

        if self.newmode == 1:
            config.plugins.dreamplex.entriescount.value += 1
            config.plugins.dreamplex.entriescount.save()

        #if self.current.machineIdentifier.value == "":
        from DP_PlexLibrary import PlexLibrary
        self.plexInstance = Singleton().getPlexInstance(
            PlexLibrary(self.session, self.current))

        machineIdentifiers = ""

        if self.current.connectionType.value == "2":
            xmlResponse = self.plexInstance.getSharedServerForPlexUser()
            machineIdentifier = xmlResponse.get("machineIdentifier")
            if machineIdentifier is not None:
                machineIdentifiers += machineIdentifier

            servers = xmlResponse.findall("Server")
            for server in servers:
                machineIdentifier = server.get("machineIdentifier")
                if machineIdentifier is not None:
                    machineIdentifiers += ", " + machineIdentifier

        else:
            xmlResponse = self.plexInstance.getXmlTreeFromUrl(
                "http://" + self.plexInstance.g_currentServer)
            machineIdentifier = xmlResponse.get("machineIdentifier")
            if machineIdentifier is not None:
                machineIdentifiers += xmlResponse.get("machineIdentifier")

        self.current.machineIdentifier.value = machineIdentifiers
        printl(
            "machineIdentifier: " + str(self.current.machineIdentifier.value),
            self, "D")

        config.plugins.dreamplex.entriescount.save()
        config.plugins.dreamplex.Entries.save()
        config.plugins.dreamplex.save()
        configfile.save()

        if not stayOpen:
            self.close()

        printl("", self, "C")
示例#23
0
    def selectMedia(self, count, options, server):
        printl("", self, "S")

        #if we have two or more files for the same movie, then present a screen
        self.options = options
        self.server = server
        self.dvdplayback = False

        if not self.options:
            response = Singleton().getPlexInstance().getLastResponse()
            self.session.open(MessageBox, (_("Error:") + "\n%s") % response,
                              MessageBox.TYPE_INFO)
        else:
            if count > 1:
                printl("we have more than one playable part ...", self, "I")
                indexCount = 0
                functionList = []

                for items in self.options:
                    printl("item: " + str(items), self, "D")
                    if items[1] is not None:
                        name = items[1].split('/')[-1]
                    else:
                        size = convertSize(int(items[3]))
                        duration = time.strftime('%H:%M:%S',
                                                 time.gmtime(int(items[4])))
                        # this is the case when there is no information of the real file name
                        name = items[0] + " (" + items[
                            2] + " / " + size + " / " + duration + ")"

                    printl("name " + str(name), self, "D")
                    functionList.append((
                        name,
                        indexCount,
                    ))
                    indexCount += 1

                self.session.openWithCallback(self.setSelectedMedia,
                                              ChoiceBox,
                                              title=_("Select media to play"),
                                              list=functionList)

            else:
                self.setSelectedMedia()

            printl("", self, "C")
示例#24
0
    def setSelectedMedia(self, choice=None):
        printl("", self, "S")
        result = 0
        printl("choice: " + str(choice), self, "D")

        if choice is not None:
            result = int(choice[1])

        printl("result: " + str(result), self, "D")

        mediaFileUrl = Singleton().getPlexInstance().mediaType(
            {
                'key': self.options[result][0],
                'file': self.options[result][1]
            }, self.server)
        printl("We have selected media at " + mediaFileUrl, self, "I")

        self.buildPlayerData(mediaFileUrl)

        printl("", self, "C")
示例#25
0
def loadSkinParams():
	printl2("", "__common__::loadSkinParams", "S")

	global skinAuthors
	global skinCompatibility
	global skinResolution
	global skinDebugMode
	global skinHighlightedColor
	global skinNormalColor

	tree = Singleton().getSkinParamsInstance()

	for skinParams in tree.findall('skinParams'):
		skinCompatibility = str(skinParams.get('compatibility'))
		skinAuthors = str(skinParams.get('skinner'))
		skinResolution = str(skinParams.get('resolution'))
		skinDebugMode = str(skinParams.get('debugMode'))
		skinHighlightedColor = str(skinParams.get('highlighted'))
		skinNormalColor = str(skinParams.get('normal'))

	printl2("", "__common__::loadSkinParams", "C")
示例#26
0
    def initScreen(self, screenName):
        printl("", self, "S")

        tree = Singleton().getSkinParamsInstance()

        self.screenName = screenName

        for screen in tree.findall('screen'):
            name = str(screen.get('name'))

            if name == self.screenName:
                self.miniTv = translateValues(str(screen.get('miniTv')))
                if self.miniTv:
                    self.width = screen.get('width')
                    self.height = screen.get('height')
                else:
                    self.Poster = translateValues(str(screen.get('usePoster')))
                    if self.Poster:
                        self.width = screen.get('width')
                        self.height = screen.get('height')

        printl("", self, "C")
示例#27
0
    def stopTranscoding(self):
        printl("", self, "S")

        if self.multiUser:
            self.timelinewatcherthread_wait.set()
            self.timelinewatcherthread_stop.set()

        instance = Singleton()
        plexInstance = instance.getPlexInstance()

        if self.universalTranscoder:
            plexInstance.doRequest(
                "http://" + self.server +
                "/video/:/transcode/universal/stop?session=" +
                self.transcodingSession)
        else:
            plexInstance.doRequest(
                "http://" + self.server +
                "/video/:/transcode/segmented/stop?session=" +
                self.transcodingSession)

        printl("", self, "C")
示例#28
0
    def updateTimeline(self):
        printl("", self, "S")
        try:
            currentTime = self.getPlayPosition()[1] / 90000
            totalTime = self.getPlayLength()[1] / 90000
            progress = int((float(currentTime) / float(totalTime)) * 100)
            if totalTime > 100000:
                return True

            printl("currentTime: " + str(currentTime), self, "C")
            printl("totalTime: " + str(totalTime), self, "C")

            instance = Singleton()
            plexInstance = instance.getPlexInstance()

            seekState = self.seekstate
            if seekState == self.SEEK_STATE_PAUSE:
                printl(
                    "Movies PAUSED time: %s secs of %s @ %s%%" %
                    (currentTime, totalTime, progress), self, "D")
                plexInstance.getTimelineURL(self.server,
                                            "/library/sections/onDeck",
                                            self.id, "paused",
                                            str(currentTime * 1000),
                                            str(totalTime * 1000))

            if seekState == self.SEEK_STATE_PLAY:
                printl(
                    "Movies PLAYING time: %s secs of %s @ %s%%" %
                    (currentTime, totalTime, progress), self, "D")
                plexInstance.getTimelineURL(self.server,
                                            "/library/sections/onDeck",
                                            self.id, "playing",
                                            str(currentTime * 1000),
                                            str(totalTime * 1000))

        except Exception, e:
            printl("exception: " + str(e), self, "E")
            return False
示例#29
0
    def buildPosterData(self):
        printl("", self, "S")

        mediaPath = config.plugins.dreamplex.mediafolderpath.value
        image_prefix = Singleton().getPlexInstance().getServerName().lower()

        self.poster_postfix = "_poster_" + self.width + "x" + self.height + "_v2.jpg"

        if self.isShow:
            self.whatPoster = mediaPath + image_prefix + "_" + self.show_id + self.poster_postfix
        else:
            self.whatPoster = mediaPath + image_prefix + "_" + self.media_id + self.poster_postfix

        printl("what poster: " + self.whatPoster, self, "D")

        printl("builded poster data: " + str(self.whatPoster), self, "D")

        if not fileExists(self.whatPoster):
            self.downloadPoster()

        if config.plugins.dreamplex.lcd4linux.value:
            self.preparePosterForExternalUsage()

        printl("", self, "C")
示例#30
0
    def loadLibrary(self, params):
        printl("", self, "S")
        printl("params: " + str(params), self, "D")

        if self.showEpisodesDirectly:
            printl("show episodes directly ...", self, "I")

            url = self.g_url

            library = Singleton().getPlexInstance().getEpisodesOfSeason(
                url, directMode=True)

            sort = [
                ("by title", None, False),
            ]

            myFilter = [
                ("All", (None, False), ("", )),
            ]

            #filter.append(("Seen", ("Seen", False, 1), ("Seen", "Unseen", )))

            printl("", self, "C")
            return library, (
                "viewMode",
                "ratingKey",
            ), None, "None", sort, myFilter
        else:
            # Diplay all TVShows
            if params["viewMode"] is None:
                printl("show TV shows ...", self, "I")

                url = self.g_url
                printl("url: " + str(url), self, "D")

                if config.plugins.dreamplex.useCache.value:
                    #noinspection PyAttributeOutsideInit
                    self.tvShowPickle = "%s%s_%s_%s.cache" % (
                        config.plugins.dreamplex.cachefolderpath.value,
                        "tvShowSection", self.g_uuid, self.g_viewGroup)

                    # params['cache'] is default None. if it is present and it is False we know that we triggered refresh
                    # for this reason we have to set self.g_source = 'plex' because the if is with "or" and not with "and" which si not possible
                    if "cache" in params:
                        if not params['cache']:
                            self.g_source = "plex"

                    if self.g_source == "cache" or params['cache'] == True:
                        try:
                            fd = open(self.tvShowPickle, "rb")
                            pickleData = pickle.load(fd)
                            library = pickleData[0]

                            # todo we have to check if we will need this in future or not
                            #tmpAbc = pickleData[1]
                            #tmpGenres = pickleData [2]

                            fd.close()
                            printl("from pickle", self, "D")
                        except:
                            printl("movie cache not found ... saving", self,
                                   "D")
                            library, tmpAbc, tmpGenres = Singleton(
                            ).getPlexInstance().getShowsFromSection(url)
                            reason = "cache file does not exists, recreating ..."
                            self.generatingCacheForTvShowSection(
                                reason, library, tmpAbc, tmpGenres)
                            printl("fallback to: from server", self, "D")
                    else:
                        library, tmpAbc, tmpGenres = Singleton(
                        ).getPlexInstance().getShowsFromSection(url)
                        reason = "generating cache first time, creating ..."
                        self.generatingCacheForTvShowSection(
                            reason, library, tmpAbc, tmpGenres)
                else:
                    library, tmpAbc, tmpGenres = Singleton().getPlexInstance(
                    ).getShowsFromSection(url)

                # sort
                sort = [
                    ("by title", None, False),
                    ("by year", "year", True),
                    ("by rating", "rating", True),
                ]

                myFilter = [
                    ("All", (None, False), ("", )),
                ]

                #if len(tmpGenres) > 0:
                #tmpGenres.sort()
                #filter.append(("Genre", ("Genres", True), tmpGenres))

                printl("", self, "C")
                return library, (
                    "viewMode",
                    "ratingKey",
                ), None, None, sort, myFilter
                # (libraryArray, onEnterPrimaryKeys, onLeavePrimaryKeys, onLeaveSelectEntry

            # Display the Seasons Menu
            elif params["viewMode"] == "ShowSeasons":
                printl("show seasons of TV show ...", self, "I")

                url = params["url"]

                library = Singleton().getPlexInstance().getSeasonsOfShow(url)

                sort = (("by season", True, False), )

                myFilter = [
                    ("All", (None, False), ("", )),
                ]

                printl("", self, "C")
                return library, (
                    "viewMode",
                    "ratingKey",
                ), None, "backToShows", sort, myFilter
                # (libraryArray, onEnterPrimaryKeys, onLeavePrimaryKeys, onLeaveSelectEntry

            # Display the Episodes Menu
            elif params["viewMode"] == "ShowEpisodes":
                printl("show episodes of season ...", self, "I")

                url = params["url"]

                library = Singleton().getPlexInstance().getEpisodesOfSeason(
                    url)

                sort = [
                    ("by title", None, False),
                ]

                myFilter = [
                    ("All", (None, False), ("", )),
                ]

                #filter.append(("Seen", ("Seen", False, 1), ("Seen", "Unseen", )))

                printl("", self, "C")
                return library, (
                    "viewMode",
                    "ratingKey",
                ), None, "backToSeasons", sort, myFilter
                # (libraryArray, onEnterPrimaryKeys, onLeavePrimaryKeys, onLeaveSelectEntry

        printl("", self, "C")