⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 progwindow.py

📁 XOT: XBMC Online TV Framework
💻 PY
📖 第 1 页 / 共 2 页
字号:
import xbmc, xbmcgui
import urlparse, re, sys, os
from urlparse import urlparse

#===============================================================================
# Make global object available
#===============================================================================
import config
import controls
import contextmenu
import common
import settings
logFile = sys.modules['__main__'].globalLogFile
uriHandler = sys.modules['__main__'].globalUriHandler

try:
    channelRegister = []
    
    # load all channels in channel folder
    channelImport = os.listdir(os.path.join(config.rootDir,"channels"))
    channelImport.sort()
    
    # first import base class
    import chn_class
    
    for channel in channelImport:
        channelDir = os.path.join(config.rootDir, "channels", channel)
        if os.path.isdir(channelDir) and not channel.startswith("."):
            sys.path.append(channelDir)
            logFile.info("Importing chn_%s", channel)
            exec("import chn_%s" % channel) 
    #channels imported, but not initialised, that happens in the __init__!
            
except:
    logFile.critical("Error loading channel modules", exc_info=True)
    
#===============================================================================
class GUI(xbmcgui.WindowXML):
    def __init__(self, strXMLname, strFallbackPath, strDefaultName, bforeFallback=0):
        try:
            self.mainlistItems = []
            self.initialised = False
            self.contextMenu = True
            self.channelGUIs = []
            self.channelButtonRegister = []
            self.activeChannelGUI = None
            self.selectedChannelIndex = 0
            self.listMode = 1 # 1=normal, 2=favorites 
            
            # create channel GUIs (channel classes are initiated)
            for channel in channelRegister:
                self.channelGUIs.append(eval(channel))   
                # if out of date, remove again!
                if self.channelGUIs[-1].OutOfDate:
                    self.channelGUIs.pop()
            
            # order them by channelName MUST Also sort the buttons
            #self.channelGUIs.sort(lambda x,y: cmp(x.channelName.lower(), y.channelName.lower))
            self.channelGUIs.sort(self.sortChannel)
            
            # now that they are ordered: get the buttoncodes. So the order in the buttoncode 
            # list is the same!
            for channel in self.channelGUIs:
                if channel.buttonID >0:
                    self.channelButtonRegister.append(channel.buttonID)
            self.panelViewEnabled = self.channelButtonRegister == []
            
            logFile.info("Starting %s ProgWindow with Fallback=%s and DefaultName=%s",config.appName, strFallbackPath,strDefaultName)
        except:
            logFile.debug("Error in __init__ of ProgWindow", exc_info=True)
    #===============================================================================
    def onInit(self):
        # check, if there are buttons registerd, and if there are, if
        # the buttoncount is the same as the channelcount
        if self.channelButtonRegister != []:
            if len(self.channelButtonRegister) != len(channelRegister):
                logFile.critical("The number of buttons that were registered is not the same as the number of channels")
                self.close()
                
        if not self.initialised:
            # hide programlist 
            self.getControl(controls.PR_LIST_WRAPPER).setVisible(False)
            
            # if buttons are present, hide the panelView
            if not self.panelViewEnabled:
                self.getControl(controls.CH_LIST_WRAPPER).setVisible(False)
                
            # set initialvalues
            self.DisplayGUIs()
            
            # Set icon
            self.selectedChannelIndex = self.getCurrentListPosition()
            self.activeChannelGUI = self.channelGUIs[self.selectedChannelIndex]
            
            self.ShowChannelInfo()
            
            self.initialised = True
        
        self.setCurrentListPosition(self.selectedChannelIndex)
        
    #===============================================================================
    def onAction(self, action):
        try:
            controlID = self.getFocusId()
            #===============================================================================
            # Handle Back actions
            #===============================================================================
            if action == controls.ACTION_PARENT_DIR or action == controls.ACTION_PREVIOUS_MENU:
                logFile.debug("Going back a level")
                if self.mainlistItems == [] or not self.panelViewEnabled:
                    self.close()
                else:
                    # hide programlist and show channelpannel
                    self.activeChannelGUI = None
                    self.mainlistItems = []
                    self.ChannelListVisible(True)
                    self.listMode = 1
            
            elif action == controls.ACTION_SHOW_INFO and controlID <> controls.CH_LIST:
                logFile.debug("Showing contextmenu")
                self.DoActionFromContextMenu(self.getControl(controls.PR_LIST).getSelectedPosition())
            
            #===============================================================================
            # Handle UP/Down on mainlist
            #===============================================================================
            elif (action in controls.ACTION_UPDOWN or action in controls.ACTION_LEFTRIGHT) and self.mainlistItems == [] and controlID == controls.CH_LIST:
                # Determine the active channel only when EP_LIST is in focus
                self.selectedChannelIndex = self.getCurrentListPosition()
                self.activeChannelGUI = self.channelGUIs[self.selectedChannelIndex]
                
                self.ShowChannelInfo()
            
            #===============================================================================
            # Handle onClicks
            #===============================================================================
            elif action == controls.ACTION_SELECT_ITEM:
                # handle the onClicks. Because we use a WrapList the onAction also triggers
                # an onAction, causing some problems. That is why we handle onclicks here now.
                logFile.debug("Hiding ControlID=%s", controls.CH_LIST)
                #self.listMode = 1
                
                #===============================================================================
                # Handle main lists
                #===============================================================================
                if controls.EP_LIST <= controlID <= controls.EP_LIST + 9 and self.mainlistItems==[]:
                    # set the active channel in case no up/down was done!
                    self.selectedChannelIndex = self.getCurrentListPosition()
                    self.activeChannelGUI = self.channelGUIs[self.selectedChannelIndex]
                
                    # Get MainlistItems
                    self.mainlistItems = self.activeChannelGUI.ParseMainList()
                    self.ShowListItems(self.mainlistItems)
                    
                    # hide Main ChannelList and show ProgramList
                    self.ChannelListVisible(False)
                                        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -