def ShowSFShortcuts(): if not SF_INSTALLED: return faves = favourite.getFavourites(SFFILE) mode = _SUPERFAVE isFolder = False isPlayable = False replaceItems = False for fave in faves: name = fave[0] icon = fave[1] path = fave[2] #these currently don't work as they are removed by chooser.py :( fanart = favourite.getFanart(path) desc = favourite.getOption(path, 'desc') menu = [] menu.append( ('Remove %s Super Favourite' % (name), '?mode=%d&url=%s' % (_REMOVESUPERFAVE, urllib.quote_plus(path)))) AddDir(name, path, mode, icon, desc, isFolder, isPlayable, fanart=fanart, contextMenu=menu, replaceItems=False)
def getFolderThumb(path, isXBMC=False): cfg = os.path.join(path, FOLDERCFG) thumb = getParam('ICON', cfg) fanart = getParam('FANART', cfg) if thumb and fanart: return thumb, fanart if isXBMC: thumb = thumb if (thumb != None) else 'DefaultFolder.png' fanart = fanart if (fanart != None) else FANART return thumb, fanart if not INHERIT: thumb = thumb if (thumb != None) else ICON fanart = fanart if (fanart != None) else FANART return thumb, fanart faves = favourite.getFavourites(os.path.join(path, FILENAME), 1) if len(faves) < 1: thumb = thumb if (thumb != None) else ICON fanart = fanart if (fanart != None) else FANART return thumb, fanart tFave = faves[0][1] fFave = favourite.getFanart(faves[0][2]) thumb = thumb if (thumb != None) else tFave fanart = fanart if (fanart != None) else fFave fanart = fanart if (fanart and len(fanart) > 0) else FANART return thumb, fanart
def onInit(self): try: self.favList = self.getControl(6) self.getControl(3).setVisible(False) except: self.favList = self.getControl(3) self.getControl(5).setVisible(False) self.getControl(1).setLabel(GETTEXT(30000)) try: self.getControl(7).setLabel(xbmc.getLocalizedString(222)) except: pass self.getControl(5).setVisible(False) #the remove item #self.favList.addItem(xbmcgui.ListItem(GETTEXT(30100), iconImage='DefaultAddonNone.png')) if self.mode != 'xbmc': self.addFolderItem() if self.mode == 'root': self.addXBMCFavouritesItem() for fave in self.faves: listitem = xbmcgui.ListItem(fave[0]) icon = fave[1] if not icon: icon = ICON listitem.setIconImage(icon) listitem.setProperty('Icon', fave[1]) cmd = fave[2] if cmd.lower().startswith('activatewindow'): cmd = cmd.replace('")', '",return)') fanart = favourite.getFanart(cmd) desc = favourite.getOption(cmd, 'desc') mode = favourite.getOption(cmd, 'mode') cmd = favourite.removeSFOptions(cmd) listitem.setProperty('Path', cmd) listitem.setProperty('Fanart', fanart) listitem.setProperty('Desc', desc) listitem.setProperty('Mode', mode) if len(fave) > 3 and fave[3]: listitem.setProperty('IsFolder', 'true') self.favList.addItem(listitem) # add a dummy item with no action assigned #listitem = xbmcgui.ListItem(GETTEXT(30101)) #listitem.setProperty('Path', 'noop') #self.favList.addItem(listitem) self.setFocus(self.favList)
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
def onInit(self): try: self.favList = self.getControl(6) self.getControl(3).setVisible(False) except: self.favList = self.getControl(3) self.getControl(5).setVisible(False) self.getControl(1).setLabel(GETTEXT(30000)) self.getControl(1).setVisible(False) #the remove item #self.favList.addItem(xbmcgui.ListItem(GETTEXT(30100), iconImage='DefaultAddonNone.png')) if self.mode != 'xbmc': self.addFolderItem() if self.mode == 'root': self.addXBMCFavouritesItem() for fave in self.faves: listitem = xbmcgui.ListItem(fave[0]) icon = fave[1] if not icon: icon = ICON listitem.setIconImage(icon) listitem.setProperty('Icon', fave[1]) cmd = fave[2] if cmd.lower().startswith('activatewindow'): cmd = cmd.replace('")', '",return)') fanart = favourite.getFanart(cmd) desc = favourite.getOption(cmd, 'desc') mode = favourite.getOption(cmd, 'mode') cmd = favourite.removeSFOptions(cmd) listitem.setProperty('Path', cmd) listitem.setProperty('Fanart', fanart) listitem.setProperty('Desc', desc) listitem.setProperty('Mode', mode) if len(fave) > 3 and fave[3]: listitem.setProperty('IsFolder', 'true') self.favList.addItem(listitem) # add a dummy item with no action assigned #listitem = xbmcgui.ListItem(GETTEXT(30101)) #listitem.setProperty('Path', 'noop') #self.favList.addItem(listitem) self.setFocus(self.favList)
def parseFile(file): global separator faves = favourite.getFavourites(file) text = GETTEXT(30099) if mode == _XBMC else GETTEXT(30068) for fave in faves: label = fave[0] thumb = fave[1] cmd = fave[2] fanart = favourite.getFanart(cmd) menu = [] menu.append( (text, 'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s&name=%s&thumb=%s)' % (sys.argv[0], _EDITFAVE, urllib.quote_plus(file), urllib.quote_plus(cmd), urllib.quote_plus(label), urllib.quote_plus(thumb)))) if isPlaylist(cmd) and (not PLAY_PLAYLISTS): menu.append( (GETTEXT(30084), 'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _PLAYLIST, urllib.quote_plus(file), urllib.quote_plus(cmd)))) if 'playmedia(' in cmd.lower(): addDir(label, _PLAYMEDIA, cmd=cmd, thumbnail=thumb, isFolder=False, menu=menu, fanart=fanart) else: addDir(label, _ACTIVATEWINDOW, cmd=cmd, thumbnail=thumb, isFolder=True, menu=menu, fanart=fanart) separator = len(faves) > 0
def cutCopy(file, cmd, cut=True): reset() xbmcgui.Window(10000).setProperty('SF_FILE', file) xbmcgui.Window(10000).setProperty('SF_FOLDER', file.rsplit(os.sep, 1)[0]) xbmcgui.Window(10000).setProperty('SF_CMD', cmd) xbmcgui.Window(10000).setProperty('SF_TYPE', 'cut' if cut else 'copy') fave, index, nFaves = favourite.findFave(file, cmd) if index < 0: return thumb = fave[1] fanart = favourite.getFanart(fave[2]) desc = favourite.getOption(fave[2], 'desc') meta = favourite.getOption(fave[2], 'meta') meta = utils.convertURLToDict(meta) _setPasteProperties(thumb, fanart, desc, meta=meta) return True
def ShowSFShortcuts(): if not SF_INSTALLED: return faves = favourite.getFavourites(SFFILE) mode = _SUPERFAVE isFolder = False isPlayable = False replaceItems = False for fave in faves: name = fave[0] icon = fave[1] path = fave[2] #these currently don't work as they are removed by chooser.py :( fanart = favourite.getFanart(path) desc = favourite.getOption(path, 'desc') menu = [] menu.append(('Remove %s Super Favourite' % (name), '?mode=%d&url=%s' % (_REMOVESUPERFAVE, urllib.quote_plus(path)))) AddDir(name, path, mode, icon, desc, isFolder, isPlayable, fanart=fanart, contextMenu=menu, replaceItems=False)
def parseFile(file): global separator faves = favourite.getFavourites(file) text = GETTEXT(30099) if mode == _XBMC else GETTEXT(30068) for fave in faves: label = fave[0] thumb = fave[1] cmd = fave[2] fanart = favourite.getFanart(cmd) menu = [] menu.append((text, 'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s&name=%s&thumb=%s)' % (sys.argv[0], _EDITFAVE, urllib.quote_plus(file), urllib.quote_plus(cmd), urllib.quote_plus(label), urllib.quote_plus(thumb)))) if isPlaylist(cmd) and (not PLAY_PLAYLISTS): menu.append((GETTEXT(30084), 'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _PLAYLIST, urllib.quote_plus(file), urllib.quote_plus(cmd)))) if 'playmedia(' in cmd.lower(): addDir(label, _PLAYMEDIA, cmd=cmd, thumbnail=thumb, isFolder=False, menu=menu, fanart=fanart) else: addDir(label, _ACTIVATEWINDOW, cmd=cmd, thumbnail=thumb, isFolder=True, menu=menu, fanart=fanart) separator = len(faves) > 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
def superSearch(keyword='', image=BLANK, fanart=FANART, imdb=''): if len(keyword) < 1: kb = xbmc.Keyboard(keyword, GETTEXT(30054)) kb.doModal() if kb.isConfirmed(): keyword = kb.getText() if len(keyword) > 0: mode = _SUPERSEARCH cmd = '%s?mode=%d&keyword=%s&image=%s&fanart=%s' % (sys.argv[0], mode, keyword, image, fanart) xbmc.executebuiltin('XBMC.Container.Update(%s)' % cmd) return False if len(keyword) < 1: return if keyword == ISEARCH_EMPTY: keyword = '' if not SHOW_FANART: fanart = BLANK menu = [] menu.append((GETTEXT(30057), 'XBMC.Container.Update(%s?mode=%d&keyword=%s)' % (sys.argv[0], _EDITTERM, keyword))) infolabels = {} if METARECOMMEND and len(imdb) > 0: from metahandler import metahandlers grabber = metahandlers.MetaData() infolabels = getMeta(grabber, '', 'movie', year=None, imdb=imdb) getMovieMenu(infolabels, menu) addDir(GETTEXT(30066) % keyword.strip(), _EDITTERM, thumbnail=image, isFolder=True, menu=menu, fanart=fanart, keyword=keyword, infolabels=infolabels) #reset menu, since adddir call will have added to it menu = [] menu.append((GETTEXT(30057), 'XBMC.Container.Update(%s?mode=%d&keyword=%s)' % (sys.argv[0], _EDITTERM, keyword))) addSeparatorItem(menu) if SHOWRECOMMEND: menu = [] menu.append((GETTEXT(30057), 'XBMC.Container.Update(%s?mode=%d&keyword=%s)' % (sys.argv[0], _EDITTERM, keyword))) getMovieMenu(infolabels, menu) if len(imdb) > 0: addDir(GETTEXT(30088), _RECOMMEND_IMDB, thumbnail=image, isFolder=True, menu=menu, fanart=fanart, keyword=keyword, imdb=imdb, infolabels=infolabels) else: addDir(GETTEXT(30088), _RECOMMEND_KEY, thumbnail=image, isFolder=True, menu=menu, fanart=fanart, keyword=keyword) keyword = urllib.quote_plus(keyword.replace('&', '')) file = os.path.join(xbmc.translatePath(ROOT), 'Search', FILENAME) faves = favourite.getFavourites(file, superSearch=True) if len(faves) == 0: #try shipped search file file = os.path.join(xbmc.translatePath(HOME), 'resources', 'Search', FILENAME) faves = favourite.getFavourites(file) for fave in faves: label = fave[0] thumb = fave[1] cmd = fave[2].replace('[%SF%]', keyword) fan = fanart if SHOW_FANART: fan = favourite.getFanart(cmd) if len(fan) == 0: fan = fanart menu = [] menu.append((GETTEXT(30057), 'XBMC.Container.Update(%s?mode=%d&keyword=%s)' % (sys.argv[0], _EDITTERM, keyword))) menu.append((GETTEXT(30103), 'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s&name=%s&thumb=%s)' % (sys.argv[0], _EDITSEARCH, urllib.quote_plus(file), urllib.quote_plus(cmd), urllib.quote_plus(label), urllib.quote_plus(thumb)))) #special fix for GlobalSearch, use local launcher (globalsearch.py) to bypass keyboard cmd = cmd.replace('script.globalsearch', os.path.join(HOME, 'globalsearch.py')) addDir(label, _ACTIVATESEARCH, cmd=cmd, thumbnail=thumb, isFolder=True, menu=menu, fanart=fan) return True
def superSearch(keyword='', image=BLANK, fanart=FANART, imdb=''): if len(keyword) < 1: kb = xbmc.Keyboard(keyword, GETTEXT(30054)) kb.doModal() if kb.isConfirmed(): keyword = kb.getText() if len(keyword) > 0: mode = _SUPERSEARCH cmd = '%s?mode=%d&keyword=%s&image=%s&fanart=%s' % ( sys.argv[0], mode, keyword, image, fanart) xbmc.executebuiltin('XBMC.Container.Update(%s)' % cmd) return False if len(keyword) < 1: return if keyword == ISEARCH_EMPTY: keyword = '' if not SHOW_FANART: fanart = BLANK menu = [] menu.append( (GETTEXT(30057), 'XBMC.Container.Update(%s?mode=%d&keyword=%s)' % (sys.argv[0], _EDITTERM, keyword))) infolabels = {} if METARECOMMEND and len(imdb) > 0: from metahandler import metahandlers grabber = metahandlers.MetaData() infolabels = getMeta(grabber, '', 'movie', year=None, imdb=imdb) getMovieMenu(infolabels, menu) addDir(GETTEXT(30066) % keyword.strip(), _EDITTERM, thumbnail=image, isFolder=True, menu=menu, fanart=fanart, keyword=keyword, infolabels=infolabels) #reset menu, since adddir call will have added to it menu = [] menu.append( (GETTEXT(30057), 'XBMC.Container.Update(%s?mode=%d&keyword=%s)' % (sys.argv[0], _EDITTERM, keyword))) addSeparatorItem(menu) if SHOWRECOMMEND: menu = [] menu.append( (GETTEXT(30057), 'XBMC.Container.Update(%s?mode=%d&keyword=%s)' % (sys.argv[0], _EDITTERM, keyword))) getMovieMenu(infolabels, menu) if len(imdb) > 0: addDir(GETTEXT(30088), _RECOMMEND_IMDB, thumbnail=image, isFolder=True, menu=menu, fanart=fanart, keyword=keyword, imdb=imdb, infolabels=infolabels) else: addDir(GETTEXT(30088), _RECOMMEND_KEY, thumbnail=image, isFolder=True, menu=menu, fanart=fanart, keyword=keyword) keyword = urllib.quote_plus(keyword.replace('&', '')) file = os.path.join(xbmc.translatePath(ROOT), 'Search', FILENAME) faves = favourite.getFavourites(file, superSearch=True) if len(faves) == 0: #try shipped search file file = os.path.join(xbmc.translatePath(HOME), 'resources', 'Search', FILENAME) faves = favourite.getFavourites(file) for fave in faves: label = fave[0] thumb = fave[1] cmd = fave[2].replace('[%SF%]', keyword) fan = fanart if SHOW_FANART: fan = favourite.getFanart(cmd) if len(fan) == 0: fan = fanart menu = [] menu.append( (GETTEXT(30057), 'XBMC.Container.Update(%s?mode=%d&keyword=%s)' % (sys.argv[0], _EDITTERM, keyword))) menu.append( (GETTEXT(30103), 'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s&name=%s&thumb=%s)' % (sys.argv[0], _EDITSEARCH, urllib.quote_plus(file), urllib.quote_plus(cmd), urllib.quote_plus(label), urllib.quote_plus(thumb)))) #special fix for GlobalSearch, use local launcher (globalsearch.py) to bypass keyboard cmd = cmd.replace('script.globalsearch', os.path.join(HOME, 'globalsearch.py')) addDir(label, _ACTIVATESEARCH, cmd=cmd, thumbnail=thumb, isFolder=True, menu=menu, fanart=fan) return True