Example #1
0
    def FindLogo(self, chtype, chname, mpath):
        self.logDebug("FindLogo")
        found = False
        setImage = ''
        LogoName = (chname[0:18] + '.png')
        LogoFolder = os.path.join(LOGO_LOC, LogoName)
        self.logoParser = lsHTMLParser()

        if FileAccess.exists(LogoFolder):
            return LogoFolder
        else:
            # if chtype == 1:
            # setImage = self.logoParser.retrieve_icon(chname)
            if chtype == 6 or chtype == 7:
                smpath = mpath.rsplit('/',
                                      2)[0]  #Path Above mpath ie Series folder
                artSeries = xbmc.translatePath(os.path.join(
                    smpath, 'logo.png'))
                artSeason = xbmc.translatePath(os.path.join(mpath, 'logo.png'))
                if FileAccess.exists(artSeries):
                    setImage = artSeries
                elif FileAccess.exists(artSeason):
                    setImage = artSeason
                # else:
                # if REAL_SETTINGS.getSetting('EnhancedGuideData') == 'true':
                # self.Fanart_Download('tvshow', 'logo', id, LogoFolder)

        if setImage.startswith('http'):
            requestDownload(setImage, LogoFolder)
        else:
            FileAccess.copy(setImage, LogoFolder)
        return LogoFolder
 def FindLogo(self, chtype, chname, mpath):
     self.logDebug("FindLogo")
     found = False
     setImage = ''
     LogoName = (chname[0:18] + '.png')
     LogoFolder = os.path.join(LOGO_LOC,LogoName)
     self.logoParser = lsHTMLParser()
     
     if FileAccess.exists(LogoFolder):
         return LogoFolder
     else:
         # if chtype == 1:
             # setImage = self.logoParser.retrieve_icon(chname)
         if chtype == 6 or chtype == 7:
             smpath = mpath.rsplit('/',2)[0] #Path Above mpath ie Series folder
             artSeries = xbmc.translatePath(os.path.join(smpath, 'logo.png'))
             artSeason = xbmc.translatePath(os.path.join(mpath, 'logo.png'))
             if FileAccess.exists(artSeries): 
                 setImage = artSeries
             elif FileAccess.exists(artSeason): 
                 setImage = artSeason
             # else:
                 # if REAL_SETTINGS.getSetting('EnhancedGuideData') == 'true': 
                     # self.Fanart_Download('tvshow', 'logo', id, LogoFolder)
                 
     if setImage.startswith('http'):
         requestDownload(setImage, LogoFolder)
     else:
         FileAccess.copy(setImage, LogoFolder)
     return LogoFolder
Example #3
0
    def buildMixedFileList(self, dom1, channel):
        fileList = []
        self.log('buildMixedFileList')

        try:
            rules = dom1.getElementsByTagName('rule')
            order = dom1.getElementsByTagName('order')
        except:
            self.log('buildMixedFileList Problem parsing playlist ' + filename,
                     xbmc.LOGERROR)
            xml.close()
            return fileList

        for rule in rules:
            rulename = rule.childNodes[0].nodeValue

            if FileAccess.exists(
                    xbmc.translatePath('special://profile/playlists/video/') +
                    rulename):
                FileAccess.copy(
                    xbmc.translatePath('special://profile/playlists/video/') +
                    rulename, MADE_CHAN_LOC + rulename)
                fileList.extend(
                    self.buildFileList(MADE_CHAN_LOC + rulename, channel))
            else:
                fileList.extend(
                    self.buildFileList(GEN_CHAN_LOC + rulename, channel))

        self.log("buildMixedFileList returning")
        return fileList
Example #4
0
    def onAction(self, act):
        action = act.getId()

        if action in ACTION_PREVIOUS_MENU:
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    dlg = xbmcgui.Dialog()

                    if dlg.yesno(xbmc.getLocalizedString(190),
                                 LANGUAGE(30032)):
                        ADDON_SETTINGS.writeSettings()

                        if CHANNEL_SHARING:
                            realloc = ADDON.getSetting('SettingsFolder')
                            FileAccess.copy(SETTINGS_LOC + '/settings2.xml',
                                            realloc + '/settings2.xml')

                self.close()
        elif act.getButtonCode() == 61575:  # Delete button
            curchan = self.listcontrol.getSelectedPosition() + 1

            if ((self.showingList == True) and
                (ADDON_SETTINGS.getSetting("Channel_" + str(curchan) + "_type")
                 != "9999")):
                dlg = xbmcgui.Dialog()

                if dlg.yesno(xbmc.getLocalizedString(190), LANGUAGE(30033)):
                    ADDON_SETTINGS.setSetting(
                        "Channel_" + str(curchan) + "_type", "9999")
                    self.updateListing(curchan)
                    self.madeChanges = 1
Example #5
0
    def onAction(self, act):
        action = act.getId()

        if action in ACTION_PREVIOUS_MENU:
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    dlg = xbmcgui.Dialog()

                    if dlg.yesno(xbmc.getLocalizedString(190), LANGUAGE(30032)):
                        ADDON_SETTINGS.writeSettings()
            
                        if CHANNEL_SHARING:
                            realloc = ADDON.getSetting('SettingsFolder')
                            FileAccess.copy(SETTINGS_LOC + '/settings2.xml', realloc + '/settings2.xml')

                self.close()
        elif act.getButtonCode() == 61575:      # Delete button
            curchan = self.listcontrol.getSelectedPosition() + 1

            if( (self.showingList == True) and (ADDON_SETTINGS.getSetting("Channel_" + str(curchan) + "_type") != "9999") ):
                dlg = xbmcgui.Dialog()

                if dlg.yesno(xbmc.getLocalizedString(190), LANGUAGE(30033)):
                    ADDON_SETTINGS.setSetting("Channel_" + str(curchan) + "_type", "9999")
                    self.updateListing(curchan)
                    self.madeChanges = 1
Example #6
0
    def onAction(self, act):
        action = act.getId()

        if action in ACTION_PREVIOUS_MENU:
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    dlg = xbmcgui.Dialog()

                    if dlg.yesno(xbmc.getLocalizedString(190),
                                 LANGUAGE(30032)):
                        ADDON_SETTINGS.writeSettings()

                        if CHANNEL_SHARING:
                            realloc = ADDON.getSetting('SettingsFolder')
                            FileAccess.copy(SETTINGS_LOC + '/settings2.xml',
                                            realloc + '/settings2.xml')
                self.close()
        elif action == CONTEXT_MENU:
            curchan = self.listcontrol.getSelectedPosition() + 1
            AffectChannelOptions = ("Copy Channel", "Swap Channels",
                                    "Insert Channel (and move down)",
                                    "Delete Channel (and move up)",
                                    "Clear Channel")
            ChannelAction = xbmcgui.Dialog().select(
                "Choose An Action For Channel %d" % curchan,
                AffectChannelOptions)
            if ChannelAction != -1:
                if ChannelAction == 0:
                    CopyToChannel = int(xbmcgui.Dialog().numeric(
                        0, "Copy To (and overwrite) Channel"))
                    if 1 <= CopyToChannel <= 9999:
                        self.copyChannel(curchan, CopyToChannel)
                elif ChannelAction == 1:
                    SwapToChannel = int(xbmcgui.Dialog().numeric(
                        0, "Swap Channel %d with Channel:" % curchan))
                    if 1 <= SwapToChannel <= 9999:
                        firstEmpty = self.findFirstEmpty(curchan)
                        self.swapChannel(curchan, SwapToChannel, firstEmpty)
                elif ChannelAction == 2:
                    firstEmpty = self.findFirstEmpty(curchan)
                    self.insertChannel(curchan, firstEmpty)
                    #xbmc.executebuiltin('Notification(%s,%s)' % (curchan,FirstEmpty))
                elif ChannelAction == 3:
                    firstEmpty = self.findFirstEmpty(curchan)
                    self.deleteChannel(curchan, firstEmpty)
                elif ChannelAction == 4:
                    self.clearChannel(curchan)
        elif act.getButtonCode() == 61575:  # Delete button
            curchan = self.listcontrol.getSelectedPosition() + 1
            self.clearChannel(curchan)
Example #7
0
    def storeFiles(self):
        self.log('storeFiles')

        if CHANNEL_SHARING == False:
            return

        realloc = ADDON.getSetting('SettingsFolder')
        FileAccess.copy(SETTINGS_LOC + '/settings2.xml', realloc + '/settings2.xml')
        realloc = xbmc.translatePath(os.path.join(realloc, 'cache')) + '/'

        for i in range(self.maxChannels + 1):
            FileAccess.copy(CHANNELS_LOC + 'channel_' + str(i) + '.m3u', realloc + 'channel_' + str(i) + '.m3u')
Example #8
0
def Backup(org, bak):
    log("Backup " + str(org) + " - " + str(bak))
    if FileAccess.exists(org):
        if FileAccess.exists(bak):
            try:
                xbmcvfs.delete(bak)
            except:
                pass
        FileAccess.copy(org, bak)

    if DEBUG == "true":
        xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoTV Lite", "Backup Complete", 1000, THUMB))
Example #9
0
def addFont(fntname, filename, size, style=""):
    log("MyFont: addFont, filename = " + filename + ", size = " + size)
    FontName = filename
    FontPath = os.path.join(PTVL_SELECT_SKIN_LOC, 'fonts', FontName)
    log("MyFont: addFont, FontName = " + FontName)
    log("MyFont: addFont, FontPath = " + FontPath)
    reload_skin = False
    fontxml_paths = getFontsXML()
    if fontxml_paths:
        for fontxml_path in fontxml_paths:
            if not isFontInstalled(fontxml_path, fntname, FontName):
                parser = PCParser()
                tree = ET.parse(fontxml_path, parser=parser)
                root = tree.getroot()
                for sets in root.getchildren():
                    sets.findall("font")[-1].tail = "\n\t\t"
                    new = ET.SubElement(sets, "font")
                    new.text, new.tail = "\n\t\t\t", "\n\t"
                    subnew1 = ET.SubElement(new, "name")
                    subnew1.text = fntname
                    subnew1.tail = "\n\t\t\t"
                    subnew2 = ET.SubElement(new, "filename")
                    subnew2.text = (
                        filename,
                        "Arial.ttf")[sets.attrib.get("id") == "Arial"]
                    subnew2.tail = "\n\t\t\t"
                    subnew3 = ET.SubElement(new, "size")
                    subnew3.text = size
                    subnew3.tail = "\n\t\t\t"
                    last_elem = subnew3
                    if style in ["normal", "bold", "italics", "bolditalics"]:
                        subnew4 = ET.SubElement(new, "style")
                        subnew4.text = style
                        subnew4.tail = "\n\t\t\t"
                        last_elem = subnew4
                    reload_skin = True
                    last_elem.tail = "\n\t\t"
                tree.write(fontxml_path)
                reload_skin = True

        if os.path.exists(SkinPath) == False:
            reload_skin = True

        dest = os.path.join(SkinPath, 'fonts', FontName)
        if os.path.exists(dest) == False:
            log("MyFont: copyFont, FontPath = " + FontPath + ", SkinPath = " +
                SkinPath)
            FileAccess.copy(FontPath, dest)

    if reload_skin:
        xbmc.executebuiltin("XBMC.ReloadSkin()")
        return True
    return False
Example #10
0
def Backup(org, bak):
    log('Backup ' + str(org) + ' - ' + str(bak))
    if FileAccess.exists(org):
        if FileAccess.exists(bak):
            try:
                xbmcvfs.delete(bak)
            except:
                pass
        FileAccess.copy(org, bak)
    
    if DEBUG == 'true':
        xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoTV Lite", "Backup Complete", 1000, THUMB) )
Example #11
0
    def storeFiles(self):
        self.log('storeFiles')

        if CHANNEL_SHARING == False:
            return

        realloc = ADDON.getSetting('SettingsFolder')
        FileAccess.copy(SETTINGS_LOC + '/settings2.xml', realloc + '/settings2.xml')
        realloc = xbmc.translatePath(os.path.join(realloc, 'cache')) + '/'

        for i in range(self.maxChannels + 1):
            FileAccess.copy(CHANNELS_LOC + 'channel_' + str(i) + '.m3u', realloc + 'channel_' + str(i) + '.m3u')
Example #12
0
def addFont(fntname, filename, size, style=""):
    log("MyFont: addFont, filename = " + filename + ", size = " + size)
    FontName = filename
    FontPath = os.path.join(PTVL_SELECT_SKIN_LOC, 'fonts', FontName)
    log("MyFont: addFont, FontName = " + FontName)
    log("MyFont: addFont, FontPath = " + FontPath)
    reload_skin = False
    fontxml_paths = getFontsXML()
    if fontxml_paths:
        for fontxml_path in fontxml_paths:
            if not isFontInstalled(fontxml_path, fntname, FontName):
                parser = PCParser()
                tree = ET.parse(fontxml_path, parser=parser)
                root = tree.getroot()
                for sets in root.getchildren():
                    sets.findall("font")[-1].tail = "\n\t\t"                        
                    new = ET.SubElement(sets, "font")
                    new.text, new.tail = "\n\t\t\t", "\n\t"
                    subnew1 = ET.SubElement(new, "name")
                    subnew1.text = fntname
                    subnew1.tail = "\n\t\t\t"
                    subnew2 = ET.SubElement(new, "filename")
                    subnew2.text = (filename, "Arial.ttf")[sets.attrib.get("id") == "Arial"]
                    subnew2.tail = "\n\t\t\t"
                    subnew3 = ET.SubElement(new, "size")
                    subnew3.text = size
                    subnew3.tail = "\n\t\t\t"
                    last_elem = subnew3
                    if style in ["normal", "bold", "italics", "bolditalics"]:
                        subnew4 = ET.SubElement(new, "style")
                        subnew4.text = style
                        subnew4.tail = "\n\t\t\t"
                        last_elem = subnew4
                    reload_skin = True
                    last_elem.tail = "\n\t\t"
                tree.write(fontxml_path)
                reload_skin = True
                
        if os.path.exists(SkinPath) == False:
            reload_skin = True
            
        dest = os.path.join(SkinPath, 'fonts', FontName)
        if os.path.exists(dest) == False:
            log("MyFont: copyFont, FontPath = " + FontPath + ", SkinPath = " + SkinPath)
            FileAccess.copy(FontPath, dest)
    
    if reload_skin:
        xbmc.executebuiltin("XBMC.ReloadSkin()")
        return True
    return False
Example #13
0
    def backupFiles(self, updatedlg):
        self.log('backupFiles')

        if CHANNEL_SHARING == False:
            return

        updatedlg.update(1, "Initializing", "Copying Channels...")
        realloc = REAL_SETTINGS.getSetting('SettingsFolder')
        FileAccess.copy(realloc + '/settings2.xml', SETTINGS_LOC + '/settings2.xml')
        realloc = xbmc.translatePath(os.path.join(realloc, 'cache')) + '/'

        for i in range(999):
            FileAccess.copy(realloc + 'channel_' + str(i) + '.m3u', CHANNELS_LOC + 'channel_' + str(i) + '.m3u')
            updatedlg.update(int(i * .07) + 1, "Initializing", "Copying Channels...")
Example #14
0
    def backupFiles(self, updatedlg):
        self.log('backupFiles')

        if CHANNEL_SHARING == False:
            return

        updatedlg.update(1, "Initializing", "Copying Channels...")
        realloc = REAL_SETTINGS.getSetting('SettingsFolder')
        FileAccess.copy(realloc + '/settings2.xml',
                        SETTINGS_LOC + '/settings2.xml')
        realloc = xbmc.translatePath(os.path.join(realloc, 'cache')) + '/'

        for i in range(999):
            FileAccess.copy(realloc + 'channel_' + str(i) + '.m3u',
                            CHANNELS_LOC + 'channel_' + str(i) + '.m3u')
            updatedlg.update(
                int(i * .07) + 1, "Initializing", "Copying Channels...")
    def __init__(self, *args, **kwargs):
        self.log("__init__")
        xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)
        self.madeChanges = 0
        self.showingList = True
        self.channel = 0
        self.channel_type = 9999
        self.setting1 = ''
        self.setting2 = ''
        self.savedRules = False

        if CHANNEL_SHARING:
            realloc = ADDON.getSetting('SettingsFolder')
            FileAccess.copy(realloc + '/settings2.xml', SETTINGS_LOC + '/settings2.xml')

        ADDON_SETTINGS.loadSettings()
        ADDON_SETTINGS.disableWriteOnSave()
        self.doModal()
        self.log("__init__ return")
Example #16
0
    def __init__(self, *args, **kwargs):
        self.log("__init__")
        xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)
        self.madeChanges = 0
        self.showingList = True
        self.channel = 0
        self.channel_type = 9999
        self.setting1 = ''
        self.setting2 = ''
        self.savedRules = False

        if CHANNEL_SHARING:
            realloc = ADDON.getSetting('SettingsFolder')
            FileAccess.copy(realloc + '/settings2.xml', SETTINGS_LOC + '/settings2.xml')

        ADDON_SETTINGS.loadSettings()
        ADDON_SETTINGS.disableWriteOnSave()
        self.doModal()
        self.log("__init__ return")
Example #17
0
    def buildMixedFileList(self, dom1, channel):
        fileList = []
        self.log('buildMixedFileList')

        try:
            rules = dom1.getElementsByTagName('rule')
            order = dom1.getElementsByTagName('order')
        except:
            self.log('buildMixedFileList Problem parsing playlist ' + filename, xbmc.LOGERROR)
            xml.close()
            return fileList

        for rule in rules:
            rulename = rule.childNodes[0].nodeValue

            if FileAccess.exists(xbmc.translatePath('special://profile/playlists/video/') + rulename):
                FileAccess.copy(xbmc.translatePath('special://profile/playlists/video/') + rulename, MADE_CHAN_LOC + rulename)
                fileList.extend(self.buildFileList(MADE_CHAN_LOC + rulename, channel))
            else:
                fileList.extend(self.buildFileList(GEN_CHAN_LOC + rulename, channel))

        self.log("buildMixedFileList returning")
        return fileList
Example #18
0
    def makeChannelList(self,
                        channel,
                        chtype,
                        setting1,
                        setting2,
                        append=False):
        self.log('makeChannelList ' + str(channel))
        israndom = False
        fileList = []

        if chtype == 7:
            fileList = self.createDirectoryPlaylist(setting1)
            israndom = True
        else:
            if chtype == 0:
                if FileAccess.copy(setting1, MADE_CHAN_LOC +
                                   os.path.split(setting1)[1]) == False:
                    if FileAccess.exists(MADE_CHAN_LOC +
                                         os.path.split(setting1)[1]) == False:
                        self.log("Unable to copy or find playlist " + setting1)
                        return False

                fle = MADE_CHAN_LOC + os.path.split(setting1)[1]
            else:
                fle = self.makeTypePlaylist(chtype, setting1, setting2)

            fle = uni(fle)

            if len(fle) == 0:
                self.log(
                    'Unable to locate the playlist for channel ' +
                    str(channel), xbmc.LOGERROR)
                return False

            try:
                xml = FileAccess.open(fle, "r")
            except:
                self.log(
                    "makeChannelList Unable to open the smart playlist " + fle,
                    xbmc.LOGERROR)
                return False

            try:
                dom = parse(xml)
            except:
                self.log('makeChannelList Problem parsing playlist ' + fle,
                         xbmc.LOGERROR)
                xml.close()
                return False

            xml.close()

            if self.getSmartPlaylistType(dom) == 'mixed':
                fileList = self.buildMixedFileList(dom, channel)
            else:
                fileList = self.buildFileList(fle, channel)

            try:
                order = dom.getElementsByTagName('order')

                if order[0].childNodes[0].nodeValue.lower() == 'random':
                    israndom = True
            except:
                pass

        try:
            if append == True:
                channelplaylist = FileAccess.open(
                    CHANNELS_LOC + "channel_" + str(channel) + ".m3u", "r")
                channelplaylist.seek(0, 2)
                channelplaylist.close()
            else:
                channelplaylist = FileAccess.open(
                    CHANNELS_LOC + "channel_" + str(channel) + ".m3u", "w")
        except:
            self.log(
                'Unable to open the cache file ' + CHANNELS_LOC + 'channel_' +
                str(channel) + '.m3u', xbmc.LOGERROR)
            return False

        if append == False:
            channelplaylist.write(uni("#EXTM3U\n"))

        if israndom:
            random.shuffle(fileList)

        if len(fileList) > 16384:
            fileList = fileList[:16384]

        fileList = self.runActions(RULES_ACTION_LIST, channel, fileList)
        self.channels[channel - 1].isRandom = israndom

        if append:
            if len(fileList) + self.channels[channel -
                                             1].Playlist.size() > 16384:
                fileList = fileList[:(
                    16384 - self.channels[channel - 1].Playlist.size())]
        else:
            if len(fileList) > 16384:
                fileList = fileList[:16384]

        # Write each entry into the new playlist
        for string in fileList:
            channelplaylist.write(uni("#EXTINF:") + uni(string) + uni("\n"))

        channelplaylist.close()
        self.log('makeChannelList return')
        return True
Example #19
0
    def onClick(self, controlId):
        self.log("onClick " + str(controlId))

        if controlId == 102:  # Channel list entry selected
            self.getControl(105).setVisible(False)
            self.getControl(106).setVisible(True)
            self.channel = self.listcontrol.getSelectedPosition() + 1
            self.changeChanType(self.channel, 0)
            self.setFocusId(110)
            self.showingList = False
            self.savedRules = False
        elif controlId == 110:  # Change channel type left
            self.changeChanType(self.channel, -1)
        elif controlId == 111:  # Change channel type right
            self.changeChanType(self.channel, 1)
        elif controlId == 112:  # Ok button
            if self.showingList == False:
                self.saveSettings()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    ADDON_SETTINGS.writeSettings()
                    if CHANNEL_SHARING:
                        realloc = ADDON.getSetting('SettingsFolder')
                        FileAccess.copy(SETTINGS_LOC + '/settings2.xml',
                                        realloc + '/settings2.xml')
                self.close()
        elif controlId == 113:  # Cancel button
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                self.close()
        elif controlId == 114:  # Rules button
            self.myRules.ruleList = self.ruleList
            self.myRules.doModal()

            if self.myRules.wasSaved == True:
                self.ruleList = self.myRules.ruleList
                self.savedRules = True
        elif controlId == 130:  # Playlist-type channel, playlist button
            dlg = xbmcgui.Dialog()
            retval = dlg.browse(1,
                                "Channel " + str(self.channel) + " Playlist",
                                "files", ".xsp", False, False,
                                "special://videoplaylists/")

            if retval != "special://videoplaylists/":
                self.getControl(130).setLabel(
                    self.getSmartPlaylistName(retval), label2=retval)
        elif controlId == 140:  # Network TV channel, left
            self.changeListData(self.networkList, 142, -1)
        elif controlId == 141:  # Network TV channel, right
            self.changeListData(self.networkList, 142, 1)
        elif controlId == 150:  # Movie studio channel, left
            self.changeListData(self.studioList, 152, -1)
        elif controlId == 151:  # Movie studio channel, right
            self.changeListData(self.studioList, 152, 1)
        elif controlId == 160:  # TV Genre channel, left
            self.changeListData(self.showGenreList, 162, -1)
        elif controlId == 161:  # TV Genre channel, right
            self.changeListData(self.showGenreList, 162, 1)
        elif controlId == 170:  # Movie Genre channel, left
            self.changeListData(self.movieGenreList, 172, -1)
        elif controlId == 171:  # Movie Genre channel, right
            self.changeListData(self.movieGenreList, 172, 1)
        elif controlId == 180:  # Mixed Genre channel, left
            self.changeListData(self.mixedGenreList, 182, -1)
        elif controlId == 181:  # Mixed Genre channel, right
            self.changeListData(self.mixedGenreList, 182, 1)
        elif controlId == 190:  # TV Show channel, left
            self.changeListData(self.showList, 192, -1)
        elif controlId == 191:  # TV Show channel, right
            self.changeListData(self.showList, 192, 1)
        elif controlId == 200:  # Directory channel, select
            dlg = xbmcgui.Dialog()
            retval = dlg.browse(0,
                                "Channel " + str(self.channel) + " Directory",
                                "files")

            if len(retval) > 0:
                self.getControl(200).setLabel(retval)

        self.log("onClick return")
    def onClick(self, controlId):
        self.log("onClick " + str(controlId))
        if controlId == 102:        # Channel list entry selected
            self.getControl(105).setVisible(False)
            self.getControl(106).setVisible(True)
            self.channel = self.listcontrol.getSelectedPosition() + 1
            self.changeChanType(self.channel, 0)
            if self.checkRules(self.channel) == True:
                self.getControl(114).setLabel('[B]$LOCALIZE[10038] $LOCALIZE[5][/B]*')
            else:
                self.getControl(114).setLabel('[B]$LOCALIZE[10038] $LOCALIZE[5][/B]')
            self.setFocusId(110)
            self.showingList = False
            self.savedRules = False


        elif controlId == 110 or controlId == 111 or controlId == 109:
            ChannelTypeOptions = ("Custom Playlist", "TV Network", "Movie Studio", "TV Genre", "Movie Genre", "Mixed Genre", "TV Show", "Directory", "None")
            ChannelType = xbmcgui.Dialog().select("Choose A Channel Type",ChannelTypeOptions)
            if ChannelType == 8:
                ChannelType = 9999
            if ChannelType != -1:
                self.setChanType(self.channel, ChannelType)
        elif controlId == 112:      # Ok button
            if self.showingList == False:
                self.saveSettings()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    ADDON_SETTINGS.writeSettings()
                    if CHANNEL_SHARING:
                        realloc = ADDON.getSetting('SettingsFolder')
                        FileAccess.copy(SETTINGS_LOC + '/settings2.xml', realloc + '/settings2.xml')
                self.close()
        elif controlId == 113:      # Cancel button
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                self.close()
        elif controlId == 114:      # Rules button
            self.myRules.ruleList = self.ruleList
            self.myRules.doModal()

            if self.myRules.wasSaved == True:
                self.ruleList = self.myRules.ruleList
                self.savedRules = True
        elif controlId == 130:      # Playlist-type channel, playlist button
            dlg = xbmcgui.Dialog()
            retval = dlg.browse(1, "Channel " + str(self.channel) + " Playlist", "files", ".xsp", False, False, "special://videoplaylists/")

            if retval != "special://videoplaylists/":
                self.getControl(130).setLabel(self.getSmartPlaylistName(retval), label2=retval)
        elif controlId == 140 or controlId == 141:      # Network TV channel
            ListOptions = self.networkList
            ListChoice = xbmcgui.Dialog().select("Choose A Network", ListOptions)
            if ListChoice != -1:
                self.setListData(self.networkList, 142, ListChoice)
        elif controlId == 150 or controlId == 151:      # Movie studio channel
            ListOptions = self.studioList
            ListChoice = xbmcgui.Dialog().select("Choose A Studio", ListOptions)
            if ListChoice != -1:
                self.setListData(self.studioList, 152, ListChoice)
        elif controlId == 160 or controlId == 161:      # TV Genre channel
            ListOptions = self.showGenreList
            ListChoice = xbmcgui.Dialog().select("Choose A Genre", ListOptions)
            if ListChoice != -1:
                self.setListData(self.showGenreList, 162, ListChoice)
        elif controlId == 170 or controlId == 171:      # Movie Genre channel
            ListOptions = self.movieGenreList
            ListChoice = xbmcgui.Dialog().select("Choose A Genre", ListOptions)
            if ListChoice != -1:
                self.setListData(self.movieGenreList, 172, ListChoice)
        elif controlId == 180 or controlId == 181:      # Mixed Genre channel
            ListOptions = self.mixedGenreList
            ListChoice = xbmcgui.Dialog().select("Choose A Genre", ListOptions)
            if ListChoice != -1:
                self.setListData(self.mixedGenreList, 182, ListChoice)
        elif controlId == 190 or controlId == 191:      # TV Show channel
            ListOptions = self.showList
            ListChoice = xbmcgui.Dialog().select("Choose A Genre", ListOptions)
            if ListChoice != -1:
                self.setListData(self.showList, 192, ListChoice)
        elif controlId == 200:      # Directory channel, select
            dlg = xbmcgui.Dialog()
            retval = dlg.browse(0, "Channel " + str(self.channel) + " Directory", "files")

            if len(retval) > 0:
                self.getControl(200).setLabel(retval)

        self.log("onClick return")
Example #21
0
    def makeChannelList(self, channel, chtype, setting1, setting2, append = False):
        self.log('makeChannelList ' + str(channel))
        israndom = False
        fileList = []

        if chtype == 7:
            fileList = self.createDirectoryPlaylist(setting1)
            israndom = True
        else:
            if chtype == 0:
                if FileAccess.copy(setting1, MADE_CHAN_LOC + os.path.split(setting1)[1]) == False:
                    if FileAccess.exists(MADE_CHAN_LOC + os.path.split(setting1)[1]) == False:
                        self.log("Unable to copy or find playlist " + setting1)
                        return False

                fle = MADE_CHAN_LOC + os.path.split(setting1)[1]
            else:
                fle = self.makeTypePlaylist(chtype, setting1, setting2)

            fle = xbmc.translatePath(fle)

            if len(fle) == 0:
                self.log('Unable to locate the playlist for channel ' + str(channel), xbmc.LOGERROR)
                return False

            try:
                xml = FileAccess.open(fle, "r")
            except:
                self.log("makeChannelList Unable to open the smart playlist " + fle, xbmc.LOGERROR)
                return False

            try:
                dom = parse(xml)
            except:
                self.log('makeChannelList Problem parsing playlist ' + fle, xbmc.LOGERROR)
                xml.close()
                return False

            xml.close()

            if self.getSmartPlaylistType(dom) == 'mixed':
                fileList = self.buildMixedFileList(dom, channel)
            else:
                fileList = self.buildFileList(fle, channel)

            try:
                order = dom.getElementsByTagName('order')

                if order[0].childNodes[0].nodeValue.lower() == 'random':
                    israndom = True
            except:
                pass

        try:
            if append == True:
                channelplaylist = FileAccess.open(CHANNELS_LOC + "channel_" + str(channel) + ".m3u", "r+")
                channelplaylist.seek(0, 2)
            else:
                channelplaylist = FileAccess.open(CHANNELS_LOC + "channel_" + str(channel) + ".m3u", "w")
        except:
            self.log('Unable to open the cache file ' + CHANNELS_LOC + 'channel_' + str(channel) + '.m3u', xbmc.LOGERROR)
            return False

        if append == False:
            channelplaylist.write("#EXTM3U\n")

        if len(fileList) == 0:
            self.log("Unable to get information about channel " + str(channel), xbmc.LOGERROR)
            channelplaylist.close()
            return False

        if israndom:
            random.shuffle(fileList)

        if len(fileList) > 4096:
            fileList = fileList[:4096]

        fileList = self.runActions(RULES_ACTION_LIST, channel, fileList)
        self.channels[channel - 1].isRandom = israndom

        if append:
            if len(fileList) + self.channels[channel - 1].Playlist.size() > 4096:
                fileList = fileList[:(4096 - self.channels[channel - 1].Playlist.size())]
        else:
            if len(fileList) > 4096:
                fileList = fileList[:4096]

        # Write each entry into the new playlist
        for string in fileList:
            channelplaylist.write("#EXTINF:" + string + "\n")

        channelplaylist.close()
        self.log('makeChannelList return')
        return True
Example #22
0
    def onClick(self, controlId):
        self.log("onClick " + str(controlId))

        if controlId == 102:        # Channel list entry selected
            self.getControl(105).setVisible(False)
            self.getControl(106).setVisible(True)
            self.channel = self.listcontrol.getSelectedPosition() + 1
            self.changeChanType(self.channel, 0)
            self.setFocusId(110)
            self.showingList = False
            self.savedRules = False
        elif controlId == 110:      # Change channel type left
            self.changeChanType(self.channel, -1)
        elif controlId == 111:      # Change channel type right
            self.changeChanType(self.channel, 1)
        elif controlId == 112:      # Ok button
            if self.showingList == False:
                self.saveSettings()
                self.hideChanDetails()
            else:
                if self.madeChanges == 1:
                    ADDON_SETTINGS.writeSettings()
                    if CHANNEL_SHARING:
                        realloc = ADDON.getSetting('SettingsFolder')
                        FileAccess.copy(SETTINGS_LOC + '/settings2.xml', realloc + '/settings2.xml')
                self.close()
        elif controlId == 113:      # Cancel button
            if self.showingList == False:
                self.cancelChan()
                self.hideChanDetails()
            else:
                self.close()
        elif controlId == 114:      # Rules button
            self.myRules.ruleList = self.ruleList
            self.myRules.doModal()

            if self.myRules.wasSaved == True:
                self.ruleList = self.myRules.ruleList
                self.savedRules = True
        elif controlId == 130:      # Playlist-type channel, playlist button
            dlg = xbmcgui.Dialog()
            retval = dlg.browse(1, "Channel " + str(self.channel) + " Playlist", "files", ".xsp", False, False, "special://videoplaylists/")

            if retval != "special://videoplaylists/":
                self.getControl(130).setLabel(self.getSmartPlaylistName(retval), label2=retval)
        elif controlId == 140:      # Network TV channel, left
            self.changeListData(self.networkList, 142, -1)
        elif controlId == 141:      # Network TV channel, right
            self.changeListData(self.networkList, 142, 1)
        elif controlId == 150:      # Movie studio channel, left
            self.changeListData(self.studioList, 152, -1)
        elif controlId == 151:      # Movie studio channel, right
            self.changeListData(self.studioList, 152, 1)
        elif controlId == 160:      # TV Genre channel, left
            self.changeListData(self.showGenreList, 162, -1)
        elif controlId == 161:      # TV Genre channel, right
            self.changeListData(self.showGenreList, 162, 1)
        elif controlId == 170:      # Movie Genre channel, left
            self.changeListData(self.movieGenreList, 172, -1)
        elif controlId == 171:      # Movie Genre channel, right
            self.changeListData(self.movieGenreList, 172, 1)
        elif controlId == 180:      # Mixed Genre channel, left
            self.changeListData(self.mixedGenreList, 182, -1)
        elif controlId == 181:      # Mixed Genre channel, right
            self.changeListData(self.mixedGenreList, 182, 1)
        elif controlId == 190:      # TV Show channel, left
            self.changeListData(self.showList, 192, -1)
        elif controlId == 191:      # TV Show channel, right
            self.changeListData(self.showList, 192, 1)
        elif controlId == 200:      # Directory channel, select
            dlg = xbmcgui.Dialog()
            retval = dlg.browse(0, "Channel " + str(self.channel) + " Directory", "files")

            if len(retval) > 0:
                self.getControl(200).setLabel(retval)

        self.log("onClick return")