Beispiel #1
0
def getCmd(path, fanart, desc, window, filename, isFolder):
    import favourite

    if path.lower().startswith('addons://user/'):
        path     = path.replace('addons://user/', 'plugin://')
        isFolder = True
        window   = 10025

    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.replace('\\', '\\\\')
    #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)')

    return cmd
Beispiel #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
Beispiel #3
0
def fanartFave(file, cmd):
    image = getImage()

    if not image:
        return False

    fave, index, nFaves = favourite.findFave(file, cmd)
    fave[2] = favourite.addFanart(fave[2], image)

    return favourite.updateFave(file, fave)
def getCmd(path, fanart, desc, window, filename, isFolder, meta):
    import favourite

    if path.lower().startswith('addons://user/'):
        path = path.replace('addons://user/', 'plugin://')
        isFolder = True
        window = 10025

    if window == 10003:  #FileManager
        import sfile
        import os
        isFolder = sfile.isdir(path)
        if isFolder:
            #special paths fail to open - http://trac.kodi.tv/ticket/17333
            if path.startswith('special://'):
                path = xbmc.translatePath(path)
            path = path.replace('%s%s' % (os.sep, os.sep), os.sep)
            path = path.replace(os.sep, '/')
            folder = path
            if folder.endswith('/'):
                folder = folder[:-1]
            folder = folder.rsplit('/', 1)[-1]
            #if not utils.DialogYesNo(GETTEXT(30271) % folder, GETTEXT(30272)):
            #    return None

    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.replace('\\', '\\\\')
    #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 meta:
        import urllib
        meta = utils.convertDictToURL(meta)
        cmd = favourite.updateSFOption(cmd, 'meta', urllib.quote_plus(meta))

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

    return cmd
Beispiel #5
0
def fanartFave(file, cmd):
    image = getImage()

    if not image:
        return False

    fave, index, nFaves = favourite.findFave(file, cmd)

    fave[2] = favourite.addFanart(fave[2], image)

    return favourite.updateFave(file, fave)
Beispiel #6
0
def _getCmd(path, fanart, desc, window, filename, isFolder, meta, picture):
    if path.lower().startswith('addons://user/'):
        path     = path.replace('addons://user/', 'plugin://')
        isFolder = True
        window   = 10025

    window = fixWindowID(window)

    if window == 10003:#FileManager
        import sfile
        import os

        isFolder = sfile.isdir(path)
        if isFolder:
            #special paths fail to open - http://trac.kodi.tv/ticket/17333
            if path.startswith('special://'):
                path = xbmc.translatePath(path)
            path = path.replace('%s%s' % (os.sep, os.sep), os.sep)
            path = path.replace(os.sep, '/')
            folder = path
            if folder.endswith('/'):
                folder = folder[:-1]
            folder = folder.rsplit('/', 1)[-1]
            #if not utils.DialogYesNo(GETTEXT(30271) % folder, GETTEXT(30272)):
            #    return None
        else:
            if not sfile.isfile(path):
                return None

    if favourite.isKodiCommand(path):
        return path
    elif len(picture) > 0:
        cmd = 'ShowPicture("%s")'  % picture
    elif 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.replace('\\', '\\\\')
    #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 meta:
        import urllib
        meta = utils.convertDictToURL(meta)
        cmd  = favourite.updateSFOption(cmd, 'meta', urllib.quote_plus(meta))

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

    return cmd
Beispiel #7
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 = [1, 2, 25, 40, 500, 501, 502] #28 is video Playlist
    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')    
    playable = xbmc.getInfoLabel('ListItem.Property(IsPlayable)').lower() == 'true'
    fanart   = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)')
    isFolder = xbmc.getCondVisibility('ListItem.IsFolder') == 1

    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:
        ytID = ''

        if path.startswith('plugin://plugin.video.youtube') and 'videoid=' in path:
            try:
                ytID = path.rsplit('videoid=', 1)[-1][0:11]
                menu.append((utils.GETTEXT(30104), _PLAYTUBE))
            except:
                ytID = ''

        #utils.verifySuperSearch()

        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))


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

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')
    choice = menus.showMenu(utils.ADDONID, menu)

    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 == _PLAYTUBE:
        if len(ytID) != 11:
            return
        import yt    
        if not yt.PlayVideo(ytID):
            utils.DialogOK(utils.GETTEXT(30105))
    
    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
        else:            
            cmd = 'PlayMedia("%s")' % path
            cmd = favourite.updateSFOption(cmd, 'winID', window)

        cmd = favourite.addFanart(cmd, fanart)

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

    if choice == _LAUNCH_SF:
        xbmc.executebuiltin('ActivateWindow(programs,plugin://%s)' % utils.ADDONID)

    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)
Beispiel #8
0
def doMenu():
    try:
        import utils
    except:
        doStandard(useScript=False)
        return

    active = [1, 2, 25, 40, 500, 501, 502]  #28 is video Playlist
    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')
    playable = xbmc.getInfoLabel(
        'ListItem.Property(IsPlayable)').lower() == 'true'
    fanart = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)')
    isFolder = xbmc.getCondVisibility('ListItem.IsFolder') == 1

    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:
        ytID = ''

        if path.startswith(
                'plugin://plugin.video.youtube') and 'videoid=' in path:
            try:
                ytID = path.rsplit('videoid=', 1)[-1][0:11]
                menu.append((utils.GETTEXT(30104), _PLAYTUBE))
            except:
                ytID = ''

        #utils.verifySuperSearch()

        default = getDefaultSearch()

        menu.append((utils.GETTEXT(30047), _ADDTOFAVES))
        menu.append((utils.GETTEXT(30049), _SF_SETTINGS))
        menu.append((utils.GETTEXT(30054), _SEARCH))

        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))

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

    xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')
    choice = menus.showMenu(utils.ADDONID, menu)

    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 == _PLAYTUBE:
        if len(ytID) != 11:
            return
        import yt
        if not yt.PlayVideo(ytID):
            utils.DialogOK(utils.GETTEXT(30105))

    if choice == _STD_SETTINGS:
        doStandard()

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

    if choice == _ADDTOFAVES:
        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
        else:
            cmd = 'PlayMedia("%s&sf_win_id=%d_' % (path, window)

        import favourite
        cmd = favourite.addFanart(cmd, fanart)

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

        copyFave(name, thumb, cmd)

    if choice == _LAUNCH_SF:
        xbmc.executebuiltin('ActivateWindow(programs,plugin://%s)' %
                            utils.ADDONID)

    if choice == _SEARCH or choice == _SEARCHDEF:
        if utils.ADDON.getSetting('STRIPNUMBERS') == 'true':
            name = 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)
Beispiel #9
0
        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(label, thumb, cmd)

    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'
Beispiel #10
0
            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(label, thumb, cmd)

    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'
Beispiel #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)
Beispiel #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)
Beispiel #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)