Example #1
0
def addToXBMC(name, thumb, cmd):    
    cmd = '"%s"' % cmd   

    folder   = '&mode=%d' % _FOLDER
    search   = '&mode=%d' % _SUPERSEARCH
    edit     = '&mode=%d' % _EDITTERM
    #activate = '&mode=%d' % _ACTIVATEWINDOW   

    #if (folder in cmd) or (search in cmd) or (edit in cmd) or (activate in cmd):
    if (folder in cmd) or (search in cmd) or (edit in cmd):
        cmd = cmd.replace('+', '%20')
        cmd = 'ActivateWindow(%d,%s)' % (getCurrentWindowId(), cmd)
    else:
        cmd = 'PlayMedia(%s)' % cmd

    if (search in cmd) and ('keyword' not in cmd):
        replace = '%s&keyword=%s' % (search, ISEARCH_EMPTY)
        cmd = cmd.replace(search, replace)
        if not cmd.lower().endswith(',return)'):
            cmd = cmd[:-1] + ',return)'
   
    fave = [name, thumb, cmd]

    file = os.path.join(xbmc.translatePath('special://profile'), FILENAME)

    #if it is already in there don't add again
    if favourite.findFave(file, cmd)[0]:
        return False

    faves = favourite.getFavourites(file)
    faves.append(fave)

    favourite.writeFavourites(file, faves)

    return True
Example #2
0
def pasteFolderLink(src, dst, folderName, addonid):
    import urllib
    thumbnail, fanart = utils.getFolderThumb(src)

    folderConfig = os.path.join(src, FOLDERCFG)
    colour       = parameters.getParam('COLOUR', folderConfig)

    if colour:
        folderName = '[COLOR %s]%s[/COLOR]' % (colour, folderName)

    path = utils.convertToHome(src)
    path = path.replace(PROFILE, '')
    path = path.replace('\\', '/')
    if path.startswith('/'):
        path = path[1:]

    cmd = '%s?label=%s&mode=%d&folder=%s' % (addonid, folderName, utils._FOLDER, urllib.quote_plus(path))
    cmd = '"%s"' % cmd  
    cmd = cmd.replace('+', '%20')
    cmd = 'ActivateWindow(%d,%s)' % (utils.getCurrentWindowId(), cmd) 
    cmd = favourite.addFanart(cmd, fanart)

    file = os.path.join(dst, FILENAME)

    if favourite.findFave(file, cmd)[0]:
        return True

    faves = favourite.getFavourites(file, validate=False)
    fave  = [folderName, thumbnail, cmd]

    faves.append(fave)

    favourite.writeFavourites(file, faves)

    return True
Example #3
0
def addToXBMC(name, thumb, cmd):
    cmd = '"%s"' % cmd

    folder = '&mode=%d' % _FOLDER
    search = '&mode=%d' % _SUPERSEARCH
    edit   = '&mode=%d' % _EDITSEARCH

    if (folder in cmd) or (search in cmd) or (edit in cmd):
        cmd = cmd.replace('+', '%20')
        cmd = 'ActivateWindow(%d,%s)' % (xbmcgui.getCurrentWindowId(), cmd)
    else:
        cmd = 'PlayMedia(%s)' % cmd

    fave = [name, thumb, cmd]

    file = os.path.join(xbmc.translatePath('special://profile'), FILENAME)

    #if it is already in there don't add again
    if findFave(file, cmd)[0]:
        return False

    faves = favourite.getFavourites(file)
    faves.append(fave)

    favourite.writeFavourites(file, faves)

    return True
Example #4
0
def removeFave(file, cmd):
    copy = []
    faves = favourite.getFavourites(file)
    for fave in faves:
        if fave[2] != cmd:
            copy.append(fave)

    if len(copy) == len(faves):
        return False

    favourite.writeFavourites(file, copy)

    return True
Example #5
0
def renameFave(file, cmd):
    copy = []
    faves = favourite.getFavourites(file)
    for fave in faves:
        if fave[2] == cmd:
            text = getText(GETTEXT(30021), text=fave[0])
            if not text:
                return
            fave[0] = text
        copy.append(fave)

    favourite.writeFavourites(file, copy)

    return True
Example #6
0
def insertFave(file, newFave, index):
    copy = []
    faves = favourite.getFavourites(file)
    for fave in faves:
        if len(copy) == index:
            copy.append(newFave)
        copy.append(fave)

    if index >= len(copy):
        copy.append(newFave)

    favourite.writeFavourites(file, copy)

    return True
Example #7
0
def changePlaybackMode(file, cmd):
    copy = []
    faves = favourite.getFavourites(file)
    for fave in faves:
        if favourite.equals(fave[2], cmd):
            if cmd.startswith('PlayMedia'):
                try:    winID = re.compile('sf_win_id=(.+?)_').search(cmd).group(1)
                except: winID = '10025'
                cmd = cmd.replace('PlayMedia(', 'ActivateWindow(%s,' % winID)
            elif cmd.startswith('ActivateWindow'):
                cmd = 'PlayMedia(' + cmd.split(',', 1)[-1]
            fave[2] = cmd
        copy.append(fave)

    favourite.writeFavourites(file, copy)
    return True
Example #8
0
def addToXBMC(name, thumb, cmd):
    p = get_params(cmd.replace('?', '&'))
    try:
        mode = int(p['mode'])
        if mode == _FOLDER:
            label = urllib.unquote_plus(p['label'])
            path = urllib.unquote_plus(p['path'])
            path = favourite.convertToHome(path)
            cmd = '%s?label=%s&mode=%d&path=%s' % (sys.argv[0], label, _FOLDER,
                                                   urllib.quote_plus(path))
    except:
        pass

    cmd = '"%s"' % cmd

    folder = '&mode=%d' % _FOLDER
    search = '&mode=%d' % _SUPERSEARCH
    edit = '&mode=%d' % _EDITTERM

    if (folder in cmd) or (search in cmd) or (edit in cmd):
        cmd = cmd.replace('+', '%20')
        cmd = 'ActivateWindow(%d,%s,return)' % (getCurrentWindowId(), cmd)
    else:
        cmd = 'PlayMedia(%s)' % cmd

    if (search in cmd) and ('keyword' not in cmd):
        replace = '%s&keyword=%s' % (search, ISEARCH_EMPTY)
        cmd = cmd.replace(search, replace)
        if not cmd.lower().endswith(',return)'):
            cmd = cmd[:-1] + ',return)'

    fave = [name, thumb, cmd]

    file = os.path.join(xbmc.translatePath('special://profile'), FILENAME)

    #if it is already in there don't add again
    if favourite.findFave(file, cmd)[0]:
        return False

    faves = favourite.getFavourites(file, validate=False)

    faves.append(fave)

    favourite.writeFavourites(file, faves)

    return True
Example #9
0
def addToXBMC(name, thumb, cmd):
    p = get_params(cmd.replace('?', '&'))
    try: 
        mode = int(p['mode'])
        if mode == _FOLDER:
            label = urllib.unquote_plus(p['label'])
            path  = urllib.unquote_plus(p['path'])
            path  = favourite.convertToHome(path)
            cmd   = '%s?label=%s&mode=%d&path=%s' % (sys.argv[0], label, _FOLDER, urllib.quote_plus(path))
    except:
        pass

    cmd = '"%s"' % cmd   
    
    folder   = '&mode=%d' % _FOLDER
    search   = '&mode=%d' % _SUPERSEARCH
    edit     = '&mode=%d' % _EDITTERM

    if (folder in cmd) or (search in cmd) or (edit in cmd):
        cmd = cmd.replace('+', '%20')
        cmd = 'ActivateWindow(%d,%s,return)' % (getCurrentWindowId(), cmd)
    else:
        cmd = 'PlayMedia(%s)' % cmd

    if (search in cmd) and ('keyword' not in cmd):
        replace = '%s&keyword=%s' % (search, ISEARCH_EMPTY)
        cmd = cmd.replace(search, replace)
        if not cmd.lower().endswith(',return)'):
            cmd = cmd[:-1] + ',return)'
   
    fave = [name, thumb, cmd]

    file = os.path.join(xbmc.translatePath('special://profile'), FILENAME)

    #if it is already in there don't add again
    if favourite.findFave(file, cmd)[0]:
        return False    

    faves = favourite.getFavourites(file, validate=False)

    faves.append(fave)

    favourite.writeFavourites(file, faves)

    return True
Example #10
0
def changePlaybackMode(file, cmd):
    copy = []
    faves = favourite.getFavourites(file)
    for fave in faves:
        if favourite.equals(fave[2], cmd):
            if cmd.startswith('PlayMedia'):
                try:
                    winID = re.compile('sf_win_id=(.+?)_').search(cmd).group(1)
                except:
                    winID = '10025'
                cmd = cmd.replace('PlayMedia(', 'ActivateWindow(%s,' % winID)
            elif cmd.startswith('ActivateWindow'):
                cmd = 'PlayMedia(' + cmd.split(',', 1)[-1]
            fave[2] = cmd
        copy.append(fave)

    favourite.writeFavourites(file, copy)
    return True
Example #11
0
def colourFave(file, cmd):
    colour = getColour()

    if not colour:
        return False

    copy = []
    faves = favourite.getFavourites(file)
    for fave in faves:
        if favourite.equals(fave[2], cmd):
            fave[0]   = decolourize(fave[0])
            if colour != 'SF_RESET': 
                fave[0] = '[COLOR %s]%s[/COLOR]' % (colour, fave[0])

        copy.append(fave)

    favourite.writeFavourites(file, copy)

    return True
Example #12
0
def colourFave(file, cmd):
    colour = getColour()

    if not colour:
        return False

    copy = []
    faves = favourite.getFavourites(file)
    for fave in faves:
        if favourite.equals(fave[2], cmd):
            fave[0] = decolourize(fave[0])
            if colour != 'SF_RESET':
                fave[0] = '[COLOR %s]%s[/COLOR]' % (colour, fave[0])

        copy.append(fave)

    favourite.writeFavourites(file, copy)

    return True
Example #13
0
def addToXBMC(name, thumb, cmd):
    cmd = cmd.replace('&', '&')
    cmd = cmd.replace('+', '%20')
    cmd = '"%s"' % cmd

    cmd = 'ActivateWindow(10001,%s)' % cmd

    fave = [name, thumb, cmd]

    file = os.path.join(xbmc.translatePath('special://profile'), FILENAME)

    #if it is already in there don't add again
    if findFave(file, cmd):
        return False

    faves = favourite.getFavourites(file)
    faves.append(fave)

    favourite.writeFavourites(file, faves)

    return True
Example #14
0
def copyFave(file, cmd, move=False):
    copy, index, nFaves = findFave(file, cmd)
    if not copy:
        return

    text = GETTEXT(30020) if move else GETTEXT(30019)

    folder = getFolder(text)
    if not folder:
        return False
  
    file  = os.path.join(folder, FILENAME)
    faves = favourite.getFavourites(file)

    #if it is already in there don't add again
    for fave in faves:
        if fave[2] == cmd:
            return False

    faves.append(copy)
    favourite.writeFavourites(file, faves)

    return True
Example #15
0
def copyFave(name, thumb, cmd):
    import favourite
    import utils

    text = utils.GETTEXT(30019)

    folder = utils.GetFolder(text)
    if not folder:
        return False
  
    file  = os.path.join(folder, utils.FILENAME)
    faves = favourite.getFavourites(file)

    #if it is already in there don't add again
    for fave in faves:
        if fave[2] == cmd:            
            return False

    fave = [name, thumb, cmd] 
  
    faves.append(fave)
    favourite.writeFavourites(file, faves)

    return True