示例#1
0
def editSearch(file, cmd, name, thumb):
    fanart = favourite.getFanart(cmd)
    hasThumb = len(thumb) > 0
    hasFanart = len(fanart) > 0

    UP = 0
    DOWN = 1
    RENAME = 2
    CHOOSETHUMB = 3
    CHOOSEFANART = 4
    REMOVETHUMB = 5
    REMOVEFANART = 6
    COLOUR = 7

    options = []
    options.append([GETTEXT(30041), UP])
    options.append([GETTEXT(30042), DOWN])
    options.append([GETTEXT(30010), RENAME])
    options.append([GETTEXT(30043), CHOOSETHUMB])
    options.append([GETTEXT(30107), CHOOSEFANART])

    if hasThumb:
        options.append([GETTEXT(30097), REMOVETHUMB])

    if hasFanart:
        options.append([GETTEXT(30108), REMOVEFANART])

    options.append([GETTEXT(30085), COLOUR])

    import menus
    option = menus.selectMenu(name, options)

    if option == UP:
        return favourite.shiftFave(file, cmd, up=True)

    if option == DOWN:
        return favourite.shiftFave(file, cmd, up=False)

    if option == RENAME:
        return renameFave(file, cmd)

    if option == CHOOSETHUMB:
        return thumbFave(file, cmd)

    if option == CHOOSEFANART:
        return fanartFave(file, cmd)

    if option == REMOVETHUMB:
        return removeThumbFave(file, cmd)

    if option == REMOVEFANART:
        return removeFanartFave(file, cmd)

    if option == COLOUR:
        return colourFave(file, cmd)

    return False
示例#2
0
def editSearch(file, cmd, name, thumb):
    fanart    = favourite.getFanart(cmd)
    hasThumb  = len(thumb) > 0
    hasFanart = len(fanart) > 0

    UP           = 0
    DOWN         = 1
    RENAME       = 2
    CHOOSETHUMB  = 3
    CHOOSEFANART = 4
    REMOVETHUMB  = 5
    REMOVEFANART = 6
    COLOUR       = 7

    options = []
    options.append([GETTEXT(30041), UP])
    options.append([GETTEXT(30042), DOWN])
    options.append([GETTEXT(30010), RENAME])
    options.append([GETTEXT(30043), CHOOSETHUMB])
    options.append([GETTEXT(30107), CHOOSEFANART])

    if hasThumb:
        options.append([GETTEXT(30097), REMOVETHUMB])

    if hasFanart:
        options.append([GETTEXT(30108), REMOVEFANART])

    options.append([GETTEXT(30085), COLOUR])

    import menus
    option = menus.selectMenu(name, options)

    if option == UP:
        return favourite.shiftFave(file, cmd, up=True)

    if option == DOWN:
        return favourite.shiftFave(file, cmd, up=False)

    if option == RENAME:
        return renameFave(file, cmd)

    if option == CHOOSETHUMB:
        return thumbFave(file, cmd)

    if option == CHOOSEFANART:
        return fanartFave(file, cmd)

    if option == REMOVETHUMB:
        return removeThumbFave(file, cmd)

    if option == REMOVEFANART:
        return removeFanartFave(file, cmd)

    if option == COLOUR:
        return colourFave(file, cmd)

    return False
示例#3
0
def editFolder(path, name):
    cfg       = os.path.join(path, FOLDERCFG)
    thumb     = getParam('ICON',   cfg)
    fanart    = getParam('FANART', cfg)
    hasThumb  = thumb  and len(thumb)  > 0
    hasFanart = fanart and len(fanart) > 0

    REMOVE       = 0
    RENAME       = 1
    CHOOSETHUMB  = 2
    CHOOSEFANART = 3
    REMOVETHUMB  = 4
    REMOVEFANART = 5
    COLOUR       = 6

    options = []
    options.append([GETTEXT(30011), REMOVE])
    options.append([GETTEXT(30012), RENAME])
    options.append([GETTEXT(30043), CHOOSETHUMB])
    options.append([GETTEXT(30107), CHOOSEFANART])

    if hasThumb:
        options.append([GETTEXT(30097), REMOVETHUMB])

    if hasFanart:
        options.append([GETTEXT(30108), REMOVEFANART])

    options.append([GETTEXT(30085), COLOUR])

    import menus
    option = menus.selectMenu(name, options)

    if option == REMOVE:
        return removeFolder(path)

    if option == RENAME:
        return renameFolder(path)

    if option == CHOOSETHUMB:
        return thumbFolder(path)

    if option == CHOOSEFANART:
        return fanartFolder(path)

    if option == REMOVETHUMB:
        return removeThumbFolder(path)

    if option == REMOVEFANART:
        return removeFanartFolder(path)

    if option == COLOUR:
        return colourFolder(path)

    return False
示例#4
0
def editFolder(path, name):
    cfg = os.path.join(path, FOLDERCFG)
    thumb = getParam('ICON', cfg)
    fanart = getParam('FANART', cfg)
    hasThumb = thumb and len(thumb) > 0
    hasFanart = fanart and len(fanart) > 0

    REMOVE = 0
    RENAME = 1
    CHOOSETHUMB = 2
    CHOOSEFANART = 3
    REMOVETHUMB = 4
    REMOVEFANART = 5
    COLOUR = 6

    options = []
    options.append([GETTEXT(30011), REMOVE])
    options.append([GETTEXT(30012), RENAME])
    options.append([GETTEXT(30043), CHOOSETHUMB])
    options.append([GETTEXT(30107), CHOOSEFANART])

    if hasThumb:
        options.append([GETTEXT(30097), REMOVETHUMB])

    if hasFanart:
        options.append([GETTEXT(30108), REMOVEFANART])

    options.append([GETTEXT(30085), COLOUR])

    import menus
    option = menus.selectMenu(name, options)

    if option == REMOVE:
        return removeFolder(path)

    if option == RENAME:
        return renameFolder(path)

    if option == CHOOSETHUMB:
        return thumbFolder(path)

    if option == CHOOSEFANART:
        return fanartFolder(path)

    if option == REMOVETHUMB:
        return removeThumbFolder(path)

    if option == REMOVEFANART:
        return removeFanartFolder(path)

    if option == COLOUR:
        return colourFolder(path)

    return False
示例#5
0
def getColour():
    filename = os.path.join(HOME, 'resources', 'colours', 'Color.xml')

    if not os.path.exists(filename):
        return None

    menu = [[GETTEXT(30087), 'SF_RESET']]

    f = open(filename, 'r')
    for line in f:
        if 'name' in line:
            name = line.split('"')[1]            
            menu.append(['[COLOR %s]%s[/COLOR]' % (name, name), name])

    if len(menu) < 2:
        return None

    import menus
    option = menus.selectMenu(GETTEXT(30086), menu)
                 
    if option < 0:
        return None

    return option
示例#6
0
def getColour():
    filename = os.path.join(HOME, 'resources', 'colours', 'Color.xml')

    if not os.path.exists(filename):
        return None

    menu = [[GETTEXT(30087), 'SF_RESET']]

    f = open(filename, 'r')
    for line in f:
        if 'name' in line:
            name = line.split('"')[1]
            menu.append(['[COLOR %s]%s[/COLOR]' % (name, name), name])

    if len(menu) < 2:
        return None

    import menus
    option = menus.selectMenu(GETTEXT(30086), menu)

    if option < 0:
        return None

    return option
def doMenu(mode):
    import menuUtils

    utils.log('**** Context Menu Information ****')

    window = xbmcgui.getCurrentWindowId()

    DEBUG = ADDON.getSetting('DEBUG') == 'true'
    if DEBUG:
        utils.DialogOK('Current Window ID %d' % window)

    utils.log('Capture window\t: %d' % window)

    if window > 12999:
        doStandard(useScript=False)
        return

    # to prevent master profile setting being used in other profiles
    if mode == 0 and ADDON.getSetting('CONTEXT') != 'true':
        doStandard(useScript=False)
        return

    folder = xbmc.getInfoLabel('Container.FolderPath')
    path = xbmc.getInfoLabel('ListItem.FolderPath')

    #ignore if in Super Favourites
    if (ADDONID in folder) or (ADDONID in path):
        doStandard(useScript=False)
        return

    if mode == 0 and whitelisted():
        doStandard(useScript=False)
        return

    try:
        params = menuUtils.getCurrentParams()
    except:
        params = None

    if params == None:
        doStandard(useScript=False)
        return

    try:
        meta = menuUtils.getCurrentMeta()
    except:
        meta = {}

    utils.outputDict(params, 'Capture Parameters')
    utils.outputDict(meta, 'Capture Metadata')

    folder = params['folder']
    path = params['path']
    label = params['label']
    filename = params['filename']
    thumb = params['thumb']
    icon = params['icon']
    playable = params['isplayable']
    fanart = params['fanart']
    isFolder = params['isfolder']
    hasVideo = params['hasVideo']
    desc = params['description']
    window = params['window']
    file = params['file']
    isStream = params['isstream']

    choice = 0
    menu = []
    localAddon = None

    if MENU_QUICKLAUNCH:
        menu.append((GETTEXT(30219), _QUICKLAUNCH))

    plugins = []
    try:
        plugins = getPlugins()
        addPlugins(menu, plugins, params, _EXTRABASE)
    except Exception as e:
        utils.log('Error adding plugins : %s' % str(e))

    if len(path) > 0:

        if MENU_ADDTOFAVES:
            menu.append((GETTEXT(30047), _ADDTOFAVES))

        if MENU_ADDON_SETTINGS:
            localAddon = utils.findAddon(path)
            if localAddon:
                name = utils.getSettingsLabel(localAddon)
                menu.append((name, _SETTINGS))

        if MENU_DEF_ISEARCH:
            default = getDefaultSearch()
            if len(default) > 0:
                menu.append((GETTEXT(30098) % default, _SEARCHDEF))

        if MENU_ISEARCH: menu.append((GETTEXT(30054), _SEARCH))

        if MENU_IRECOMMEND: menu.append((GETTEXT(30088), _RECOMMEND))

        if MENU_COPY_PROPS: menu.append((GETTEXT(30209), _COPYITEM))

        if MENU_VIEW_IMAGES:
            if len(thumb) > 0 or len(fanart) > 0:
                menu.append((GETTEXT(30216), _SHOWIMAGE))

    if MENU_SF_SETTINGS:
        menu.append((GETTEXT(30049), _SF_SETTINGS))

    stdMenu = False
    if MENU_STD_MENU:
        if (len(path) > 0) or (window == 10034):  #10034 is profile dialog
            stdMenu = True
            menu.append((GETTEXT(30048), _STD_MENU))

    if hasVideo:
        if MENU_DOWNLOADS and isStream:
            menu.append((GETTEXT(30259), _DOWNLOAD))

        if len(menu) == 0:
            doStandard(useScript=False)
            return

        nowPlaying = GETTEXT(30220)
        menu.append((nowPlaying, _PLAYLIST))

    if len(menu) == 0 or (len(menu) == 1 and stdMenu):
        doStandard(useScript=False)
        return

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')

    dialog = ADDON.getSetting('CONTEXT_STYLE') == '1'

    import menus

    if dialog:
        choice = menus.selectMenu(utils.TITLE, menu)
    else:
        choice = menus.showMenu(
            ADDONID, menu,
            useBuiltin=False)  #False to allow right-click to std context menu

    utils.log('selection\t\t: %s' % choice)

    if choice >= _EXTRABASE:
        module = (choice - _EXTRABASE) / 1000
        option = (choice - _EXTRABASE) % 1000

        utils.log('plugin\t\t: %s' % module)
        utils.log('option\t\t: %s' % option)

        try:
            plugins[module].process(option, params)
        except Exception as e:
            utils.log('Error processing plugin: %s' % str(e))

    if choice == _QUICKLAUNCH:
        try:
            quickLaunch()
        except:
            pass

    if choice == _STD_MENU:
        doStandard(useScript=True)

    if choice == _PLAYLIST:
        activateWindow('videoplaylist')

    if choice == _DOWNLOAD:
        try:
            menuUtils.doDownload(file)
        except:
            pass

    if choice == _SF_SETTINGS:
        utils.ADDON.openSettings()

    if choice == _SETTINGS:
        xbmcaddon.Addon(localAddon).openSettings()

    if choice == _ADDTOFAVES:
        menuUtils.addToFaves(params, meta)

    if choice == _LAUNCH_SF:
        utils.LaunchSF()

    if choice in [_SEARCH, _SEARCHDEF, _RECOMMEND]:
        if utils.ADDON.getSetting('STRIPNUMBERS') == 'true':
            label = utils.Clean(label)

        thumb = thumb if len(thumb) > 0 else 'null'
        fanart = fanart if len(fanart) > 0 else 'null'

        #declared in default.py
        _SUPERSEARCH = 0
        _SUPERSEARCHDEF = 10
        _RECOMMEND_KEY = 2700

        valid = [10001, 10002, 10025, 10502]

        if window not in valid:
            window = 10025  #video window

        import urllib

        if choice == _RECOMMEND:
            mode = _RECOMMEND_KEY
        else:
            mode = _SUPERSEARCH if (choice == _SEARCH) else _SUPERSEARCHDEF

        if mode == _SUPERSEARCHDEF:
            return launchDefaultSearch(label)

        try:
            meta = urllib.quote_plus(utils.convertDictToURL(meta))
        except:
            meta = ''

        cmd = 'ActivateWindow(%d,"plugin://%s/?mode=%d&keyword=%s&image=%s&fanart=%s&meta=%s")' % (
            window, ADDONID, mode, urllib.quote_plus(label),
            urllib.quote_plus(thumb), urllib.quote_plus(fanart), meta)

        activateCommand(cmd)

    if choice == _COPYITEM:
        #if not fanart:
        #    fanart = thumb

        cmd = menuUtils.getCmd(path, fanart, desc, window, filename, isFolder,
                               meta)

        import clipboard
        clipboard.setPasteProperties(thumb, fanart, desc, label, cmd, meta)

    if choice == _SHOWIMAGE:
        #if not fanart:
        #    fanart = thumb

        import viewer
        viewer.show(fanart, thumb, ADDONID)
示例#8
0
            if hasVideo:
                menu.append(
                    (xbmc.getLocalizedString(31040), _PLAYLIST))  #Now Playing

    if len(menu) == 0 or (len(menu) == 1 and stdMenu):
        doStandard(useScript=False)
        return

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')

    dialog = ADDON.getSetting('CONTEXT_STYLE') == '1'

    import menus

    if dialog:
        choice = menus.selectMenu(utils.TITLE, menu)
    else:
        choice = menus.showMenu(ADDONID, menu)

    #xbmc.executebuiltin('Dialog.Close(all, true)')

    utils.log('selection\t\t: %s' % choice)

    if choice >= _EXTRABASE:
        module = (choice - _EXTRABASE) / 1000
        option = (choice - _EXTRABASE) % 1000

        utils.log('plugin\t\t: %s' % module)
        utils.log('option\t\t: %s' % option)

        try:
示例#9
0
def editFave(file, cmd, name, thumb):
    fanart    = favourite.getFanart(cmd)
    hasThumb  = len(thumb)  > 0
    hasFanart = len(fanart) > 0
    hasMode   = 'sf_win_id=' in cmd

    UP           = 0
    DOWN         = 1
    COPY         = 2
    MOVE         = 3
    REMOVE       = 4
    RENAME       = 5
    CHOOSETHUMB  = 6
    CHOOSEFANART = 7
    REMOVETHUMB  = 8
    REMOVEFANART = 9
    COLOUR       = 10
    PLAYBACKMODE = 11

    options = []
    options.append([GETTEXT(30041), UP])
    options.append([GETTEXT(30042), DOWN])
    options.append([GETTEXT(30007), COPY])
    options.append([GETTEXT(30008), MOVE])
    options.append([GETTEXT(30009), REMOVE])
    options.append([GETTEXT(30010), RENAME])
    options.append([GETTEXT(30043), CHOOSETHUMB])
    options.append([GETTEXT(30107), CHOOSEFANART])

    if hasThumb:
        options.append([GETTEXT(30097), REMOVETHUMB])

    if hasFanart:
        options.append([GETTEXT(30108), REMOVEFANART])

    options.append([GETTEXT(30085), COLOUR])

    if hasMode:
        options.append([GETTEXT(30052), PLAYBACKMODE])

    import menus
    option = menus.selectMenu(name, options)

    if option == UP:
        return favourite.shiftFave(file, cmd, up=True)

    if option == DOWN:
        return favourite.shiftFave(file, cmd, up=False)

    if option == COPY:
        return copyFave(file, cmd)

    if option == MOVE:
        return moveFave(file, cmd)

    if option == REMOVE:
        return favourite.removeFave(file, cmd)

    if option == RENAME:
        return renameFave(file, cmd)

    if option == CHOOSETHUMB:
        return thumbFave(file, cmd)

    if option == CHOOSEFANART:
        return fanartFave(file, cmd)

    if option == REMOVETHUMB:
        return removeThumbFave(file, cmd)

    if option == REMOVEFANART:
        return removeFanartFave(file, cmd)

    if option == COLOUR:
        return colourFave(file, cmd)

    if option == PLAYBACKMODE:
        return changePlaybackMode(file, cmd)

    return False
示例#10
0
        else:
            if hasVideo:            
                menu.append((xbmc.getLocalizedString(31040), _PLAYLIST)) #Now Playing

    if len(menu) == 0 or (len(menu) == 1 and stdMenu):
        doStandard(useScript=False)
        return

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')

    dialog = ADDON.getSetting('CONTEXT_STYLE') == '1' 

    import menus

    if dialog:
        choice = menus.selectMenu(utils.TITLE, menu)
    else:
        choice = menus.showMenu(ADDONID, menu)

    #xbmc.executebuiltin('Dialog.Close(all, true)')

    utils.log('selection\t\t: %s' % choice)
    
    if choice >= _EXTRABASE:       
        module = (choice - _EXTRABASE) / 1000
        option = (choice - _EXTRABASE) % 1000

        utils.log('plugin\t\t: %s' % module)
        utils.log('option\t\t: %s' % option)

        try:    
示例#11
0
def doMenu():
    try:
        import utils
    except:
        doStandard(useScript=False)
        return  

    DEBUG = utils.ADDON.getSetting('DEBUG') == 'true'
    #if DEBUG:
    #    window = xbmcgui.getCurrentWindowId()
    #    utils.DialogOK('Current Window ID %d' % window)  

    active = [0, 1, 2, 3, 25, 40, 500, 501, 502, 601]
    window = xbmcgui.getCurrentWindowId()
    utils.log('Window     : %d' % window)  
    if window-10000 not in active:
        doStandard(useScript=False)
        return

    import menus

    # to prevent master profile setting being used in other profiles
    if utils.ADDON.getSetting('CONTEXT') != 'true':
        doStandard(useScript=False)
        return

    folder = xbmc.getInfoLabel('Container.FolderPath')
    path  = xbmc.getInfoLabel('ListItem.FolderPath')

    #ignore if in Super Favourites
    if (utils.ADDONID in folder) or (utils.ADDONID in path):
        doStandard(useScript=False)
        return
        
    choice   = 0
    label    = xbmc.getInfoLabel('ListItem.Label')
    filename = xbmc.getInfoLabel('ListItem.FilenameAndPath')
    name     = xbmc.getInfoLabel('ListItem.Label')
    thumb    = xbmc.getInfoLabel('ListItem.Thumb')    
    #thumb    = xbmc.getInfoLabel('ListItem.Art(thumb)')
    playable = xbmc.getInfoLabel('ListItem.Property(IsPlayable)').lower() == 'true'
    fanart   = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)')
    fanart   = xbmc.getInfoLabel('ListItem.Art(fanart)')
    isFolder = xbmc.getCondVisibility('ListItem.IsFolder') == 1
    desc     = getDescription()

    try:    file = xbmc.Player().getPlayingFile()
    except: file = None

    isStream = False
    if file:
        isStream = file.startswith('http://')

    #GOTHAM only 
    #if hasattr(xbmc.Player(), 'isInternetStream'):
    #    isStream = xbmc.Player().isInternetStream()
    #elif file:
    #    isStream = file.startswith('http://')

    if window == 10003: #filemanager
        control = 0
        if xbmc.getCondVisibility('Control.HasFocus(20)') == 1:
            control = 20
        elif xbmc.getCondVisibility('Control.HasFocus(21)') == 1:
            control = 21

        if control == 0:
            return doStandard()

        name     = xbmc.getInfoLabel('Container(%d).ListItem.Label' % control)
        root     = xbmc.getInfoLabel('Container(%d).ListItem.Path'  % control)
        path     = root + name
        isFolder = True
        thumb    = 'DefaultFolder.png'
        #if not path.endswith(os.sep):
        #    path += os.sep

    if isFolder:
        path     = path.replace('\\', '\\\\')
        filename = filename.replace('\\', '\\\\')

    utils.log('**** Context Menu Information ****')
    utils.log('Label      : %s' % label)
    utils.log('Folder     : %s' % folder) 
    utils.log('Path       : %s' % path) 
    utils.log('Filename   : %s' % filename)
    utils.log('Name       : %s' % name)    
    utils.log('Thumb      : %s' % thumb)
    utils.log('Fanart     : %s' % fanart)   
    utils.log('Window     : %d' % window)  
    utils.log('IsPlayable : %s' % playable)
    utils.log('IsFolder   : %s' % isFolder)
    utils.log('File       : %s' % file)
    utils.log('IsStream   : %s' % isStream)

    menu = []

    #if (len(menu) == 0) and window == 12005: #video playing
        #if isStream:
        #    menu.append(('Download  %s' % label, _DOWNLOAD))
        #    menu.append(('Show Playlist',        _PLAYLIST))
        #else:
        #    return doStandard()
        #cancel download feature for now
        #return doStandard()
    
    if (len(menu) == 0) and len(path) > 0:
        menu.append((utils.GETTEXT(30047), _ADDTOFAVES))
        menu.append((utils.GETTEXT(30049), _SF_SETTINGS))

        if utils.ADDON.getSetting('SHOWSS') == 'true':
            menu.append((utils.GETTEXT(30054), _SEARCH))

            default = getDefaultSearch()
            if len(default) > 0:
                menu.append((utils.GETTEXT(30098) % default, _SEARCHDEF))

        menu.append((utils.GETTEXT(30048), _STD_SETTINGS))

    elif window == 10000: #Home screen
        #menu.append((utils.GETTEXT(30053), _LAUNCH_SF))
        #menu.append((utils.GETTEXT(30049), _SF_SETTINGS))
        pass


    if len(menu) == 0:
        doStandard()
        return

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')

    dialog = utils.ADDON.getSetting('CONTEXT_STYLE') == '1'

    if dialog:
        choice = menus.selectMenu(utils.TITLE, menu)
    else:
        choice = menus.showMenu(utils.ADDONID, menu, utils.HELIX)


    if choice == _STD_SETTINGS:
        doStandard()
        return

    xbmc.executebuiltin('Dialog.Close(all, true)')

    if choice == _PLAYLIST:
        xbmc.executebuiltin('ActivateWindow(videoplaylist)')

    #if choice == _DOWNLOAD: 
    #    import download
    #    download.download(file, 'c:\\temp\\file.mpg', 'Super Favourites')

    
    if choice == _STD_SETTINGS:
        doStandard()

    if choice == _SF_SETTINGS:
        utils.ADDON.openSettings()

    if choice == _ADDTOFAVES:
        import favourite
        if isFolder:
            cmd =  'ActivateWindow(%d,"%s' % (window, path)
        elif path.lower().startswith('script'):
            #if path[-1] == '/':
            #    path = path[:-1]
            cmd = 'RunScript("%s' % path.replace('script://', '')
        elif path.lower().startswith('videodb') and len(filename) > 0:
            cmd = 'PlayMedia("%s' % filename
        #elif path.lower().startswith('musicdb') and len(filename) > 0:
        #    cmd = 'PlayMedia("%s")' % filename
        elif path.lower().startswith('androidapp'):
            cmd = 'StartAndroidActivity("%s")' % path.replace('androidapp://sources/apps/', '', 1)
        else:            
            cmd = 'PlayMedia("%s")' % path
            cmd = favourite.updateSFOption(cmd, 'winID', window)

        cmd = favourite.addFanart(cmd, fanart)
        cmd = favourite.updateSFOption(cmd, 'desc', desc)

        if isFolder:
            cmd = cmd.replace('")', '",return)')
       
        copyFave(name, thumb, cmd)

    if choice == _LAUNCH_SF:
        utils.LaunchSF()

    if choice == _SEARCH or choice == _SEARCHDEF:
        if utils.ADDON.getSetting('STRIPNUMBERS') == 'true':
            name = utils.Clean(name)

        thumb  = thumb  if len(thumb)  > 0 else 'null'
        fanart = fanart if len(fanart) > 0 else 'null'

        _SUPERSEARCH    =  0     #declared as  0 in default.py
        _SUPERSEARCHDEF = 10     #declared as 10 in default.py

        mode    = _SUPERSEARCH if (choice == _SEARCH) else _SUPERSEARCHDEF
        videoID = 10025 #video

        if window == 10000: #don't activate on home screen, push to video
            window = videoID

        import urllib        

        cmd = 'ActivateWindow(%d,"plugin://%s/?mode=%d&keyword=%s&image=%s&fanart=%s")' % (window, utils.ADDONID, mode, urllib.quote_plus(name), urllib.quote_plus(thumb), urllib.quote_plus(fanart))
        activateCommand(cmd)
示例#12
0
def doMenu():
    DEBUG = ADDON.getSetting('DEBUG') == 'true'
    if DEBUG:
        window = xbmcgui.getCurrentWindowId()
        utils.DialogOK('Current Window ID %d' % window)

    active = [0, 1, 2, 3, 25, 40, 500, 501, 502, 601, 2005]
    window = xbmcgui.getCurrentWindowId()
    utils.log('Window     : %d' % window)
    if window - 10000 not in active:
        doStandard(useScript=False)
        return

    import menus

    # to prevent master profile setting being used in other profiles
    if ADDON.getSetting('CONTEXT') != 'true':
        doStandard(useScript=False)
        return

    folder = xbmc.getInfoLabel('Container.FolderPath')
    path = xbmc.getInfoLabel('ListItem.FolderPath')

    #ignore if in Super Favourites
    if (ADDONID in folder) or (ADDONID in path):
        doStandard(useScript=False)
        return

    choice = 0
    label = xbmc.getInfoLabel('ListItem.Label')
    filename = xbmc.getInfoLabel('ListItem.FilenameAndPath')
    name = xbmc.getInfoLabel('ListItem.Label')
    thumb = xbmc.getInfoLabel('ListItem.Thumb')
    icon = xbmc.getInfoLabel('ListItem.ActualIcon')
    #thumb    = xbmc.getInfoLabel('ListItem.Art(thumb)')
    playable = xbmc.getInfoLabel(
        'ListItem.Property(IsPlayable)').lower() == 'true'
    fanart = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)')
    fanart = xbmc.getInfoLabel('ListItem.Art(fanart)')
    isFolder = xbmc.getCondVisibility('ListItem.IsFolder') == 1
    desc = getDescription()

    if not thumb:
        thumb = icon

    try:
        file = xbmc.Player().getPlayingFile()
    except:
        file = None

    isStream = False

    if hasattr(xbmc.Player(), 'isInternetStream'):
        isStream = xbmc.Player().isInternetStream()
    elif file:
        isStream = file.startswith('http://')

    if window == 10003:  #filemanager
        control = 0
        if xbmc.getCondVisibility('Control.HasFocus(20)') == 1:
            control = 20
        elif xbmc.getCondVisibility('Control.HasFocus(21)') == 1:
            control = 21

        if control == 0:
            return doStandard()

        name = xbmc.getInfoLabel('Container(%d).ListItem.Label' % control)
        root = xbmc.getInfoLabel('Container(%d).ListItem.Path' % control)
        path = root + name
        isFolder = True
        thumb = 'DefaultFolder.png'
        #if not path.endswith(os.sep):
        #    path += os.sep

    if isFolder:
        path = path.replace('\\', '\\\\')
        filename = filename.replace('\\', '\\\\')

    utils.log('**** Context Menu Information ****')
    utils.log('Label      : %s' % label)
    utils.log('Folder     : %s' % folder)
    utils.log('Path       : %s' % path)
    utils.log('Filename   : %s' % filename)
    utils.log('Name       : %s' % name)
    utils.log('Thumb      : %s' % thumb)
    utils.log('Fanart     : %s' % fanart)
    utils.log('Window     : %d' % window)
    utils.log('IsPlayable : %s' % playable)
    utils.log('IsFolder   : %s' % isFolder)
    utils.log('File       : %s' % file)
    utils.log('IsStream   : %s' % isStream)

    menu = []
    localAddon = None

    #if xbmc.getCondVisibility('Player.HasVideo') == 1:
    #    if isStream:
    #        menu.append(('Download  %s' % label, _DOWNLOAD))
    #        menu.append(('Now playing...',       _PLAYLIST))

    if len(path) > 0:
        if MENU_ADDTOFAVES: menu.append((GETTEXT(30047), _ADDTOFAVES))

        if MENU_ADDON_SETTINGS:
            localAddon = utils.findAddon(path)
            if localAddon:
                label = utils.getSettingsLabel(localAddon)
                menu.append((label, _SETTINGS))

        if MENU_DEF_ISEARCH:
            default = getDefaultSearch()
            if len(default) > 0:
                menu.append((GETTEXT(30098) % default, _SEARCHDEF))

        if MENU_ISEARCH: menu.append((GETTEXT(30054), _SEARCH))
        if MENU_IRECOMMEND: menu.append((GETTEXT(30088), _RECOMMEND))

        if MENU_COPY_PROPS:
            if len(thumb) > 0 or len(fanart) > 0:
                menu.append((GETTEXT(30209), _COPYIMAGES))
                if MENU_VIEW_IMAGES: menu.append((GETTEXT(30216), _SHOWIMAGE))
            else:
                if len(description) > 0:
                    menu.append((GETTEXT(30209), _COPYIMAGES))

    if MENU_SF_SETTINGS: menu.append((GETTEXT(30049), _SF_SETTINGS))
    if MENU_STD_MENU: menu.append((GETTEXT(30048), _STD_MENU))

    if len(menu) == 0 or (len(menu) == 1 and MENU_STD_MENU):
        doStandard(useScript=False)
        return

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')

    dialog = ADDON.getSetting('CONTEXT_STYLE') == '1'

    if dialog:
        choice = menus.selectMenu(utils.TITLE, menu)
    else:
        choice = menus.showMenu(ADDONID, menu)

    #if choice == _STD_MENU:
    #    doStandard()
    #    return

    xbmc.executebuiltin('Dialog.Close(all, true)')

    if choice == _PLAYLIST:
        xbmc.executebuiltin('ActivateWindow(videoplaylist)')

    if choice == _DOWNLOAD:
        import download
        download.doDownload(file, 'c:\\temp\\file.mpg', 'Super Favourites', '',
                            True)

    if choice == _STD_MENU:
        doStandard()

    if choice == _SF_SETTINGS:
        utils.ADDON.openSettings()

    if choice == _SETTINGS:
        xbmcaddon.Addon(localAddon).openSettings()

    if choice == _ADDTOFAVES:
        import favourite
        if isFolder:
            cmd = 'ActivateWindow(%d,"%s' % (window, path)
        elif path.lower().startswith('script'):
            #if path[-1] == '/':
            #    path = path[:-1]
            cmd = 'RunScript("%s' % path.replace('script://', '')
        elif path.lower().startswith('videodb') and len(filename) > 0:
            cmd = 'PlayMedia("%s' % filename
        #elif path.lower().startswith('musicdb') and len(filename) > 0:
        #    cmd = 'PlayMedia("%s")' % filename
        elif path.lower().startswith('androidapp'):
            cmd = 'StartAndroidActivity("%s")' % path.replace(
                'androidapp://sources/apps/', '', 1)
        else:
            cmd = 'PlayMedia("%s")' % path
            cmd = favourite.updateSFOption(cmd, 'winID', window)

        cmd = favourite.addFanart(cmd, fanart)
        cmd = favourite.updateSFOption(cmd, 'desc', desc)

        if isFolder:
            cmd = cmd.replace('")', '",return)')

        copyFave(name, thumb, cmd)

    if choice == _LAUNCH_SF:
        utils.LaunchSF()

    if choice in [_SEARCH, _SEARCHDEF, _RECOMMEND]:
        if utils.ADDON.getSetting('STRIPNUMBERS') == 'true':
            name = utils.Clean(name)

        thumb = thumb if len(thumb) > 0 else 'null'
        fanart = fanart if len(fanart) > 0 else 'null'

        #declared in default.py
        _SUPERSEARCH = 0
        _SUPERSEARCHDEF = 10
        _RECOMMEND_KEY = 2700

        videoID = 10025  #video

        if window == 10000:  #don't activate on home screen, push to video
            window = videoID

        import urllib

        if choice == _RECOMMEND:
            mode = _RECOMMEND_KEY
        else:
            mode = _SUPERSEARCH if (choice == _SEARCH) else _SUPERSEARCHDEF

        cmd = 'ActivateWindow(%d,"plugin://%s/?mode=%d&keyword=%s&image=%s&fanart=%s")' % (
            window, ADDONID, mode, urllib.quote_plus(name),
            urllib.quote_plus(thumb), urllib.quote_plus(fanart))

        activateCommand(cmd)

    if choice == _COPYIMAGES:
        if not fanart:
            fanart = thumb

        xbmcgui.Window(10000).setProperty('SF_THUMB', thumb)
        xbmcgui.Window(10000).setProperty('SF_FANART', fanart)
        xbmcgui.Window(10000).setProperty('SF_DESCRIPTION', desc)

    if choice == _SHOWIMAGE:
        if not fanart:
            fanart = thumb

        import viewer
        viewer.show(fanart, thumb, ADDONID)
示例#13
0
def doMenu():     
    DEBUG = ADDON.getSetting('DEBUG') == 'true'
    if DEBUG:
        window = xbmcgui.getCurrentWindowId()
        utils.DialogOK('Current Window ID %d' % window)  

    active = [0, 1, 2, 3, 25, 40, 500, 501, 502, 601, 2005]
    window = xbmcgui.getCurrentWindowId()
    utils.log('Window     : %d' % window)  
    if window-10000 not in active:
        doStandard(useScript=False)
        return

    import menus

    # to prevent master profile setting being used in other profiles
    if ADDON.getSetting('CONTEXT') != 'true':
        doStandard(useScript=False)
        return

    folder = xbmc.getInfoLabel('Container.FolderPath')
    path   = xbmc.getInfoLabel('ListItem.FolderPath')

    #ignore if in Super Favourites
    if (ADDONID in folder) or (ADDONID in path):
        doStandard(useScript=False)
        return
        
    choice   = 0
    label    = xbmc.getInfoLabel('ListItem.Label')
    filename = xbmc.getInfoLabel('ListItem.FilenameAndPath')
    name     = xbmc.getInfoLabel('ListItem.Label')
    thumb    = xbmc.getInfoLabel('ListItem.Thumb')    
    icon     = xbmc.getInfoLabel('ListItem.ActualIcon')    
    #thumb    = xbmc.getInfoLabel('ListItem.Art(thumb)')
    playable = xbmc.getInfoLabel('ListItem.Property(IsPlayable)').lower() == 'true'
    fanart   = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)')
    fanart   = xbmc.getInfoLabel('ListItem.Art(fanart)')
    isFolder = xbmc.getCondVisibility('ListItem.IsFolder') == 1
    desc     = getDescription()

    if not thumb:
        thumb = icon

    try:    file = xbmc.Player().getPlayingFile()
    except: file = None

    isStream = False
   
    if hasattr(xbmc.Player(), 'isInternetStream'):
        isStream = xbmc.Player().isInternetStream()
    elif file:
        isStream = file.startswith('http://')

    if window == 10003: #filemanager
        control = 0
        if xbmc.getCondVisibility('Control.HasFocus(20)') == 1:
            control = 20
        elif xbmc.getCondVisibility('Control.HasFocus(21)') == 1:
            control = 21

        if control == 0:
            return doStandard()

        name     = xbmc.getInfoLabel('Container(%d).ListItem.Label' % control)
        root     = xbmc.getInfoLabel('Container(%d).ListItem.Path'  % control)
        path     = root + name
        isFolder = True
        thumb    = 'DefaultFolder.png'
        #if not path.endswith(os.sep):
        #    path += os.sep

    if isFolder:
        path     = path.replace('\\', '\\\\')
        filename = filename.replace('\\', '\\\\')

    utils.log('**** Context Menu Information ****')
    utils.log('Label      : %s' % label)
    utils.log('Folder     : %s' % folder) 
    utils.log('Path       : %s' % path) 
    utils.log('Filename   : %s' % filename)
    utils.log('Name       : %s' % name)    
    utils.log('Thumb      : %s' % thumb)
    utils.log('Fanart     : %s' % fanart)   
    utils.log('Window     : %d' % window)  
    utils.log('IsPlayable : %s' % playable)
    utils.log('IsFolder   : %s' % isFolder)
    utils.log('File       : %s' % file)
    utils.log('IsStream   : %s' % isStream)

    menu       = []
    localAddon = None

    #if xbmc.getCondVisibility('Player.HasVideo') == 1:
    #    if isStream:
    #        menu.append(('Download  %s' % label, _DOWNLOAD))
    #        menu.append(('Now playing...',       _PLAYLIST))

    
    if len(path) > 0:
        if MENU_ADDTOFAVES: menu.append((GETTEXT(30047), _ADDTOFAVES))


        if MENU_ADDON_SETTINGS:          
            localAddon = utils.findAddon(path)           
            if localAddon:
                label = utils.getSettingsLabel(localAddon)
                menu.append((label, _SETTINGS))
       

        if MENU_DEF_ISEARCH:           
            default = getDefaultSearch()
            if len(default) > 0:
                menu.append((GETTEXT(30098) % default, _SEARCHDEF))


        if MENU_ISEARCH: menu.append(   (GETTEXT(30054), _SEARCH))
        if MENU_IRECOMMEND: menu.append((GETTEXT(30088), _RECOMMEND))


        if MENU_COPY_PROPS:
            if len(thumb) > 0 or len(fanart) > 0:
                menu.append((GETTEXT(30209), _COPYIMAGES))   
                if MENU_VIEW_IMAGES: menu.append((GETTEXT(30216), _SHOWIMAGE))
            else:
                if len(description) > 0: menu.append((GETTEXT(30209), _COPYIMAGES))   
   

    if MENU_SF_SETTINGS: menu.append((GETTEXT(30049), _SF_SETTINGS))
    if MENU_STD_MENU:    menu.append((GETTEXT(30048), _STD_MENU))


    if len(menu) == 0 or (len(menu) == 1 and MENU_STD_MENU):
        doStandard(useScript=False)
        return

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')

    dialog = ADDON.getSetting('CONTEXT_STYLE') == '1'    

    if dialog:
        choice = menus.selectMenu(utils.TITLE, menu)
    else:
        choice = menus.showMenu(ADDONID, menu)


    #if choice == _STD_MENU:
    #    doStandard()
    #    return

    xbmc.executebuiltin('Dialog.Close(all, true)')

    if choice == _PLAYLIST:
        xbmc.executebuiltin('ActivateWindow(videoplaylist)')

    if choice == _DOWNLOAD: 
        import download
        download.doDownload(file, 'c:\\temp\\file.mpg', 'Super Favourites', '', True)

    if choice == _STD_MENU:
        doStandard()

    if choice == _SF_SETTINGS:
        utils.ADDON.openSettings()

    if choice == _SETTINGS:
        xbmcaddon.Addon(localAddon).openSettings()

    if choice == _ADDTOFAVES:
        import favourite
        if isFolder:
            cmd =  'ActivateWindow(%d,"%s' % (window, path)
        elif path.lower().startswith('script'):
            #if path[-1] == '/':
            #    path = path[:-1]
            cmd = 'RunScript("%s' % path.replace('script://', '')
        elif path.lower().startswith('videodb') and len(filename) > 0:
            cmd = 'PlayMedia("%s' % filename
        #elif path.lower().startswith('musicdb') and len(filename) > 0:
        #    cmd = 'PlayMedia("%s")' % filename
        elif path.lower().startswith('androidapp'):
            cmd = 'StartAndroidActivity("%s")' % path.replace('androidapp://sources/apps/', '', 1)
        else:            
            cmd = 'PlayMedia("%s")' % path
            cmd = favourite.updateSFOption(cmd, 'winID', window)

        cmd = favourite.addFanart(cmd, fanart)
        cmd = favourite.updateSFOption(cmd, 'desc', desc)

        if isFolder:
            cmd = cmd.replace('")', '",return)')
       
        copyFave(name, thumb, cmd)

    if choice == _LAUNCH_SF:
        utils.LaunchSF()

    if choice in [_SEARCH, _SEARCHDEF, _RECOMMEND]:
        if utils.ADDON.getSetting('STRIPNUMBERS') == 'true':
            name = utils.Clean(name)

        thumb  = thumb  if len(thumb)  > 0 else 'null'
        fanart = fanart if len(fanart) > 0 else 'null'

        #declared in default.py
        _SUPERSEARCH    =    0
        _SUPERSEARCHDEF =   10
        _RECOMMEND_KEY  = 2700

        videoID = 10025 #video

        if window == 10000: #don't activate on home screen, push to video
            window = videoID

        import urllib   

        if choice == _RECOMMEND:
            mode = _RECOMMEND_KEY
        else:
            mode = _SUPERSEARCH if (choice == _SEARCH) else _SUPERSEARCHDEF
            
        cmd = 'ActivateWindow(%d,"plugin://%s/?mode=%d&keyword=%s&image=%s&fanart=%s")' % (window, ADDONID, mode, urllib.quote_plus(name), urllib.quote_plus(thumb), urllib.quote_plus(fanart))

        activateCommand(cmd)

    if choice == _COPYIMAGES:  
        if not fanart:
            fanart = thumb
      
        xbmcgui.Window(10000).setProperty('SF_THUMB',       thumb)
        xbmcgui.Window(10000).setProperty('SF_FANART',      fanart)
        xbmcgui.Window(10000).setProperty('SF_DESCRIPTION', desc)


    if choice == _SHOWIMAGE:
        if not fanart:
            fanart = thumb

        import viewer
        viewer.show(fanart, thumb, ADDONID)
示例#14
0
def doMenu():
    try:
        import utils
    except:
        doStandard(useScript=False)
        return

    DEBUG = utils.ADDON.getSetting('DEBUG') == 'true'
    if DEBUG:
        window = xbmcgui.getCurrentWindowId()
        utils.DialogOK('Current Window ID %d' % window)

    active = [0, 1, 2, 25, 40, 500, 501, 502, 601]
    window = xbmcgui.getCurrentWindowId()
    utils.log('Window     : %d' % window)
    if window - 10000 not in active:
        doStandard(useScript=False)
        return

    import menus

    # to prevent master profile setting being used in other profiles
    if utils.ADDON.getSetting('CONTEXT') != 'true':
        doStandard(useScript=False)
        return

    folder = xbmc.getInfoLabel('Container.FolderPath')
    path = xbmc.getInfoLabel('ListItem.FolderPath')

    #ignore if in Super Favourites
    if (utils.ADDONID in folder) or (utils.ADDONID in path):
        doStandard(useScript=False)
        return

    choice = 0
    label = xbmc.getInfoLabel('ListItem.Label')
    filename = xbmc.getInfoLabel('ListItem.FilenameAndPath')
    name = xbmc.getInfoLabel('ListItem.Label')
    thumb = xbmc.getInfoLabel('ListItem.Thumb')
    thumb = xbmc.getInfoLabel('ListItem.Art(thumb)')
    playable = xbmc.getInfoLabel(
        'ListItem.Property(IsPlayable)').lower() == 'true'
    fanart = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)')
    fanart = xbmc.getInfoLabel('ListItem.Art(fanart)')
    isFolder = xbmc.getCondVisibility('ListItem.IsFolder') == 1
    desc = getDescription()

    try:
        file = xbmc.Player().getPlayingFile()
    except:
        file = None

    isStream = False
    if file:
        isStream = file.startswith('http://')

    #GOTHAM only
    #if hasattr(xbmc.Player(), 'isInternetStream'):
    #    isStream = xbmc.Player().isInternetStream()
    #elif file:
    #    isStream = file.startswith('http://')

    if isFolder:
        path = path.replace('\\', '\\\\')
        filename = filename.replace('\\', '\\\\')

    utils.log('**** Context Menu Information ****')
    utils.log('Label      : %s' % label)
    utils.log('Folder     : %s' % folder)
    utils.log('Path       : %s' % path)
    utils.log('Filename   : %s' % filename)
    utils.log('Name       : %s' % name)
    utils.log('Thumb      : %s' % thumb)
    utils.log('Fanart     : %s' % fanart)
    utils.log('Window     : %d' % window)
    utils.log('IsPlayable : %s' % playable)
    utils.log('IsFolder   : %s' % isFolder)
    utils.log('File       : %s' % file)
    utils.log('IsStream   : %s' % isStream)

    menu = []

    #if (len(menu) == 0) and window == 12005: #video playing
    #if isStream:
    #    menu.append(('Download  %s' % label, _DOWNLOAD))
    #    menu.append(('Show Playlist',        _PLAYLIST))
    #else:
    #    return doStandard()
    #cancel download feature for now
    #return doStandard()

    if (len(menu) == 0) and len(path) > 0:
        menu.append((utils.GETTEXT(30047), _ADDTOFAVES))
        menu.append((utils.GETTEXT(30049), _SF_SETTINGS))

        if utils.ADDON.getSetting('SHOWSS') == 'true':
            menu.append((utils.GETTEXT(30054), _SEARCH))

            default = getDefaultSearch()
            if len(default) > 0:
                menu.append((utils.GETTEXT(30098) % default, _SEARCHDEF))

        menu.append((utils.GETTEXT(30048), _STD_SETTINGS))

    elif window == 10000:  #Home screen
        #menu.append((utils.GETTEXT(30053), _LAUNCH_SF))
        #menu.append((utils.GETTEXT(30049), _SF_SETTINGS))
        pass

    if len(menu) == 0:
        doStandard()
        return

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')

    dialog = utils.ADDON.getSetting('CONTEXT_STYLE') == '1'

    if dialog:
        choice = menus.selectMenu(utils.TITLE, menu)
    else:
        choice = menus.showMenu(utils.ADDONID, menu, utils.HELIX)

    if choice == _STD_SETTINGS:
        doStandard()
        return

    xbmc.executebuiltin('Dialog.Close(all, true)')

    if choice == _PLAYLIST:
        xbmc.executebuiltin('ActivateWindow(videoplaylist)')

    #if choice == _DOWNLOAD:
    #    import download
    #    download.download(file, 'c:\\temp\\file.mpg', 'Super Favourites')

    if choice == _STD_SETTINGS:
        doStandard()

    if choice == _SF_SETTINGS:
        utils.ADDON.openSettings()

    if choice == _ADDTOFAVES:
        import favourite
        if isFolder:
            cmd = 'ActivateWindow(%d,"%s' % (window, path)
        elif path.lower().startswith('script'):
            #if path[-1] == '/':
            #    path = path[:-1]
            cmd = 'RunScript("%s' % path.replace('script://', '')
        elif path.lower().startswith('videodb') and len(filename) > 0:
            cmd = 'PlayMedia("%s' % filename
        #elif path.lower().startswith('musicdb') and len(filename) > 0:
        #    cmd = 'PlayMedia("%s")' % filename
        elif path.lower().startswith('androidapp'):
            cmd = 'StartAndroidActivity("%s")' % path.replace(
                'androidapp://sources/apps/', '', 1)
        else:
            cmd = 'PlayMedia("%s")' % path
            cmd = favourite.updateSFOption(cmd, 'winID', window)

        cmd = favourite.addFanart(cmd, fanart)
        cmd = favourite.updateSFOption(cmd, 'desc', desc)

        if isFolder:
            cmd = cmd.replace('")', '",return)')

        copyFave(name, thumb, cmd)

    if choice == _LAUNCH_SF:
        utils.LaunchSF()

    if choice == _SEARCH or choice == _SEARCHDEF:
        if utils.ADDON.getSetting('STRIPNUMBERS') == 'true':
            name = utils.Clean(name)

        thumb = thumb if len(thumb) > 0 else 'null'
        fanart = fanart if len(fanart) > 0 else 'null'

        _SUPERSEARCH = 0  #declared as  0 in default.py
        _SUPERSEARCHDEF = 10  #declared as 10 in default.py

        mode = _SUPERSEARCH if (choice == _SEARCH) else _SUPERSEARCHDEF
        videoID = 10025  #video

        if window == 10000:  #don't activate on home screen, push to video
            window = videoID

        import urllib

        cmd = 'ActivateWindow(%d,"plugin://%s/?mode=%d&keyword=%s&image=%s&fanart=%s")' % (
            window, utils.ADDONID, mode, urllib.quote_plus(name),
            urllib.quote_plus(thumb), urllib.quote_plus(fanart))
        activateCommand(cmd)
示例#15
0
def editFave(file, cmd, name, thumb):
    fanart = favourite.getFanart(cmd)
    hasThumb = len(thumb) > 0
    hasFanart = len(fanart) > 0
    hasMode = 'sf_win_id=' in cmd

    UP = 0
    DOWN = 1
    COPY = 2
    MOVE = 3
    REMOVE = 4
    RENAME = 5
    CHOOSETHUMB = 6
    CHOOSEFANART = 7
    REMOVETHUMB = 8
    REMOVEFANART = 9
    COLOUR = 10
    PLAYBACKMODE = 11

    options = []
    options.append([GETTEXT(30041), UP])
    options.append([GETTEXT(30042), DOWN])
    options.append([GETTEXT(30007), COPY])
    options.append([GETTEXT(30008), MOVE])
    options.append([GETTEXT(30009), REMOVE])
    options.append([GETTEXT(30010), RENAME])
    options.append([GETTEXT(30043), CHOOSETHUMB])
    options.append([GETTEXT(30107), CHOOSEFANART])

    if hasThumb:
        options.append([GETTEXT(30097), REMOVETHUMB])

    if hasFanart:
        options.append([GETTEXT(30108), REMOVEFANART])

    options.append([GETTEXT(30085), COLOUR])

    if hasMode:
        options.append([GETTEXT(30052), PLAYBACKMODE])

    import menus
    option = menus.selectMenu(name, options)

    if option == UP:
        return favourite.shiftFave(file, cmd, up=True)

    if option == DOWN:
        return favourite.shiftFave(file, cmd, up=False)

    if option == COPY:
        return copyFave(file, cmd)

    if option == MOVE:
        return moveFave(file, cmd)

    if option == REMOVE:
        return favourite.removeFave(file, cmd)

    if option == RENAME:
        return renameFave(file, cmd)

    if option == CHOOSETHUMB:
        return thumbFave(file, cmd)

    if option == CHOOSEFANART:
        return fanartFave(file, cmd)

    if option == REMOVETHUMB:
        return removeThumbFave(file, cmd)

    if option == REMOVEFANART:
        return removeFanartFave(file, cmd)

    if option == COLOUR:
        return colourFave(file, cmd)

    if option == PLAYBACKMODE:
        return changePlaybackMode(file, cmd)

    return False