Пример #1
0
    def populateChannels(self, alphaSort = False):
        channels = []

        try:
            current, dirs, files = sfile.walk(OTT_CHANNELS)
        except Exception, e:
            return channels
Пример #2
0
def getAllChannels(alphaSort = False):
    channels = []

    try:
        current, dirs, files = sfile.walk(TVP_CHANNELS)
    except Exception, e:
        return channels
Пример #3
0
    def populateChannels(self, alphaSort=False):
        channels = []

        try:
            current, dirs, files = sfile.walk(OTT_CHANNELS)
        except Exception, e:
            return channels
Пример #4
0
def newChannel():
    title = ''

    while True:
        title = getText('Please enter channel name', title)
        if not title :
            return False

        id = createID(title)

        try:
            current, dirs, files = sfile.walk(TVP_CHANNELS)
        except Exception, e:
            return False

        duplicate = False
    
        for file in files:
            if id.lower() == file.lower():
                duplicate = True
                break

        if not duplicate:
            break

        utils.DialogOK('%s clashes with an existing channel.' % title, 'Please enter a different name.')
Пример #5
0
    def _locateSuperFavourites(self, title, folder, items):    
        import sfile  
        import settings
        import urllib
        current, dirs, files = sfile.walk(folder)

        for dir in dirs:    
            folder = os.path.join(current, dir)    
            if dir.lower() == title:
                cfg      = os.path.join(folder, 'folder.cfg')
                autoplay = settings.get('AUTOPLAY', cfg)

                if autoplay:
                    uTitle  = urllib.quote_plus(title)
                    mode    = 5400
                    uFolder = urllib.quote_plus(folder)
                    toAdd   = 'plugin://plugin.program.super.favourites/?label=%s&mode=%d&path=%s' % (uTitle, mode, uFolder)
                else:               
                    uTitle  = urllib.quote_plus(title)
                    mode    = 400
                    uFolder = urllib.quote_plus(folder)
                    toAdd   = 'plugin://plugin.program.super.favourites/?label=%s&mode=%d&path=%s' % (uTitle, mode, uFolder)
                    toAdd   = '__SF__ActivateWindow(10025,"%s",return)' % toAdd
                    
                items.append(['SF_'+folder, toAdd])

            self._locateSuperFavourites(title, folder, items)
Пример #6
0
    def _locateSuperFavourites(self, title, folder, items):
        import sfile
        import settings
        import urllib
        current, dirs, files = sfile.walk(folder)

        for dir in dirs:
            folder = os.path.join(current, dir)
            if dir.lower() == title:
                cfg = os.path.join(folder, 'folder.cfg')
                autoplay = settings.get('AUTOPLAY', cfg)

                if autoplay:
                    uTitle = urllib.quote_plus(title)
                    mode = 5400
                    uFolder = urllib.quote_plus(folder)
                    toAdd = 'plugin://plugin.program.super.favourites/?label=%s&mode=%d&path=%s' % (
                        uTitle, mode, uFolder)
                else:
                    uTitle = urllib.quote_plus(title)
                    mode = 400
                    uFolder = urllib.quote_plus(folder)
                    toAdd = 'plugin://plugin.program.super.favourites/?label=%s&mode=%d&path=%s' % (
                        uTitle, mode, uFolder)
                    toAdd = '__SF__ActivateWindow(10025,"%s",return)' % toAdd

                items.append(['SF_' + folder, toAdd])

            self._locateSuperFavourites(title, folder, items)
Пример #7
0
def isPlayable(path, ignore, maxAge=-1):
    if not sfile.exists(path):
        return False

    if sfile.isfile(path):
        playable = isFilePlayable(path, maxAge)
        return playable

    try:
        if sfile.getfilename(path)[0] in ignore:
            return False
    except:
        pass
         
    current, dirs, files = sfile.walk(path)

    for file in files:
        if isPlayable(os.path.join(current, file), ignore, maxAge):
            return True

    for dir in dirs:
        try: 
            if isPlayable(os.path.join(current, dir), ignore, maxAge):
                return True
        except:
            pass

    return False
Пример #8
0
    def _locateSuperFavourites(self, title, folder, items):    
        import sfile  
        import settings
        import urllib
        current, dirs, files = sfile.walk(folder)
         
        for dir in dirs:    
            folder = os.path.join(current, dir)

# check against SF list, if it exists then match up
            if dir.upper() == title:
#                cfg      = os.path.join(folder, 'folder.cfg')
#                autoplay = settings.get('AUTOPLAY', cfg)

                if autoplay == 'true':
                    uTitle  = urllib.quote_plus(title)
                    mode    = 5400
                    uFolder = urllib.quote_plus(folder)
                    toAdd   = 'plugin://plugin.program.super.favourites/?label=%s&mode=%d&path=%s' % (uTitle, mode, uFolder)
                else:               
                    uTitle  = urllib.quote_plus(title)
                    mode    = 400
                    uFolder = urllib.quote_plus(folder)
                    toAdd   = 'plugin://plugin.program.super.favourites/?label=%s&mode=%d&path=%s' % (uTitle, mode, uFolder)
                    toAdd   = '__SF__ActivateWindow(10025,"%s",return)' % toAdd
                xbmc.log('##### FOLDER: %s' % folder)
                if os.path.exists(xbmc.translatePath(os.path.join(folder,'favourites.xml'))):
                    items.append(['SF_'+folder, toAdd])

            self._locateSuperFavourites(title, folder, items)
Пример #9
0
def _parseFolder(folder, root, subfolders, ignore, maxAge=-1):
    items = []

    if not folder:
        folder = getExternalDrive()
        if isPlayable(folder, ignore, maxAge):
            items.append([root, folder, False, True])
        return items

    current, dirs, files = sfile.walk(folder)

    if subfolders:
        for dir in dirs:        
            path = os.path.join(current, dir)
            if dir.endswith('_PLAYALL'):
                items.append([dir.rsplit('_PLAYALL', 1)[0], path, True, True])
            elif isPlayable(path, ignore, maxAge):
                items.append([dir, path, False, True])

    for file in files:
        path = os.path.join(current, file)
        if isPlayable(path, ignore, maxAge):
            items.append([removeExtension(file), path, True, False])

    return items
Пример #10
0
    def _locateSuperFavourites(self, title, folder, items):    
        import sfile  
        import settings
        import urllib
        current, dirs, files = sfile.walk(folder)
         
        for dir in dirs:    
            folder = os.path.join(current, dir)

# check against SF list, if it exists then match up
            if dir.upper() == title:
#                cfg      = os.path.join(folder, 'folder.cfg')
#                autoplay = settings.get('AUTOPLAY', cfg)

                if autoplay == 'true':
                    uTitle  = urllib.quote_plus(title)
                    mode    = 5400
                    uFolder = urllib.quote_plus(folder)
                    toAdd   = 'plugin://plugin.program.super.favourites/?label=%s&mode=%d&path=%s' % (uTitle, mode, uFolder)
                else:               
                    uTitle  = urllib.quote_plus(title)
                    mode    = 400
                    uFolder = urllib.quote_plus(folder)
                    toAdd   = 'plugin://plugin.program.super.favourites/?label=%s&mode=%d&path=%s' % (uTitle, mode, uFolder)
                    toAdd   = '__SF__ActivateWindow(10025,"%s",return)' % toAdd
                xbmc.log('##### FOLDER: %s' % folder)
                if os.path.exists(xbmc.translatePath(os.path.join(folder,'favourites.xml'))):
                    items.append(['SF_'+folder, toAdd])

            self._locateSuperFavourites(title, folder, items)
Пример #11
0
    def getAllChannels(self):
        channels = []

        try:
            current, dirs, files = sfile.walk(channelPath)
        except Exception, e:
            dixie.log('Error in getAllChannels' % str(e))
            return channels
Пример #12
0
    def getAllChannels(self):
        channels = []

        try:
            current, dirs, files = sfile.walk(channelPath)
        except Exception, e:
            dixie.log('Error in getAllChannels' % str(e))
            return channels
Пример #13
0
 def populateChannels(self, alphaSort=False):
     channels = []
     channelarray = []
     SFchannelarray = []
     try:
         current, dirs, files = sfile.walk(OTT_CHANNELS)
     except Exception, e:
         dixie.log('### Failed to scan master channel list: %s' % str(e))
         return channelarray
Пример #14
0
def sf_check(channels,weight):
    sfchans     = []
    newchans    = []
# Grab a list of all the SF folders with a favourites.xml
    dixie.log('Checking for new SF folders')
    try:
        current, dirs, files = sfile.walk(SF_CHANNELS)
    except Exception, e:
        dixie.log('Error in getAllChannels - SF List: %s' % str(e))
Пример #15
0
 def populateChannels(self, alphaSort = False):
     channels = []
     channelarray = []
     SFchannelarray = []
     try:
         current, dirs, files = sfile.walk(OTT_CHANNELS)
     except Exception, e:
         dixie.log('### Failed to scan master channel list: %s' % str(e))
         return channelarray
Пример #16
0
def sf_check(channels, weight):
    sfchans = []
    newchans = []
    # Grab a list of all the SF folders with a favourites.xml
    dixie.log('Checking for new SF folders')
    try:
        current, dirs, files = sfile.walk(SF_CHANNELS)
    except Exception, e:
        dixie.log('Error in getAllChannels - SF List: %s' % str(e))
Пример #17
0
def CheckForChannels():
    dir    = dixie.GetChannelFolder()
    folder = os.path.join(dir, 'channels')
    files  = []
    try:    current, dirs, files = sfile.walk(folder)
    except: pass
    if len(files) == 0:
        dixie.SetSetting('updated.channels', -1) # force refresh of channels
    
    backup = os.path.join(dir, 'channels-backup')
    if not sfile.exists(backup):
        dixie.BackupChannels()
Пример #18
0
def SF_Folder_Count(foldermode):
    channelFolder  =  GetChannelFolder()
    channelPath    =  os.path.join(channelFolder,'channels')
    channels       = []
    channelarray   = []
    SFchannelarray = []

    try:
        current, dirs, files = sfile.walk(channelPath)
    except Exception, e:
        log('Error in getAllChannels - Master List: %s' % str(e))
        return channels
Пример #19
0
def _getAllPlayableFiles(folder, theFiles):
    current, dirs, files = sfile.walk(folder)

    for dir in dirs:        
        path = os.path.join(current, dir)
        _getAllPlayableFiles(path, theFiles)

    for file in files:
        path = os.path.join(current, file)
        if isPlayable(path, ignore=[]):
            size = sfile.size(path)
            theFiles[path] = [path, size]
Пример #20
0
def SF_Folder_Count(foldermode):
    channelFolder = GetChannelFolder()
    channelPath = os.path.join(channelFolder, 'channels')
    channels = []
    channelarray = []
    SFchannelarray = []

    try:
        current, dirs, files = sfile.walk(channelPath)
    except Exception, e:
        log('Error in getAllChannels - Master List: %s' % str(e))
        return channels
Пример #21
0
def _getAllPlayableFiles(folder, theFiles):
    current, dirs, files = sfile.walk(folder)

    for dir in dirs:
        path = os.path.join(current, dir)
        _getAllPlayableFiles(path, theFiles)

    for file in files:
        path = os.path.join(current, file)
        if isPlayable(path):
            size = sfile.size(path)
            theFiles[path] = [path, size]
Пример #22
0
def patchSkins():
    skinPath = os.path.join(extras, 'skins')

    srcImage = os.path.join(RESOURCES, 'changer.png')
    srcFile = os.path.join(RESOURCES, 'script-tvguide-changer.xml')

    current, dirs, files = sfile.walk(skinPath)

    for dir in dirs:
        dstImage = os.path.join(current, dir, 'resources', 'skins', 'Default', 'media', 'changer.png')
        dstFile = os.path.join(current, dir, 'resources', 'skins', 'Default', '720p', 'script-tvguide-changer.xml')

        sfile.copy(srcImage, dstImage, overWrite=False)
        sfile.copy(srcFile, dstFile, overWrite=False)
Пример #23
0
def patchSkins():
    skinPath = os.path.join(extras, 'skins')

    srcImage = os.path.join(RESOURCES, 'changer.png')
    srcFile  = os.path.join(RESOURCES, 'script-tvguide-changer.xml')

    current, dirs, files = sfile.walk(skinPath)

    for dir in dirs:
        dstImage = os.path.join(current, dir, 'resources', 'skins', 'Default', 'media', 'changer.png')
        dstFile  = os.path.join(current, dir, 'resources', 'skins', 'Default', '720p', 'script-tvguide-changer.xml')

        sfile.copy(srcImage, dstImage, overWrite=False)
        sfile.copy(srcFile,  dstFile,  overWrite=False)
Пример #24
0
def CheckForChannels():
    dir = dixie.GetChannelFolder()
    folder = os.path.join(dir, 'channels')
    files = []
    try:
        current, dirs, files = sfile.walk(folder)
    except:
        pass
    if len(files) == 0:
        dixie.SetSetting('updated.channels', -1)  # force refresh of channels

    backup = os.path.join(dir, 'channels-backup')
    if not sfile.exists(backup):
        dixie.BackupChannels()
Пример #25
0
def restoreChannels():
    src = os.path.join(datapath, 'channels-backup')
    dst = os.path.join(datapath, 'channels')

    if not sfile.exists(src):
        return False

    try:
        current, dirs, files = sfile.walk(src)
        for file in files:
            full = os.path.join(current, file)
            sfile.copy(full, dst)
    except Exception, e:
        print str(e)
        return False
def restoreChannels():
    src = os.path.join(datapath, 'channels-backup')
    dst = os.path.join(datapath, 'channels')

    if not sfile.exists(src):
        return False
    
    try:
        current, dirs, files = sfile.walk(src)
        for file in files:
            full = os.path.join(current, file)
            sfile.copy(full,  dst)
    except Exception, e:
        print str(e)
        return False
Пример #27
0
def _removePartFiles(folder, recurse=True):
    current, dirs, files = sfile.walk(folder)

    for file in files:
        if file.endswith('.part'):
            file = os.path.join(current, file)
            tidyUp(file.rsplit('.part', 1)[0])
            #sfile.remove(file)
            #sfile.remove(file.rsplit('.part', 1)[0])

    if not recurse:
        return

    for dir in dirs:        
        folder = os.path.join(current, dir)
        _removePartFiles(folder, recurse)
Пример #28
0
def extract(src, dp):
    success = False
    try:
        src = xbmc.translatePath(src)
        import zipfile

        update = os.path.join(PROFILE, 'update')
        update = xbmc.translatePath(update)
        sfile.makedirs(update)

        zin   = zipfile.ZipFile(src, 'r')
        nItem = float(len(zin.infolist()))

        index = 0
        for item in zin.infolist():
            index += 1

            percent  = int(index / nItem *100)
            #filename = item.filename

            zin.extract(item, update)
  
            if dp:
                dp.update(percent, utils.GETTEXT(30118), utils.GETTEXT(30080))

        addons = os.path.join('special://home', 'addons')
        current, folders, files = sfile.walk(update)

        for folder in folders:
            ori = os.path.join(addons, folder)
            src = os.path.join(current, folder)
            dst = os.path.join(addons, folder + '.temp')
            sfile.copytree(src, dst)
            sfile.rmtree(ori)
            while not sfile.exists(dst):
                xbmc.sleep(100)
            while sfile.exists(ori):
                xbmc.sleep(100)
            sfile.rename(dst, ori)   

        success = True
    except:
        success = False

    sfile.delete(update)
    return success
Пример #29
0
    def getFaves(self):
        file = os.path.join(self.FULLPATH, FILENAME).decode('utf-8')
        faves = []

        index = 0

        label_numeric = LABEL_NUMERIC
        if self.MODE == 'folder':
            folderCfg = os.path.join(self.FULLPATH, FOLDERCFG)
            numeric = parameters.getParam('NUMERICAL', folderCfg)
            if numeric:
                label_numeric = numeric.lower() == 'true'

        if label_numeric:
            label_numeric = LABEL_NUMERIC_QL

        if self.MODE != 'xbmc':
            try:
                current, dirs, files = sfile.walk(self.FULLPATH)

                dirs = sorted(dirs, key=str.lower)

                for dir in dirs:
                    path = os.path.join(self.FULLPATH, dir)

                    folderCfg = os.path.join(path, FOLDERCFG)
                    folderCfg = parameters.getParams(folderCfg)
                    lock = parameters.getParam('LOCK', folderCfg)
                    if lock:
                        continue
                    colour = parameters.getParam('COLOUR', folderCfg)
                    thumb = getFolderThumb(path)

                    label = dir

                    if colour and colour.lower() <> 'none':
                        label = '[COLOR %s]%s[/COLOR]' % (colour, label)

                    label, index = utils.addPrefixToLabel(
                        index, label, label_numeric)

                    fave = [label, thumb, os.path.join(self.PATH, dir), True]
                    faves.append(fave)

            except Exception, e:
                pass
Пример #30
0
def parseFolder(folder, subfolders=True):
    items = []

    current, dirs, files = sfile.walk(folder)

    if subfolders:
        for dir in dirs:        
            path = os.path.join(current, dir)
            if isPlayable(path):
                items.append([dir, path, False])

    for file in files:
        path = os.path.join(current, file)
        if isPlayable(path):
            items.append([file, path, True])

    return items
Пример #31
0
def parseFolder(folder, subfolders=True):
    items = []

    current, dirs, files = sfile.walk(folder)

    if subfolders:
        for dir in dirs:
            path = os.path.join(current, dir)
            if isPlayable(path):
                items.append([dir, path, False])

    for file in files:
        path = os.path.join(current, file)
        if isPlayable(path):
            items.append([file, path, True])

    return items
Пример #32
0
    def getFaves(self):
        file  = os.path.join(self.FULLPATH, FILENAME).decode('utf-8')        
        faves = []        

        index = 0

        label_numeric = LABEL_NUMERIC 
        if self.MODE == 'folder':    
            folderCfg = os.path.join(self.FULLPATH, FOLDERCFG)
            numeric = parameters.getParam('NUMERICAL', folderCfg)
            if numeric:
                label_numeric = numeric.lower() == 'true'

        if label_numeric:
            label_numeric = LABEL_NUMERIC_QL

        if self.MODE != 'xbmc':        
            try:    
                current, dirs, files = sfile.walk(self.FULLPATH)

                dirs = sorted(dirs, key=str.lower)

                for dir in dirs:
                    path = os.path.join(self.FULLPATH, dir)
                                   
                    folderCfg = os.path.join(path, FOLDERCFG)
                    folderCfg = parameters.getParams(folderCfg)
                    lock      = parameters.getParam('LOCK',   folderCfg)
                    if lock:
                        continue
                    colour    = parameters.getParam('COLOUR', folderCfg)
                    thumb     = getFolderThumb(path)               

                    label = dir
                
                    if colour and colour.lower() <> 'none':
                        label = '[COLOR %s]%s[/COLOR]' % (colour, label)
              
                    label, index = utils.addPrefixToLabel(index, label, label_numeric)
                
                    fave = [label, thumb, os.path.join(self.PATH, dir),  True]
                    faves.append(fave)
                
            except Exception, e:
                pass
Пример #33
0
    def getAllChannels(self):
        channels       = []

        if showSFchannels == 'true':
            try:
                current, dirs, files = sfile.walk(SF_CHANNELS)
            except Exception, e:
                dixie.log('Error in getAllChannels - SF List: %s' % str(e))
                return channels

    # Grab a list of SF folders not in the channels folder and add as dummy channels
            for dir in dirs:
                try:
                    if os.path.exists(os.path.join(SF_CHANNELS,dir,'favourites.xml')):
                        channels.append(dir)

                except:
                    dixie.log("Special characters in directory, skipping: "+dir)
Пример #34
0
    def getAllChannels(self):
        channels       = []

        if showSFchannels == 'true':
            try:
                current, dirs, files = sfile.walk(SF_CHANNELS)
            except Exception, e:
                dixie.log('Error in getAllChannels - SF List: %s' % str(e))
                return channels

    # Grab a list of SF folders not in the channels folder and add as dummy channels
            for dir in dirs:
                try:
                    if os.path.exists(os.path.join(SF_CHANNELS,dir,'favourites.xml')):
                        channels.append(dir)

                except:
                    dixie.log("Special characters in directory, skipping: "+dir)
Пример #35
0
def parseFolder(folder):
    try:    current, dirs, files = sfile.walk(folder)
    except: return []

    items = []

    for file in files:
        try:
            path = os.path.join(current, file)
            file = file.rsplit('.', 1)
            ext  = file[-1]
            file = file[0]            
            if ext in PLAYLIST_EXT:
                items.append([path, file])
        except:
            pass

    return items
Пример #36
0
def isPlayable(path):
    if not sfile.exists(path):
        return False

    if sfile.isfile(path):
        playable = isFilePlayable(path)
        return playable
         
    current, dirs, files = sfile.walk(path)

    for file in files:
        if isPlayable(os.path.join(current, file)):
            return True

    for dir in dirs:        
        if isPlayable(os.path.join(current, dir)):
            return True

    return False
Пример #37
0
def isPlayable(path):
    if not sfile.exists(path):
        return False

    if sfile.isfile(path):
        playable = isFilePlayable(path)
        return playable

    current, dirs, files = sfile.walk(path)

    for file in files:
        if isPlayable(os.path.join(current, file)):
            return True

    for dir in dirs:
        if isPlayable(os.path.join(current, dir)):
            return True

    return False
Пример #38
0
def doAdd():
    root, folders, files = sfile.walk(XBMCHOME)

    list = []

    for folder in folders:
        file = os.path.join(root, folder, 'addon.xml')
        if sfile.exists(file):
            if not folder in WHITELIST:
                list.append(folder)   

    option = xbmcgui.Dialog().select(GETTEXT(35041), list)
    if option < 0:
        return

    folder = list[option]
    
    whitelist = WHITELIST + SEPARATOR + folder

    ADDON.setSetting('WHITELIST', tidy(whitelist))
Пример #39
0
def doAdd():
    root, folders, files = sfile.walk(XBMCHOME)

    list = []

    for folder in folders:
        file = os.path.join(root, folder, 'addon.xml')
        if sfile.exists(file):
            if not folder in WHITELIST:
                list.append(folder)

    option = xbmcgui.Dialog().select(GETTEXT(35041), list)
    if option < 0:
        return

    folder = list[option]

    whitelist = WHITELIST + SEPARATOR + folder

    ADDON.setSetting('WHITELIST', tidy(whitelist))
Пример #40
0
def parseFolder(folder):
    try:
        current, dirs, files = sfile.walk(folder)
    except:
        return []

    items = []

    for file in files:
        try:
            path = os.path.join(current, file)
            file = file.rsplit('.', 1)
            ext = file[-1]
            file = file[0]
            if ext in PLAYLIST_EXT:
                items.append([path, file])
        except:
            pass

    return items
Пример #41
0
def Grab_Providers():
    fail        = 0
    final_array = []

# Walk through files in the providers folder
    if os.path.exists(PROVIDER_PATH):
        current, dirs, files = sfile.walk(PROVIDER_PATH)
        for file in files:
            if fail != 1:

    # Turn each line into an array then go through the array and search for keywords
                with open(os.path.join(PROVIDER_PATH, file),'rb') as fin:
                    content     = fin.read().splitlines()
                    name        = Find_In_Lines(content, '"name"', '"')
                    repository  = Find_In_Lines(content, '"repository"', '"')
                    plugin      = Find_In_Lines(content, '"plugin"', '"')
                    playertype  = Find_In_Lines(content, '"id"', '"')

    # If this is a valid live tv provider with relevant info we add to the array
                    for line in content:
                        if '"live"' in line and '[' in line and not ']' in line and plugin != 'Unknown' and repository != 'Unknown' and repository != 'na' and name != 'Unknown' and playertype != 'Unknown':
                            final_array.append([name, repository, plugin, playertype])
    return final_array
Пример #42
0
def Grab_Providers():
    fail        = 0
    final_array = []

# Walk through files in the providers folder
    if os.path.exists(PROVIDER_PATH):
        current, dirs, files = sfile.walk(PROVIDER_PATH)
        for file in files:
            if fail != 1:

    # Turn each line into an array then go through the array and search for keywords
                with open(os.path.join(PROVIDER_PATH, file),'rb') as fin:
                    content     = fin.read().splitlines()
                    name        = Find_In_Lines(content, '"name"', '"')
                    repository  = Find_In_Lines(content, '"repository"', '"')
                    plugin      = Find_In_Lines(content, '"plugin"', '"')
                    playertype  = Find_In_Lines(content, '"id"', '"')

    # If this is a valid live tv provider with relevant info we add to the array
                    for line in content:
                        if '"live"' in line and '[' in line and not ']' in line and plugin != 'Unknown' and repository != 'Unknown' and repository != 'na' and name != 'Unknown' and playertype != 'Unknown':
                            final_array.append([name, repository, plugin, playertype])
    return final_array
Пример #43
0
except:
    silent = 0

xbmc.log('##### SILENT = %s' % sys.argv[1])


if SF_CHANNELS == '':
    dialog.ok('SF Folder Not Set', 'No Super Favourite location has been set, please set the folder location in your settings then run again.')
else:
    provider_array  =   Grab_Providers()
    if len(provider_array) > 0:
        if SF_CHANNELS.startswith('special://'):
            SF_CHANNELS = xbmc.translatePath(SF_CHANNELS)
            
        try:
            current, dirs, files = sfile.walk(OTT_CHANNELS)
        except Exception, e:
            dixie.log('Failed to run script: %s' % str(e))
            
        if SF_METALLIQ == 'true':
            try:
                for file in files:
                    if not os.path.exists(os.path.join(SF_CHANNELS, '-metalliq', file)):
                        try:
                            os.makedirs(os.path.join(SF_CHANNELS, '-metalliq', file))
                        except:
                            dixie.log('### Failed to create folder for: %s' % str(file))
                    dixie.log('## Creating xml for: %s' % file)
                    Create_XML(os.path.join(SF_CHANNELS, '-metalliq', file))
            except:
                pass
#

import xbmcgui
import xbmcaddon
import os
import dixie
import sfile

AddonID        =  'script.tvportal'
ADDON          =  xbmcaddon.Addon(id=AddonID)
SF_CHANNELS    =  ADDON.getSetting('SF_CHANNELS')
OTT_CHANNELS   =  os.path.join(dixie.GetChannelFolder(), 'channels')
dialog         =  xbmcgui.Dialog()

if SF_CHANNELS.startswith('special://'):
	SF_CHANNELS = xbmc.translatePath(SF_CHANNELS)
	
try:
    current, dirs, files = sfile.walk(OTT_CHANNELS)
except Exception, e:
    dixie.log('Failed to run script: %s' % str(e))
    
for file in files:
    if not os.path.exists(os.path.join(SF_CHANNELS,file)):
        try:
            print os.path.join(SF_CHANNELS,file)
            os.makedirs(os.path.join(SF_CHANNELS,file))
        except:
            dixie.log('### Failed to create folder for: %s' % str(file))

dialog.ok(ADDON.getLocalizedString(30809),ADDON.getLocalizedString(30810))
Пример #45
0
            except Exception, e:
                dixie.log('Error in getAllChannels - SF List: %s' % str(e))
                return channels

    # Grab a list of SF folders not in the channels folder and add as dummy channels
            for dir in dirs:
                if dir != '-_ADD_OR_REMOVE_CHANNELS':
                    try:
                        if os.path.exists(os.path.join(SF_CHANNELS,dir,'favourites.xml')):
                            channels.append(dir)
                    except:
                        dixie.log("Special characters in directory, skipping: "+dir)

        else:
            try:
                current, dirs, files = sfile.walk(channelPath)
            except Exception, e:
                dixie.log('Error in getAllChannels - Master List: %s' % str(e))
                return channels

            for file in files:
                if file != '-_ADD_OR_REMOVE_CHANNELS':
                    try:
                        channels.append(file)
                    except:
                        dixie.log("failed to add to array: "+file)

        return channels

    def removeCleanChannel(self, id):
        try:    del self.channelDict[id]
Пример #46
0
class OSD(xbmcgui.WindowXMLDialog):
    def __new__(cls, channel='', epgMode=False, osdMode=False):
        return super(OSD, cls).__new__(cls, XML, PATH)

    def __init__(self, channel='', epgMode=False, osdMode=False):
        super(OSD, self).__init__()

        self.channel = channel
        self.closeTimer = None
        self.list = None
        self.showInfo = False
        self.epgMode = epgMode
        self.osdMode = osdMode
        self.infoService = InfoService()
        self.now = None
        self.next = None
        self.other = None

        self.streamingService = streaming.StreamsService()

    def close(self):
        if self.closeTimer != None:
            self.closeTimer.cancel()

        channel = self.getChannel(self.channel)
        if channel:
            xbmcgui.Window(10000).setProperty('OTT_CHANNEL', channel.id)

        xbmcgui.WindowXMLDialog.close(self)

    def resetCloseTimer(self):
        return
        if self.closeTimer != None:
            self.closeTimer.cancel()

        interval = 10

        self.closeTimer = Timer(interval, self.onCloseTimer)
        self.closeTimer.start()

    def onCloseTimer(self):
        if self.closeTimer == None:
            return

        if self.showInfo or self.osdMode:
            self.resetCloseTimer()
            return

        if (not self.epgMode) and (not self.osdMode):
            self.playChannel(self.channel)

        self.close()

    def toggleInfo(self):
        self.showInfo = not self.showInfo

        if self.epgMode:
            try:
                self.getControl(EPG_METADATA).setVisible(self.showInfo)
            except:
                pass

        x = self.osdX
        y = self.osdY  # -100 if self.showInfo else self.osdY

        try:
            self.getControl(OSD_MINIGUIDE).setPosition(x, y)
        except:
            pass

        try:
            self.getControl(OSD_MINIGUIDE).setVisible(self.showInfo)
        except:
            pass

    def setChannel(self, text):
        dixie.log('Setting changer channel to %s' % text)

        channel = self.getChannel(text)

        if not channel:
            xbmcgui.Window(10000).setProperty('OTT_CH_LOGO', '')
            xbmcgui.Window(10000).setProperty('OTT_CH_TITLE', '')
            xbmcgui.Window(10000).setProperty('OTT_CH_NUMBER', '')
            self.channel = ''
        else:
            if channel.title.endswith(')') and channel.title[-4] == '(':
                test_title = channel.title[:-5].replace('_', ' ').replace(
                    ' PLUS1', ' +1').replace(' STAR', '*').replace(
                        'PLUS1', '+1').replace('&AMP;',
                                               '&').replace('&GT;', ' ')
            else:
                test_title = channel.title.replace('_', ' ').replace(
                    ' PLUS1', ' +1').replace(' STAR', '*').replace(
                        'PLUS1', '+1').replace('&AMP;',
                                               '&').replace('&GT;', ' ')
            if not 'default.png' in channel.logo:
                test_logo = channel.logo
            else:
                test_logo = os.path.join(logofolder,
                                         test_title.replace(' ', '_') + '.png')
            xbmcgui.Window(10000).setProperty('OTT_CH_LOGO', test_logo)
            xbmcgui.Window(10000).setProperty('OTT_CH_TITLE', test_title)
            xbmcgui.Window(10000).setProperty('OTT_CH_NUMBER', text)

        self.updateProgramInfo(channel)

    def previousProgram(self):
        if not self.other:
            self.other = self.infoService.getPreviousProgram(self.now)
        else:
            self.other = self.infoService.getPreviousProgram(self.other)

        self.updateLabels()

    def nextProgram(self):
        if not self.other:
            self.other = self.infoService.getNextProgram(self.next)
        else:
            self.other = self.infoService.getNextProgram(self.other)

        self.updateLabels()

    def updateProgramInfo(self, channel):
        import info

        if self.epgMode:
            return

        self.now = None
        self.next = None
        self.other = None

        self.now = self.infoService.getCurrentProgram(channel)
        self.next = self.infoService.getNextProgram(self.now)

        self.updateLabels()

    def updateLabels(self):
        if self.other and (self.other.startDate < self.now.startDate):
            self.other = None

        if self.other and (self.other.startDate == self.next.startDate):
            self.other = None

        if self.other and (self.other.startDate == self.now.startDate):
            self.other = None

        if self.now:
            xbmcgui.Window(10000).setProperty('OTT_NOW_TITLE', self.now.title)
            xbmcgui.Window(10000).setProperty(
                'OTT_NOW_TIME', self.now.startDate.strftime('%H:%M'))
            xbmcgui.Window(10000).setProperty('OTT_PROG_DESC',
                                              self.now.description)

        if self.other:
            label = 'EARLIER' if (
                self.other.startDate < self.now.startDate) else 'LATER'
            xbmcgui.Window(10000).setProperty('OTT_NEXT_TEXT', label)
            xbmcgui.Window(10000).setProperty('OTT_NEXT_TITLE',
                                              self.other.title)
            xbmcgui.Window(10000).setProperty(
                'OTT_NEXT_TIME', self.other.startDate.strftime('%H:%M'))

        elif self.next:
            xbmcgui.Window(10000).setProperty('OTT_NEXT_TEXT', 'NEXT')
            xbmcgui.Window(10000).setProperty('OTT_NEXT_TITLE',
                                              self.next.title)
            xbmcgui.Window(10000).setProperty(
                'OTT_NEXT_TIME', self.next.startDate.strftime('%H:%M'))

        if not self.now:
            xbmcgui.Window(10000).setProperty('OTT_NOW_TITLE', '')
            xbmcgui.Window(10000).setProperty('OTT_NOW_TIME', '')
            xbmcgui.Window(10000).setProperty('OTT_PROG_DESC', '')

        if (not self.next) and (not self.other):
            xbmcgui.Window(10000).setProperty('OTT_NEXT_TEXT', '')
            xbmcgui.Window(10000).setProperty('OTT_NEXT_TITLE', '')
            xbmcgui.Window(10000).setProperty('OTT_NEXT_TIME', '')

    def playChannel(self, _channel):
        channel = self.getChannel(_channel)
        current = xbmcgui.Window(10000).getProperty('OTT_CHANNEL')

        if not channel:
            return

        if channel.id == current:
            if not self.osdMode:
                return

        streamUrl = channel.streamUrl

        if not streamUrl:
            streamUrl = self.detectStream(channel)

        if not streamUrl:
            return

        #xbmcgui.Window(10000).setProperty('OTT_CHANNEL', channel.id)

        prev = xbmcgui.Window(10000).getProperty('OTT_CURR_INDEX')

        xbmcgui.Window(10000).setProperty('OTT_PREV_INDEX', prev)
        xbmcgui.Window(10000).setProperty('OTT_CURR_INDEX', _channel)

        path = os.path.join(dixie.HOME, 'player.py')
        xbmc.executebuiltin('XBMC.RunScript(%s,%s,%d,%s)' %
                            (path, streamUrl, False, 'OSD'))

    def detectStream(self, channel):
        result = self.streamingService.detectStream(channel)

        if type(result) == str:
            self.setCustomStreamUrl(channel, result)
            return result

        if len(result) < 1:
            dixie.DialogOK('Sorry, we could not detect a stream.', '',
                           'Please allocate a stream for this channel.')
            return None

        import detect

        d = detect.StreamAddonDialog(result)
        d.doModal()

        if not d.stream:
            return None

        if not IGNORESTRM:
            self.setCustomStreamUrl(channel, d.stream)

        return d.stream

    def playPrevious(self):
        prevChan = xbmcgui.Window(10000).getProperty('OTT_PREV_INDEX')

        if len(prevChan) == 0:
            return False

        self.setChannel(prevChan)
        self.playChannel(prevChan)
        return True

    def getChannel(self, channel):
        try:
            index = int(channel) - 1
            if index < 0:
                return None

            return self.list[index]
        except:
            return None

    def onInit(self):
        try:
            self.getControl(MAIN).setVisible(False)
        except:
            pass

        try:
            self.getControl(EPG_CHANNEL).setVisible(self.epgMode)
        except:
            pass

        try:
            self.getControl(OSD_METADATA).setVisible(not self.epgMode)
        except:
            pass

        try:
            self.getControl(EPG_METADATA).setVisible(False)
        except:
            pass

        try:
            self.getControl(OSD_MINIGUIDE).setVisible(not self.epgMode)
        except:
            pass

        # try:    self.getControl(OSD_MINIGUIDE).setVisible(self.showInfo)
        # except: pass

        try:
            self.getControl(OSD_TITLEBAR).setVisible(not self.epgMode)
        except:
            pass

        try:
            self.osdX = self.getControl(OSD_MINIGUIDE).getPosition()[0]
            self.osdY = self.getControl(OSD_MINIGUIDE).getPosition()[1]
        except:
            pass

        try:
            self.populateChannels()

            if self.channel == 'PREV':
                self.channel = ''
                if self.playPrevious():
                    self.close()
                    return

            if len(self.channel) < 0:
                self.channel = 1

            self.setChannel(self.channel)
            self.resetCloseTimer()

        except Exception:
            raise

        try:
            self.getControl(MAIN).setPosition(0, 0)
            self.getControl(MAIN).setVisible(True)
        except:
            pass

    def onAction(self, action):
        try:
            actionId = action.getId()
            buttonId = action.getButtonCode()

            if actionId != 107:
                dixie.log(str(actionId))
                dixie.log(str(buttonId))

            self.resetCloseTimer()

            if actionId == KEY_ESC_ID and buttonId == KEY_ESC_CODE:
                self.close()
                return

            if actionId == ACTION_BACK:
                if self.channel == '':
                    self.close()
                    return

                self.channel = self.channel[:-1]
                self.setChannel(self.channel)

            if actionId in [ACTION_UP, ACTION_PAGE_UP]:
                self.ChannelUp()

            if actionId in [ACTION_DOWN, ACTION_PAGE_DOWN]:
                self.ChannelDown()

            if actionId == ACTION_LEFT:
                self.previousProgram()
                return

            if actionId == ACTION_RIGHT:
                self.nextProgram()
                return

            if actionId == ACTION_X or actionId == ACTION_STOP:
                self.close()
                return

            if actionId == ACTION_SELECT:
                if not self.epgMode:
                    self.playChannel(self.channel)
                self.close()
                return

            if actionId == ACTION_PLAY:
                self.playChannel(self.channel)
                return

            if actionId >= ACTION_0 and actionId <= ACTION_9:
                self.channel = str(
                    self.verifyChannel(self.channel, actionId - ACTION_0))
                self.setChannel(self.channel)

            if actionId == ACTION_SHOW_INFO:
                self.toggleInfo()

        except Exception:
            raise

    def verifyChannel(self, oldChannel, newNumber):
        try:
            oldNumber = int(oldChannel)
        except:
            return newNumber

        newChannel = (oldNumber * 10) + newNumber

        if newChannel <= len(self.list):
            return newChannel

        if newNumber <= len(self.list):
            return newNumber

        return oldChannel

    def ChannelUp(self):
        if self.channel == '':
            self.channel = '1'

        ch = int(self.channel) + 1

        if ch > len(self.list):
            ch = 1

        self.channel = str(ch)
        self.setChannel(self.channel)

    def ChannelDown(self):
        if self.channel == '':
            self.channel = str(len(self.list))

        ch = int(self.channel) - 1

        if ch == 0:
            ch = len(self.list)

        self.channel = str(ch)
        self.setChannel(self.channel)

    def getChannelFromFile(self, id):
        path = os.path.join(OTT_CHANNELS, id)

        if not sfile.exists(path):
            return None

        cfg = sfile.readlines(path)

        return Channel(cfg)

    def populateChannels(self, alphaSort=False):
        channels = []
        channelarray = []
        SFchannelarray = []
        try:
            current, dirs, files = sfile.walk(OTT_CHANNELS)

        except Exception, e:
            dixie.log('### Failed to scan master channel list: %s' % str(e))
            return channelarray

        for file in files:
            if show_social == 'false' and file == '-_ADD_OR_REMOVE_CHANNELS':
                pass

            else:
                channelarray.append(file)

# Allows user to only show channels they have SF folders setup for
        if showSFchannels == 'true':
            try:
                current, dirs, files = sfile.walk(SF_CHANNELS)
            except Exception, e:
                return SFchannelarray
                dixie.log('### Failed to scan SF channel list: %s' % str(e))

            for dir in dirs:
                if os.listdir(os.path.join(SF_CHANNELS, dir)):
                    SFchannelarray.append(dir)

            nk = set(channelarray).intersection(SFchannelarray)
            for x in channelarray:
                if x in nk:
                    channels.append(x)
Пример #47
0
def GetAddons():
    return sfile.walk(XBMCHOME)
Пример #48
0
def GetAddons():
    return sfile.walk(XBMCHOME)
Пример #49
0
    except Exception, e:
        log('Error in getAllChannels - Master List: %s' % str(e))
        return channels

    for file in files:
        try:
            channels.append(file)
        except:
            log("failed to add to array: "+file)

    if showSFchannels == 'false':
        return channels

    elif showSFchannels == 'true':
        try:
            current, dirs, files = sfile.walk(SF_CHANNELS)
        except Exception, e:
            log('Error in getAllChannels - SF List: %s' % str(e))
            return SFchannelarray

# Grab a list of SF folders not in the channels folder and add as dummy channels
        for dir in dirs:
            try:
                if os.path.exists(os.path.join(SF_CHANNELS,dir,'favourites.xml')):
                    SFchannelarray.append(dir)
                    if not dir in channels:
                        channelarray.append(dir)
            except:
                log("Special characters in directory, skipping: "+dir)

        if debug == 'true':
Пример #50
0
    except Exception, e:
        log('Error in getAllChannels - Master List: %s' % str(e))
        return channels

    for file in files:
        try:
            channels.append(file)
        except:
            log("failed to add to array: " + file)

    if showSFchannels == 'false':
        return channels

    elif showSFchannels == 'true':
        try:
            current, dirs, files = sfile.walk(SF_CHANNELS)
        except Exception, e:
            log('Error in getAllChannels - SF List: %s' % str(e))
            return SFchannelarray

        # Grab a list of SF folders not in the channels folder and add as dummy channels
        for dir in dirs:
            try:
                if os.path.exists(
                        os.path.join(SF_CHANNELS, dir, 'favourites.xml')):
                    SFchannelarray.append(dir)
                    if not dir in channels:
                        channelarray.append(dir)
            except:
                log("Special characters in directory, skipping: " + dir)
    def getFaves(self):
        file = os.path.join(self.FULLPATH, FILENAME).decode('utf-8')
        faves = []

        index = 0

        label_numeric = LABEL_NUMERIC
        if self.MODE == 'folder':
            folderCfg = os.path.join(self.FULLPATH, FOLDERCFG)
            numeric = parameters.getParam('NUMERICAL', folderCfg)
            if numeric:
                label_numeric = numeric.lower() == 'true'

        if label_numeric:
            label_numeric = LABEL_NUMERIC_QL

        if self.MODE != 'xbmc':
            try:
                current, dirs, files = sfile.walk(self.FULLPATH)

                dirs = sorted(dirs, key=str.lower)

                for dir in dirs:
                    path = os.path.join(self.FULLPATH, dir)

                    folderCfg = os.path.join(path, FOLDERCFG)
                    folderCfg = parameters.getParams(folderCfg)
                    lock = parameters.getParam('LOCK', folderCfg)
                    if lock:
                        continue
                    colour = parameters.getParam('COLOUR', folderCfg)
                    thumb = getFolderThumb(path)

                    label = dir

                    if colour and colour.lower() <> 'none':
                        label = '[COLOR %s]%s[/COLOR]' % (colour, label)

                    label, index = utils.addPrefixToLabel(
                        index, label, label_numeric)

                    fave = [label, thumb, os.path.join(self.PATH, dir), True]
                    faves.append(fave)

            except Exception as e:
                pass

        items = favourite.getFavourites(file, chooser=True)

        sortorder = 0

        if self.MODE == 'folder':
            folderCfg = os.path.join(self.FULLPATH, FOLDERCFG)

            try:
                sortorder = int(parameters.getParam('SORT', folderCfg))
            except:
                sortorder = 0

        if sortorder == 0:
            sortorder = 1 if ALPHA_SORT else 2

        if sortorder == 1:  #ALPHA_SORT:
            items = sorted(items, key=lambda x: utils.CleanForSort(x))

        if not label_numeric:
            faves.extend(items)
        else:
            for fave in items:
                label = fave[0]
                thumb = fave[1]
                cmd = fave[2]

                label, index = utils.addPrefixToLabel(index, label,
                                                      label_numeric)

                faves.append([label, thumb, cmd])

        return faves
Пример #52
0
            except Exception, e:
                dixie.log('Error in getAllChannels - SF List: %s' % str(e))
                return channels

    # Grab a list of SF folders not in the channels folder and add as dummy channels
            for dir in dirs:
                try:
                    if os.path.exists(os.path.join(SF_CHANNELS,dir,'favourites.xml')):
                        channels.append(dir)

                except:
                    dixie.log("Special characters in directory, skipping: "+dir)

        else:
            try:
                current, dirs, files = sfile.walk(channelPath)
            except Exception, e:
                dixie.log('Error in getAllChannels - Master List: %s' % str(e))
                return channels

            for file in files:
                try:
                    channels.append(file)
                except:
                    dixie.log("failed to add to array: "+file)

        return channels

    def removeCleanChannel(self, id):
        try:    del self.channelDict[id]
        except: pass