Esempio n. 1
0
def IsUpdateNeededForHostsChangesCommit(enabledHostsListOld, enabledHostsList=None, hostsFromFolder=None):
    if enabledHostsList == None: 
        enabledHostsList = GetEnabledHostsList()
    if hostsFromFolder == None: 
        hostsFromFolder = GetHostsList(fromList=False, fromHostFolder=True)

    bRet = False
    if config.plugins.iptvplayer.remove_diabled_hosts.value and enabledHostsList != enabledHostsListOld:
        hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
        diffDisabledHostsList = set(enabledHostsListOld).difference(set(enabledHostsList))
        diffList = set(enabledHostsList).symmetric_difference(set(enabledHostsListOld))
        for hostItem in diffList:
            if hostItem in hostsFromList:
                if hostItem in diffDisabledHostsList:
                    if hostItem in hostsFromFolder:
                        # standard host has been disabled but it is still in folder
                        bRet = True
                        break
                else:
                    if hostItem not in hostsFromFolder:
                        # standard host has been enabled but it is not in folder
                        bRet = True
                        break
    if bRet:
        SetGraphicsHash("")
        SetIconsHash("")
    return bRet
Esempio n. 2
0
    def getHostsList(self, groupName):
        printDBG("IPTVHostsGroups.getHostsList")
        if groupName in self.CACHE_HOSTS:
            return self.CACHE_HOSTS[groupName]

        if self.hostListFromFolder == None:
            self.hostListFromFolder = GetHostsList(fromList=False,
                                                   fromHostFolder=True)
        if self.hostListFromList == None:
            self.hostListFromList = GetHostsList(fromList=True,
                                                 fromHostFolder=False)

        groupFile = self._getGroupFile(groupName)
        self._loadHosts(groupFile, groupName, self.hostListFromFolder,
                        self.hostListFromFolder)

        hosts = []
        for host in self.LOADED_HOSTS[groupName]:
            if IsHostEnabled(host):
                hosts.append(host)

        for host in self.PREDEFINED_HOSTS.get(groupName, []):
            if host not in hosts and host not in self.LOADED_DISABLED_HOSTS[
                    groupName] and host in self.hostListFromList and host in self.hostListFromFolder and IsHostEnabled(
                        host):
                hosts.append(host)

        self.CACHE_HOSTS[groupName] = hosts
        return hosts
    def stepRemoveUnnecessaryFiles(self):
        printDBG("stepRemoveUnnecessaryFiles")
        playerSelectorPath = os_path.join(self.ExtensionTmpPath,
                                          'IPTVPlayer/icons/PlayerSelector/')
        logosPath = os_path.join(self.ExtensionTmpPath,
                                 'IPTVPlayer/icons/logos/')
        hostsPath = os_path.join(self.ExtensionTmpPath, 'IPTVPlayer/hosts/')
        webPath = os_path.join(self.ExtensionTmpPath, 'IPTVPlayer/Web/')
        cmds = []
        iconSize = int(config.plugins.iptvplayer.IconsSize.value)
        if not config.plugins.iptvplayer.ListaGraficzna.value:
            iconSize = 0
        for size in [135, 120, 100]:
            if size != iconSize:
                cmds.append('rm -f %s' %
                            (playerSelectorPath + '*{0}.png'.format(size)))
                cmds.append(
                    'rm -f %s' %
                    (playerSelectorPath + 'marker{0}.png'.format(size + 45)))

        # remove Web iterface module if not needed
        if not config.plugins.iptvplayer.IPTVWebIterface.value:
            cmds.append('rm -rf %s' % (webPath))

        # removing not needed hosts
        if config.plugins.iptvplayer.remove_diabled_hosts.value:
            enabledHostsList = GetEnabledHostsList()
            hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
            hostsFromFolder = GetHostsList(fromList=False, fromHostFolder=True)
            hostsToRemove = []
            for hostItem in hostsFromList:
                if hostItem not in enabledHostsList and hostItem in hostsFromFolder:
                    cmds.append(
                        'rm -f %s' %
                        (playerSelectorPath + '{0}*.png'.format(hostItem)))
                    cmds.append('rm -f %s' %
                                (logosPath + '{0}logo.png'.format(hostItem)))
                    cmds.append('rm -f %s' %
                                (hostsPath + 'host{0}.py*'.format(hostItem)))

            # we need to prepare temporary file with removing cmds because cmd can be to long
            cmdFilePath = GetTmpDir('.iptv_remove_cmds.sh')
            cmds.insert(0, '#!/bin/sh')
            cmds.append('exit 0\n')
            text = '\n'.join(cmds)
            WriteTextFile(cmdFilePath, text, 'ascii')
            cmd = '/bin/sh "{0}" '.format(cmdFilePath)
            #cmd = '/bin/sh "{0}" && rm -rf "{1}" '.format(cmdFilePath, cmdFilePath)
        else:
            cmd = ' && '.join(cmds)
        printDBG("stepRemoveUnnecessaryFiles cmdp[%s]" % cmd)
        self.cmd = iptv_system(cmd, self.__removeUnnecessaryFilesCmdFinished)
Esempio n. 4
0
 def hostsPageContent(self, MenuStatusMSG, ShowCancelButton):
     tempText = '<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n'
     tempText += IncludeMENU(MenuStatusMSG, ShowCancelButton)
     tempText += '<div class="main"><table border="0" cellspacing="50px"><tbody>\n<tr>'
     columnIndex = 1
     displayHostsList = SortHostsList(GetHostsList())
     if 0 == len(GetHostsOrderList()):
         try:
             displayHostsList.sort(key=lambda t: tuple('.'.join(
                 str(t[0]).replace('://', '.').replace('www.', '').split(
                     '.')[1:-1]).lower()))
         except Exception as e:
             print("Exception during sorting displayHostsList", str(e))
     for hostName in displayHostsList:
         if hostName in settings.activeHostsHTML.keys():
             hostHTML = settings.activeHostsHTML[hostName]
             tempText += hostHTML
             #tempText += '<td><button type="button" disabled>%s</button> </td>' % _('Enter')
             columnIndex += 1
             if columnIndex > 4:
                 columnIndex = 1
                 tempText += '</tr>\n<tr>'
     tempText += '</tr>'
     tempText += '</tbody></table></div></body>\n'
     return tempText
Esempio n. 5
0
 def settingsPageContent(self, MenuStatusMSG):
     usedCFG = []
     tempText = '<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n<div class="main">\n'
     tempText += IncludeMENU(MenuStatusMSG)
     #build hosts settings section
     hostsCFG = '<br><table width="850px" border="1"><tbody>\n'
     hostsCFG += '<tr><td align="center" colspan="3"><p><font size="5" color="#9FF781">%s</font></p></td></tr>\n' % _(
         'Hosts settings')
     for hostName in SortHostsList(GetHostsList()):
         if hostName in settings.configsHTML.keys():
             hostsCFG += settings.configsHTML[hostName]
     hostsCFG += '</tbody></table>\n'
     #build plugin global settings
     pluginCFG = '<table width="850px" border="1"><tbody>\n'
     pluginCFG += '<tr><td align="center" colspan="2"><p><font size="5" color="#9FF781">%s</font></p></td></tr>\n' % _(
         'Plugin global settings')
     from Plugins.Extensions.IPTVPlayer.components.iptvconfigmenu import ConfigMenu
     OptionsList = []
     ConfigMenu.fillConfigList(OptionsList, hiddenOptions=False)
     for item in OptionsList:
         if item[0] in settings.configsHTML.keys():
             pluginCFG += settings.configsHTML[item[0]]
     pluginCFG += '</tbody></table>\n'
     tempText += pluginCFG + '<p><br</p>\n' + hostsCFG + '</div></body>\n'
     return tempText
Esempio n. 6
0
 def getMessageBeforeClose(self, afterSave):
     needPluginUpdate = False
     if afterSave and config.plugins.iptvplayer.ListaGraficzna.value and 0 == GetAvailableIconSize(False):
         needPluginUpdate = True
     else:
         enabledHostsList = GetEnabledHostsList()
         hostsFromFolder  = GetHostsList(fromList=False, fromHostFolder=True)
         if self.remove_diabled_hostsOld != config.plugins.iptvplayer.remove_diabled_hosts.value:
             if config.plugins.iptvplayer.remove_diabled_hosts.value:
                 for folderItem in hostsFromFolder:
                     if folderItem in enabledHostsList:
                         continue
                     else:
                         # there is host file which is not enabled, 
                         # so we need perform update to remove it
                         needPluginUpdate = True
                         break
             else:
                 hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
                 if not set(hostsFromList).issubset(set(hostsFromFolder)):
                     # there is missing hosts files, we need updated does not matter 
                     # if these hosts are enabled or disabled
                     needPluginUpdate = True
             
         elif config.plugins.iptvplayer.remove_diabled_hosts.value and enabledHostsList != self.enabledHostsListOld:
             hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
             diffDisabledHostsList = set(self.enabledHostsListOld).difference(set(enabledHostsList))
             diffList = set(enabledHostsList).symmetric_difference(set(self.enabledHostsListOld))
             for hostItem in diffList:
                 if hostItem in hostsFromList:
                     if hostItem in diffDisabledHostsList:
                         if hostItem in hostsFromFolder:
                             # standard host has been disabled but it is still in folder
                             needPluginUpdate = True
                             break
                     else:
                         if hostItem not in hostsFromFolder:
                             # standard host has been enabled but it is not in folder
                             needPluginUpdate = True
                             break
         
     if needPluginUpdate:
         return _('Some changes will be applied only after plugin update.\nDo you want to perform update now?')
     else:
         return ''
Esempio n. 7
0
	def hostsPageContent(self, MenuStatusMSG, ShowCancelButton):
		tempText = '<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n'
		tempText += IncludeMENU(MenuStatusMSG, ShowCancelButton)
		tempText += '<div class="main"><table border="0" cellspacing="50px"><tbody>\n<tr>'
		columnIndex = 1
		displayHostsList = SortHostsList(GetHostsList())
		if 0 == len(GetHostsOrderList()):
			try:
				displayHostsList.sort(key=lambda t: tuple('.'.join(str(t[0]).replace('://', '.').replace('www.', '').split('.')[1:-1]).lower()))
			except Exception, e:
				print "Exception during sorting displayHostsList", str(e)
Esempio n. 8
0
 def getMessageBeforeClose(self, afterSave):
     needPluginUpdate = False
     if afterSave and config.plugins.iptvplayer.ListaGraficzna.value and 0 == GetAvailableIconSize(False):
         needPluginUpdate = True
     else:
         enabledHostsList = GetEnabledHostsList()
         hostsFromFolder  = GetHostsList(fromList=False, fromHostFolder=True)
         if self.remove_diabled_hostsOld != config.plugins.iptvplayer.remove_diabled_hosts.value:
             if config.plugins.iptvplayer.remove_diabled_hosts.value:
                 for folderItem in hostsFromFolder:
                     if folderItem in enabledHostsList:
                         continue
                     else:
                         # there is host file which is not enabled, 
                         # so we need perform update to remove it
                         needPluginUpdate = True
                         break
             else:
                 hostsFromList = GetHostsList(fromList=True, fromHostFolder=False)
                 if not set(hostsFromList).issubset(set(hostsFromFolder)):
                     # there is missing hosts files, we need updated does not matter 
                     # if these hosts are enabled or disabled
                     needPluginUpdate = True
         elif IsUpdateNeededForHostsChangesCommit(self.enabledHostsListOld, enabledHostsList, hostsFromFolder):
             needPluginUpdate = True
     
     if needPluginUpdate:
         SetGraphicsHash("")
         SetIconsHash("")
     
     if not needPluginUpdate and config.plugins.iptvplayer.IPTVWebIterface.value != IsWebInterfaceModuleAvailable(True):
         needPluginUpdate = True
         
     if needPluginUpdate:
         return _('Some changes will be applied only after plugin update.\nDo you want to perform update now?')
     else:
         return ''
Esempio n. 9
0
    def run(self):
        for hostName in SortHostsList(GetHostsList()):
            if hostName in [
                    'localmedia', 'urllist'
            ]:  # those are local hosts, nothing to do via web interface
                continue
            if not IsHostEnabled(hostName):
                continue
            # column 1 containing logo and link if available
            try:
                _temp = __import__(
                    'Plugins.Extensions.IPTVPlayer.hosts.host' + hostName,
                    globals(), locals(), ['gettytul'], -1)
                title = _temp.gettytul()
                _temp = None
            except Exception:
                continue  # we do NOT use broken hosts!!!

            logo = getHostLogo(hostName)

            if title[:4] == 'http' and logo == "":
                try:
                    hostNameWithURLandLOGO = '<br><a href="./usehost?activeHost=%s" target="_blank"><font size="2" color="#58D3F7">%s</font></a>' % (
                        hostName, '.'.join(
                            title.replace('://', '.').replace(
                                'www.', '').split('.')[1:-1]))
                except Exception:
                    hostNameWithURLandLOGO = '<br><a href="%s" target="_blank"><font size="2" color="#58D3F7">%s</font></a>' % (
                        title, title)
            elif title[:4] == 'http' and logo != "":
                try:
                    hostNameWithURLandLOGO = '<a href="./usehost?activeHost=%s">%s</a><br><a href="%s" target="_blank"><font size="2" color="#58D3F7">%s</font></a>' % (
                        hostName, logo, title, '.'.join(
                            title.replace('://', '.').replace(
                                'www.', '').split('.')[1:-1]))
                except Exception as e:
                    print(str(e))
                    hostNameWithURLandLOGO = '<a href="%s" target="_blank">%s</a><br><a href="%s" target="_blank"><font size="2" color="#58D3F7">%s</font></a>' % (
                        title, logo, title, _('visit site'))
            elif title[:4] != 'http' and logo != "":
                hostNameWithURLandLOGO = '<a href="./usehost?activeHost=%s">%s</a><br><a href="%s" target="_blank"><font size="2" color="#58D3F7">%s</font></a>' % (
                    hostName, logo, title, title)
            else:
                hostNameWithURLandLOGO = '<br><a>%s</a>' % (title)
            # Column 2 TBD

            #build table row
            hostHTML = '<td align="center">%s</td>' % hostNameWithURLandLOGO
            settings.activeHostsHTML[hostName] = hostHTML
Esempio n. 10
0
 def run(self):
     if settings.GlobalSearchQuery == '':
         print "End settings.GlobalSearchQuery is empty"
         return
     for hostName in SortHostsList(GetHostsList()):
         self.stopIfRequested()
         if hostName in [
                 'localmedia', 'urllist'
         ]:  # those are local hosts, nothing to do via web interface
             continue
         elif hostName in [
                 'localmedia', 'urllist'
         ]:  # those are local hosts, nothing to do via web interface
             continue
         elif hostName in [
                 'seriesonline'
         ]:  # those hosts have issues wth global search, need more investigation
             continue
         elif not IsHostEnabled(hostName):
             continue
         #print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ---------------- %s ---------------- !!!!!!!!!!!!!!!!!!!!!!!!!" % hostName
         try:
             _temp = __import__(
                 'Plugins.Extensions.IPTVPlayer.hosts.host' + hostName,
                 globals(), locals(), ['IPTVHost'], -1)
         except Exception:
             print "doGlobalSearch: Exception importing %s" % hostName
             continue
         try:
             self.host = _temp.IPTVHost()
         except Exception, e:
             print "doGlobalSearch: Exception initializing iptvhost for %s: %s" % (
                 hostName, str(e))
             continue
         #print "settings.GlobalSearchQuery=",settings.GlobalSearchQuery, 'hostName=', hostName
         settings.searchingInHost = hostName
         time.sleep(0.2)  #
         try:
             self.host.getSupportedFavoritesTypes()
             ret = self.host.getInitList()
             searchTypes = self.host.getSearchTypes()
         except Exception, e:
             print "doGlobalSearch: Exception in getInitList for %s: %s" % (
                 hostName, str(e))
             settings.hostsWithNoSearchOption.append(hostName)
             continue
Esempio n. 11
0
config.plugins.iptvplayer.watched_item_color = ConfigSelection(default = "#808080", choices = COLORS_DEFINITONS)
config.plugins.iptvplayer.usepycurl = ConfigYesNo(default = False)

config.plugins.iptvplayer.prefer_hlsdl_for_pls_with_alt_media = ConfigYesNo(default = True)

###################################################

########################################################
# Generate list of hosts options for Enabling/Disabling
########################################################
class ConfigIPTVHostOnOff(ConfigOnOff):
    def __init__(self, default = False):
        ConfigOnOff.__init__(self, default = default)

gListOfHostsNames = GetHostsList()
for hostName in gListOfHostsNames:
    try:
        # as default all hosts are enabled
        if hostName in ['ipla']:
            enabledByDefault = 'False'
        else:
            enabledByDefault = 'True'
        exec('config.plugins.iptvplayer.host' + hostName + ' = ConfigIPTVHostOnOff(default = ' + enabledByDefault + ')')
    except Exception:
        printExc(hostName)

def GetListOfHostsNames():
    global gListOfHostsNames
    return gListOfHostsNames
Esempio n. 12
0
    def run(self):
        usedCFG = []
        #configs for hosts
        for hostName in SortHostsList(GetHostsList()):
            # column 1 containing logo and link if available
            try:
                _temp = __import__(
                    'Plugins.Extensions.IPTVPlayer.hosts.host' + hostName,
                    globals(), locals(), ['gettytul'], -1)
                title = _temp.gettytul()
            except Exception:
                continue  # we do NOT use broken hosts!!!
            usedCFG.append("host%s" % hostName)

            logo = getHostLogo(hostName)
            if logo == "":
                logo = title

            if title[:4] == 'http':
                hostNameWithURLandLOGO = '<a href="%s" target="_blank">%s</a>' % (
                    title, logo)
            else:
                hostNameWithURLandLOGO = '<a>%s</a>' % (logo)
            # Column 2 TBD

            # Column 3 enable/disable host in GUI
            if IsHostEnabled(hostName):
                OnOffState = formSUBMITvalue([('cmd', 'OFF:host' + hostName)],
                                             _('Disable'))
            else:
                OnOffState = formSUBMITvalue([('cmd', 'ON:host' + hostName)],
                                             _('Enable'))

            # Column 4 host configuration options
            try:
                _temp = __import__(
                    'Plugins.Extensions.IPTVPlayer.hosts.host' + hostName,
                    globals(), locals(), ['GetConfigList'], -1)
                OptionsList = _temp.GetConfigList()
            except Exception:
                OptionsList = []

            #build table row
            hostsCFG = '<tr>'
            hostsCFG += '<td style="width:120px">%s</td>' % hostNameWithURLandLOGO
            hostsCFG += '<td>%s</td>' % OnOffState
            if len(OptionsList) == 0:
                hostsCFG += '<td><a>%s</a></td>' % ""  # _('Host does not have configuration options')
            else:
                hostsCFG += '<td><table border="1" style="width:100%">'
                for item in self.buildSettingsTable(
                        List2=OptionsList,
                        List1=config.plugins.iptvplayer.dict().items(),
                        exclList=usedCFG,
                        direction='2>1'):
                    usedCFG.append(item[0])
                    #print('hostsCFG:',item[0], item[1],item[2])
                    if item[0] == 'fake_separator':
                        hostsCFG += '<tr><td colspan="2" align="center"><tt>%s</tt></td></tr>\n' % (
                            item[1])
                    else:
                        hostsCFG += '<tr><td nowrap style="width:50%%"><tt>%s</tt></td><td>%s</td></tr>\n' % (
                            item[1], formGET(item[2]))
                hostsCFG += '</table></td>'
            hostsCFG += '</tr>\n'
            settings.configsHTML[hostName] = hostsCFG
        #now configs for plugin
        OptionsList = []
        ConfigMenu.fillConfigList(OptionsList, hiddenOptions=False)
        for item in self.buildSettingsTable(
                List1=config.plugins.iptvplayer.dict().items(),
                List2=OptionsList,
                exclList=usedCFG,
                direction='2>1'):
            settings.configsHTML[
                item[1]] = '<tr><td><tt>%s</tt></td><td>%s</td></tr>\n' % (
                    item[1], formGET(item[2]))