Beispiel #1
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
Beispiel #2
0
def writeFavourites(file, faves):
    kodiFile = os.path.join('special://profile', utils.FILENAME)
    isKodi = xbmc.translatePath(file) == xbmc.translatePath(kodiFile)

    f = sfile.file(file, 'w')

    f.write('<favourites>')

    for fave in faves:
        try:
            name = utils.escape(fave[0])
            thumb = utils.escape(fave[1])
            cmd = utils.escape(fave[2])

            cmd = removeHome(cmd)

            if isKodi and cmd.lower().startswith('playmedia'):
                cmd = removeSFOptions(cmd)

            thumb = utils.convertToHome(thumb)

            name = 'name="%s" ' % name
            thumb = 'thumb="%s">' % thumb
            f.write('\n\t<favourite ')
            f.write(name)
            f.write(thumb)
            f.write(cmd)
            f.write('</favourite>')
        except:
            pass

    f.write('\n</favourites>')
    f.close()

    import xbmcgui
    try:
        count = int(
            xbmcgui.Window(10000).getProperty('Super_Favourites_Count'))
    except:
        count = 0
    xbmcgui.Window(10000).setProperty('Super_Favourites_Count', str(count + 1))
Beispiel #3
0
def writeFavourites(file, faves):
    kodiFile = os.path.join("special://profile", utils.FILENAME)
    isKodi = xbmc.translatePath(file) == xbmc.translatePath(kodiFile)

    f = sfile.file(file, "w")

    f.write("<favourites>")

    for fave in faves:
        try:
            name = utils.escape(fave[0])
            thumb = utils.escape(fave[1])
            cmd = utils.escape(fave[2])

            if isKodi and cmd.lower().startswith("playmedia"):
                cmd = removeSFOptions(cmd)

            thumb = utils.convertToHome(thumb)

            name = 'name="%s" ' % name
            thumb = 'thumb="%s">' % thumb
            f.write("\n\t<favourite ")
            f.write(name)
            f.write(thumb)
            f.write(cmd)
            f.write("</favourite>")
        except:
            pass

    f.write("\n</favourites>")
    f.close()

    import xbmcgui

    try:
        count = int(xbmcgui.Window(10000).getProperty("Super_Favourites_Count"))
    except:
        count = 0
    xbmcgui.Window(10000).setProperty("Super_Favourites_Count", str(count + 1))
Beispiel #4
0
def addFanart(cmd, fanart):
    if len(fanart) < 1:
        return cmd

    return updateSFOption(cmd, "fanart", utils.convertToHome(fanart))
Beispiel #5
0
def addFanart(cmd, fanart):
    if len(fanart) < 1:
        return cmd

    return updateSFOption(cmd, 'fanart', utils.convertToHome(fanart))