Пример #1
0
def getPlaylist():
    root = utils.HOME.split(os.sep, 1)[0] + os.sep
    playlist = xbmcgui.Dialog().browse(1, utils.GETTEXT(30148), 'files',
                                       PLAYLIST_EXT, False, False, root)

    if playlist and playlist != root:
        return playlist

    return None
Пример #2
0
def download(silent=False):
    params = menuUtils.getCurrentParams()

    if params == None or ('file' not in params):
        if not silent:
            import utils
            utils.DialogOK(utils.GETTEXT(30261))
        return

    menuUtils.doDownload(params['file'])
Пример #3
0
def copyFave(name, thumb, cmd):
    import favourite
    import utils

    text = utils.GETTEXT(30019)

    folder = utils.GetFolder(text)
    if not folder:
        return False

    file = os.path.join(folder, utils.FILENAME)

    fave = [name, thumb, cmd]

    return favourite.copyFave(file, fave)
Пример #4
0
def add(silent=False):
    params = menuUtils.getCurrentParams()
    meta = menuUtils.getCurrentMeta()

    import utils
    utils.outputDict(params, 'menu_addtofaves - params')
    utils.outputDict(meta, 'menu_addtofaves - meta')

    if params == None:
        if not silent:
            import utils
            utils.DialogOK(utils.GETTEXT(30260))
        return

    menuUtils.addToFaves(params, meta)
Пример #5
0
def copyFave(name, thumb, cmd):
    import favourite
    import utils

    text = utils.GETTEXT(30019)

    folder = utils.GetFolder(text)
    if not folder:
        return False

    file = os.path.join(folder, utils.FILENAME)
    faves = favourite.getFavourites(file)

    #if it is already in there don't add again
    for fave in faves:
        if favourite.equals(fave[2], cmd):
            return False

    fave = [name, thumb, cmd]

    return favourite.copyFave(file, fave)
Пример #6
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 contextmenu

    # 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')
    #ignore if in Super Favourites
    if utils.ADDONID in folder:
        doStandard(useScript=False)
        return

    choice = 0
    label = xbmc.getInfoLabel('ListItem.Label')
    path = xbmc.getInfoLabel('ListItem.FolderPath')
    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://')

    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 = contextmenu.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 urllib
        if '?' in cmd:
            cmd += '&'
        else:
            cmd += '?'

        cmd += 'sf_fanart=%s_")' % urllib.quote_plus(fanart)

        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)
Пример #7
0
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with XBMC; see the file COPYING.  If not, write to
#  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#  http://www.gnu.org/copyleft/gpl.html
#

import xbmc
import os
import shutil
import utils

CACHE = xbmc.translatePath(os.path.join(utils.PROFILE, 'c'))
print "CAHCE"
print CACHE

try:
    shutil.rmtree(CACHE)
except:
    pass

utils.DialogOK('', utils.GETTEXT(30004))
Пример #8
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)