The branch, frodo has been updated
via f5336d81f41cb55c351e501285657e3f9a1a8397 (commit)
from b16a636f488f5e5565fab5d822faeba76cc78a1d (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=f5336d81f41cb55c351e501285657e3f9a1a8397
commit f5336d81f41cb55c351e501285657e3f9a1a8397
Author: sphere <[email protected]>
Date: Wed May 7 10:01:30 2014 +0200
[plugin.program.super.favourites] updated to version 1.0.3
diff --git a/plugin.program.super.favourites/addon.xml
b/plugin.program.super.favourites/addon.xml
index cae811b..727c5bb 100644
--- a/plugin.program.super.favourites/addon.xml
+++ b/plugin.program.super.favourites/addon.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.program.super.favourites" name="Super Favourites"
version="1.0.1" provider-name="spoyser">
+<addon id="plugin.program.super.favourites" name="Super Favourites"
version="1.0.3" provider-name="spoyser">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
- <provides>executable</provides>
+ <provides>video executable</provides>
</extension>
<extension point="xbmc.service" library="service.py" start="startup" />
<extension point="xbmc.addon.metadata">
diff --git a/plugin.program.super.favourites/changelog.txt
b/plugin.program.super.favourites/changelog.txt
index 48acbc4..d7ddf7d 100644
--- a/plugin.program.super.favourites/changelog.txt
+++ b/plugin.program.super.favourites/changelog.txt
@@ -1,5 +1,20 @@
+v1.0.3:
+ - Improved handling of non-ascii characters
+ - Add back to XBMC favourites for both folders and favourites
+
+
+v1.0.2:
+ - Beta release for testing / feedback
+ - Overide standard context menu, allows direct Adding to Super Favourites
from any addon
+ - Added Move Up / Move Down
+ - Super Favourites now launch properly from within Super Favourites
+ - Choose Thumbnails for Super Favourites and Super Folders (including built
in icons when using Confluence or ReTouched)
+ - Coloured text works correctly in favourite names
+
+
v1.0.1:
- - bug fixes
+ - Bug fixes
+
v1.0.0:
- - initial release
+ - Initial release
\ No newline at end of file
diff --git a/plugin.program.super.favourites/default.py
b/plugin.program.super.favourites/default.py
index 5d9d83a..85829e4 100644
--- a/plugin.program.super.favourites/default.py
+++ b/plugin.program.super.favourites/default.py
@@ -32,20 +32,23 @@ import shutil
import favourite
import utils
-
ADDONID = utils.ADDONID
ADDON = utils.ADDON
HOME = utils.HOME
PROFILE = utils.PROFILE
VERSION = utils.VERSION
ICON = utils.ICON
+
FANART = utils.FANART
BLANK = utils.BLANK
GETTEXT = utils.GETTEXT
TITLE = utils.TITLE
+FRODO = utils.FRODO
GOTHAM = utils.GOTHAM
-FILENAME = 'favourites.xml'
+FILENAME = utils.FILENAME
+FOLDERCFG = utils.FOLDERCFG
+
_SEPARATOR = 0
_SETTINGS = 100
@@ -62,14 +65,26 @@ _MOVE = 1100
_COPY = 1200
_UP = 1300
_DOWN = 1400
+_THUMBFAVE = 1500
+_THUMBFOLDER = 1600
+_PLAYBACKMODE = 1700
+
SHOWNEW = ADDON.getSetting('SHOWNEW') == 'true'
SHOWXBMC = ADDON.getSetting('SHOWXBMC') == 'true'
+SHOWSEP = ADDON.getSetting('SHOWSEP') == 'true'
def clean(text):
- text = re.sub('[:\\/*?\<>|"]+', '', text)
- return text.strip()
+ if not text:
+ return None
+
+ text = re.sub('[:\\\\/*?\<>|"]+', '', text)
+ text = text.strip()
+ if len(text) < 1:
+ return None
+
+ return text
def main():
@@ -89,7 +104,8 @@ def addNewFolderItem(path):
def addSeparatorItem():
- addDir('', _SEPARATOR, thumbnail=BLANK, isFolder=False)
+ if SHOWSEP:
+ addDir('', _SEPARATOR, thumbnail=BLANK, isFolder=False)
def addGlobalMenuItem(menu):
@@ -107,22 +123,29 @@ def addGlobalMenuItem(menu):
def addFavouriteMenuItem(menu, name, thumb, cmd):
+ if cmd.endswith('&mode=0'):
+ return
+
menu.append((GETTEXT(30006),
'XBMC.RunPlugin(%s?mode=%d&name=%s&thumb=%s&cmd=%s)' % (sys.argv[0],
_ADDTOXBMC, urllib.quote_plus(name), urllib.quote_plus(thumb),
urllib.quote_plus(cmd))))
def addToXBMC(name, thumb, cmd):
- cmd = cmd.replace('&', '&')
- cmd = cmd.replace('+', '%20')
- cmd = '"%s"' % cmd
+ cmd = '"%s"' % cmd
- cmd = 'ActivateWindow(10001,%s)' % cmd
+ folder = '&mode=%d&' % _FOLDER
+
+ if folder in cmd:
+ cmd = cmd.replace('+', '%20')
+ cmd = 'ActivateWindow(%d,%s)' % (xbmcgui.getCurrentWindowId(), cmd)
+ else:
+ cmd = 'PlayMedia(%s)' % cmd
fave = [name, thumb, cmd]
file = os.path.join(xbmc.translatePath('special://profile'), FILENAME)
#if it is already in there don't add again
- if findFave(file, cmd):
+ if findFave(file, cmd)[0]:
return False
faves = favourite.getFavourites(file)
@@ -139,10 +162,10 @@ def refresh():
def showXBMCFolder():
file = os.path.join(xbmc.translatePath('special://profile'), FILENAME)
- parseFile(file, True)
+ parseFile(file, isXBMC=True)
-def parseFile(file, isXBMC=False, reqSep=False):
+def parseFile(file, reqSep=False, isXBMC=False):
faves = favourite.getFavourites(file)
if reqSep and len(faves) > 0:
@@ -158,17 +181,20 @@ def parseFile(file, isXBMC=False, reqSep=False):
include = True #originally set to (not isXBMC) to prevent altering
XBMC favourites themselves
- #if include:
- #menu.append((GETTEXT(30041),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _UP,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
- #menu.append((GETTEXT(30042),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _DOWN,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
+ if include:
+ menu.append((GETTEXT(30041),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _UP,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
+ menu.append((GETTEXT(30042),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _DOWN,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
menu.append((GETTEXT(30007),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _COPY,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
if include:
+ menu.append((GETTEXT(30008),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _MOVE,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
+ menu.append((GETTEXT(30009),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _REMOVEFAVE,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
+ menu.append((GETTEXT(30010),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _RENAMEFAVE,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
+ menu.append((GETTEXT(30043),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _THUMBFAVE,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
- menu.append((GETTEXT(30008),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _MOVE,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
- menu.append((GETTEXT(30009),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _REMOVEFAVE,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
- menu.append((GETTEXT(30010),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _RENAMEFAVE,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
+ if 'sf_win_id=' in cmd:
+ menu.append((GETTEXT(30052),
'XBMC.RunPlugin(%s?mode=%d&file=%s&cmd=%s)' % (sys.argv[0], _PLAYBACKMODE,
urllib.quote_plus(file), urllib.quote_plus(cmd))))
addDir(label, _COMMAND, cmd=cmd, thumbnail=thumb, isFolder=False,
menu=menu)
@@ -196,8 +222,14 @@ def parseFolder(folder):
menu = []
menu.append((GETTEXT(30011), 'XBMC.RunPlugin(%s?mode=%d&path=%s)' %
(sys.argv[0], _REMOVEFOLDER, urllib.quote_plus(path))))
menu.append((GETTEXT(30012), 'XBMC.RunPlugin(%s?mode=%d&path=%s)' %
(sys.argv[0], _RENAMEFOLDER, urllib.quote_plus(path))))
+ menu.append((GETTEXT(30043), 'XBMC.RunPlugin(%s?mode=%d&path=%s)' %
(sys.argv[0], _THUMBFOLDER, urllib.quote_plus(path))))
+
+ folderConfig = os.path.join(path, FOLDERCFG)
+ thumbnail = getParam('ICON', folderConfig)
+ if not thumbnail:
+ thumbnail = ICON
- addDir(dir, _FOLDER, path=path, thumbnail=ICON, isFolder=True,
menu=menu)
+ addDir(dir, _FOLDER, path=path, thumbnail=thumbnail, isFolder=True,
menu=menu)
file = os.path.join(folder, FILENAME)
nmrFaves = parseFile(file, reqSep=reqSep)
@@ -207,65 +239,181 @@ def parseFolder(folder):
addSeparatorItem()
+def getParam(param, file):
+ try:
+ config = []
+ param = param.upper() + '='
+ f = open(file, 'r')
+ config = f.readlines()
+ f.close()
+ except:
+ return None
+
+ for line in config:
+ if line.startswith(param):
+ return line.split(param, 1)[-1].strip()
+ return None
+
+
+def setParam(param, value, file):
+ config = []
+ try:
+ param = param.upper() + '='
+ f = open(file, 'r')
+ config = f.readlines()
+ f.close()
+ except:
+ pass
+
+ copy = []
+ for line in config:
+ line = line.strip()
+ if (len(line) > 0) and (not line.startswith(param)):
+ copy.append(line)
+
+ copy.append(param + value)
+
+ f = open(file, 'w')
+
+ for line in copy:
+ f.write(line)
+ f.write('\n')
+ f.close()
+
+
def getText(title, text=''):
kb = xbmc.Keyboard(text, title)
kb.doModal()
if not kb.isConfirmed():
return None
- text = clean(kb.getText())
+ text = kb.getText().strip()
+
if len(text) < 1:
return None
return text
-def getFolder(title):
- default = ADDON.getAddonInfo('profile')
- folder = xbmc.translatePath(PROFILE)
+def getImage():
+ image = ''
- if not os.path.isdir(folder):
- os.makedirs(folder)
+ skin = xbmc.getSkinDir().lower()
+ icon = os.path.join(HOME, 'resources', skin, 'icons')
- folder = xbmcgui.Dialog().browse(3, title, 'files', '', False, False,
default)
- if folder == default:
- return None
+ items = ['Super Favourite']
+
+ if os.path.exists(icon):
+ f = open(icon, 'r')
+ for line in f:
+ items.append(line.strip())
+ f.close()
+
+ if (len(items) > 1) and utils.DialogYesNo(GETTEXT(30046)):
+ import imagebrowser
+ return imagebrowser.getImage(ADDONID, items)
+
+ image = xbmcgui.Dialog().browse(2,GETTEXT(30044), 'files')
+ if image and len(image) > 0:
+ return image
+
+ return ''
+
+
+def thumbFolder(path, cmd):
+ image = getImage()
+
+ if not image:
+ return False
+
+ #special case
+ if image == 'Super Favourite.png':
+ image = ''
+
+ folderConfig = os.path.join(path, FOLDERCFG)
+ setParam('ICON', image, folderConfig)
+ return True
+
+
+def thumbFave(file, cmd):
+ image = getImage()
+
+ if not image:
+ return False
+
+ fave, index, nFaves = findFave(file, cmd)
+ fave[1] = image
+
+ updateFave(file, fave)
+ return True
- return xbmc.translatePath(folder)
+
+def updateFave(file, update):
+ cmd = update[2]
+ fave, index, nFaves = findFave(file, cmd)
+
+ removeFave(file, cmd)
+
+ return insertFave(file, update, index)
+
+
+def getFolder(title):
+ return utils.GetFolder(title)
def createNewFolder(current):
- text = getText(GETTEXT(30013))
+ text = clean(getText(GETTEXT(30013)))
if not text:
- return
+ return False
folder = os.path.join(current, text)
if os.path.exists(folder):
utils.DialogOK('', GETTEXT(30014) % text)
- return
+ return False
os.mkdir(xbmc.translatePath(folder))
- refresh()
+ return True
+
+
+def changePlaybackMode(file, cmd):
+ copy = []
+ faves = favourite.getFavourites(file)
+ for fave in faves:
+ if fave[2] == cmd:
+ if cmd.startswith('PlayMedia'):
+ try: winID =
re.compile('sf_win_id=(.+?)_').search(cmd).group(1)
+ except: winID = '10025'
+ cmd = cmd.replace('PlayMedia(', 'ActivateWindow(%s,' % winID)
+ elif cmd.startswith('ActivateWindow'):
+ cmd = 'PlayMedia(' + cmd.split(',', 1)[-1]
+ fave[2] = cmd
+ copy.append(fave)
+
+ favourite.writeFavourites(file, copy)
+ return True
+
def renameFolder(path):
label = path.rsplit(os.sep, 1)[-1]
- text = getText(GETTEXT(30015) % label, label)
+ text = clean(getText(GETTEXT(30015) % label, label))
if not text:
- return
+ return False
root = path.rsplit(os.sep, 1)[0]
newName = os.path.join(root, text)
os.rename(path, newName)
- refresh()
+ return True
def removeFolder(path):
label = path.rsplit(os.sep, 1)[-1]
- if utils.DialogYesNo(GETTEXT(30016) % label, GETTEXT(30017),
GETTEXT(30018)):
- try: shutil.rmtree(path)
- except: pass
- refresh()
+ if not utils.DialogYesNo(GETTEXT(30016) % label, GETTEXT(30017),
GETTEXT(30018)):
+ return False
+
+ try: shutil.rmtree(path)
+ except: pass
+ return True
def moveFave(file, cmd):
@@ -277,18 +425,48 @@ def moveFave(file, cmd):
def findFave(file, cmd):
faves = favourite.getFavourites(file)
+ index = -1
for fave in faves:
+ index += 1
if fave[2] == cmd:
- return fave
- return None
+ return fave, index, len(faves)
+ return None, -1, 0
def shiftFave(file, cmd, up):
+ fave, index, nFaves = findFave(file, cmd)
+ max = nFaves - 1
+ if up:
+ index -= 1
+ if index < 0:
+ index = max
+ else: #down
+ index += 1
+ if index > max:
+ index = 0
+
+ removeFave(file, cmd)
+ return insertFave(file, fave, index)
+
+
+def insertFave(file, newFave, index):
+ copy = []
+ faves = favourite.getFavourites(file)
+ for fave in faves:
+ if len(copy) == index:
+ copy.append(newFave)
+ copy.append(fave)
+
+ if index >= len(copy):
+ copy.append(newFave)
+
+ favourite.writeFavourites(file, copy)
+
return True
def copyFave(file, cmd, move=False):
- copy = findFave(file, cmd)
+ copy, index, nFaves = findFave(file, cmd)
if not copy:
return
@@ -347,13 +525,17 @@ def playCommand(cmd):
cmd = cmd.replace('"', '')
cmd = cmd.replace('&', '&')
+ #if a 'Super Favourite' favourite just do it
+ #if ADDONID in cmd:
+ # return xbmc.executebuiltin(cmd)
+
if 'ActivateWindow' in cmd:
return activateWindowCommand(cmd)
- #workaraound bug in Frodo that can cause lock-up
+ #workaround bug in Frodo that can cause lock-up
#when running a script favourite
- if not GOTHAM and 'RunScript' in cmd:
- xbmc.executebuiltin('ActivateWindow(Home)')
+ #if FRODO and 'RunScript' in cmd:
+ # xbmc.executebuiltin('ActivateWindow(Home)')
xbmc.executebuiltin(cmd)
except:
@@ -363,17 +545,22 @@ def playCommand(cmd):
def activateWindowCommand(cmd):
cmds = cmd.split(',', 1)
- activate = cmds[0]+')'
+ activate = cmds[0]+',return)'
plugin = cmds[1][:-1]
- xbmc.executebuiltin(activate)
- xbmc.executebuiltin('XBMC.Container.Update(%s)' % plugin)
+ #check if it is a different window and if so activate it
+ id = str(xbmcgui.getCurrentWindowId())
+ if id not in activate:
+ xbmc.executebuiltin(activate)
+
+ xbmc.executebuiltin('Container.Update(%s)' % plugin)
def addDir(label, mode, index=-1, path = '', cmd = '', thumbnail='',
isFolder=True, menu=None):
u = sys.argv[0]
- u += '?label=' + urllib.quote_plus(label)
- u += '&mode=' + str(mode)
+
+ u += '?label=' + urllib.quote_plus(label)
+ u += '&mode=' + str(mode)
if index > -1:
u += '&index=' + str(index)
@@ -391,14 +578,14 @@ def addDir(label, mode, index=-1, path = '', cmd = '',
thumbnail='', isFolder=Tr
if not menu:
menu = []
- if isFolder and mode != _XBMC:
+ if mode != _XBMC:
addFavouriteMenuItem(menu, label, thumbnail, u)
addGlobalMenuItem(menu)
liz.addContextMenuItems(menu, replaceItems=True)
- infoLabels = {'container.folderName' : 'FANART'}
- liz.setInfo(type='default-view', infoLabels=infoLabels)
+ #infoLabels = {'container.folderName' : 'FANART'}
+ #liz.setInfo(type='default-view', infoLabels=infoLabels)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz,
isFolder=isFolder)
@@ -420,12 +607,24 @@ def get_params():
param[splitparams[0]]=splitparams[1]
return param
+
params = get_params()
-mode = -1
thepath = ''
+
try: mode = int(params['mode'])
-except: pass
+except: mode = -2
+
+try: file = urllib.unquote_plus(params['file'])
+except: file = None
+
+try: cmd = urllib.unquote_plus(params['cmd'])
+except: cmd = None
+
+try: path = urllib.unquote_plus(params['path'])
+except: path = None
+
+doRefresh = False
if mode == _XBMC:
showXBMCFolder()
@@ -433,7 +632,6 @@ if mode == _XBMC:
elif mode == _COMMAND:
- cmd = urllib.unquote_plus(params['cmd'])
playCommand(cmd)
@@ -444,64 +642,58 @@ elif mode == _FOLDER:
elif mode == _REMOVEFOLDER:
- path = urllib.unquote_plus(params['path'])
- removeFolder(path)
+ doRefresh = removeFolder(path)
elif mode == _RENAMEFOLDER:
- path = urllib.unquote_plus(params['path'])
- renameFolder(path)
+ doRefresh = renameFolder(path)
elif mode == _NEWFOLDER:
- path = urllib.unquote_plus(params['path'])
- createNewFolder(path)
+ doRefresh = createNewFolder(path)
elif mode == _MOVE:
- file = urllib.unquote_plus(params['file'])
- cmd = urllib.unquote_plus(params['cmd'])
- if moveFave(file, cmd):
- refresh()
+ doRefresh = moveFave(file, cmd)
elif mode == _COPY:
- file = urllib.unquote_plus(params['file'])
- cmd = urllib.unquote_plus(params['cmd'])
if copyFave(file, cmd):
refresh()
elif mode == _UP:
- file = urllib.unquote_plus(params['file'])
- cmd = urllib.unquote_plus(params['cmd'])
- if shiftFave(file, cmd, up=True):
- refresh()
+ doRefresh = shiftFave(file, cmd, up=True)
+
elif mode == _DOWN:
- file = urllib.unquote_plus(params['file'])
- cmd = urllib.unquote_plus(params['cmd'])
- if shiftFave(file, cmd, up=False):
- refresh()
+ doRefresh = shiftFave(file, cmd, up=False)
+
elif mode == _REMOVEFAVE:
- file = urllib.unquote_plus(params['file'])
- cmd = urllib.unquote_plus(params['cmd'])
- if removeFave(file, cmd):
- refresh()
+ doRefresh = removeFave(file, cmd)
elif mode == _RENAMEFAVE:
- file = urllib.unquote_plus(params['file'])
- cmd = urllib.unquote_plus(params['cmd'])
- if renameFave(file, cmd):
- refresh()
+ doRefresh = renameFave(file, cmd)
+
elif mode == _ADDTOXBMC:
name = urllib.unquote_plus(params['name'])
thumb = urllib.unquote_plus(params['thumb'])
- cmd = urllib.unquote_plus(params['cmd'])
addToXBMC(name, thumb, cmd)
+
+elif mode == _THUMBFAVE:
+ doRefresh = thumbFave(file, cmd)
+
+
+elif mode == _THUMBFOLDER:
+ doRefresh = thumbFolder(path, cmd)
+
+
+elif mode == _PLAYBACKMODE:
+ doRefresh = changePlaybackMode(file, cmd)
+
elif mode == _SETTINGS:
ADDON.openSettings()
@@ -512,5 +704,8 @@ elif mode == _SEPARATOR:
else:
main()
+
+if doRefresh:
+ refresh()
-xbmcplugin.endOfDirectory(int(sys.argv[1]))
\ No newline at end of file
+xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=False)
\ No newline at end of file
diff --git a/plugin.program.super.favourites/fanart.jpg
b/plugin.program.super.favourites/fanart.jpg
index 688a4c4..6f908ce 100644
Binary files a/plugin.program.super.favourites/fanart.jpg and
b/plugin.program.super.favourites/fanart.jpg differ
diff --git a/plugin.program.super.favourites/favourite.py
b/plugin.program.super.favourites/favourite.py
index c39ea8e..4b246f0 100644
--- a/plugin.program.super.favourites/favourite.py
+++ b/plugin.program.super.favourites/favourite.py
@@ -22,6 +22,43 @@ import os
import xbmc
import re
+import HTMLParser
+
+
+html_escape_table = {
+ "&": "&",
+ '"': """,
+ "'": "'",
+ ">": ">",
+ "<": "<",
+ }
+
+def escape(text):
+ return "".join(html_escape_table.get(c,c) for c in text)
+
+
+def unescape(text):
+ try:
+ return HTMLParser.HTMLParser().unescape(text)
+ except:
+ pass
+
+ newText = ''
+ ignoreNext = False
+
+ for c in text:
+ if ord(c) < 127:
+ newText += c
+ ignoreNext = False
+ elif ignoreNext:
+ ignoreNext = False
+ else:
+ newText += ' '
+ ignoreNext = True
+
+ return unescape(newText)
+
+
def getFavourites(file):
xml = '<favourites></favourites>'
if os.path.exists(file):
@@ -33,13 +70,25 @@ def getFavourites(file):
faves = re.compile('<favourite(.+?)</favourite>').findall(xml)
for fave in faves:
- name = re.compile('name="(.+?)"').findall(fave)[0]
+ fave = fave.replace('"', '&_quot_;')
+ fave = fave.replace('\'', '"')
+ fave = unescape(fave)
+
+ try: name = re.compile('name="(.+?)"').findall(fave)[0]
+ except: name = ''
try: thumb = re.compile('thumb="(.+?)"').findall(fave)[0]
except: thumb = ''
- cmd = fave.rsplit('>', 1)[-1]
- items.append([name, thumb, cmd])
+ try: cmd = fave.rsplit('>', 1)[-1]
+ except: cmd = ''
+
+ name = name.replace( '&_quot_;', '"')
+ thumb = thumb.replace('&_quot_;', '"')
+ cmd = cmd.replace( '&_quot_;', '"')
+
+ if len(cmd) > 0:
+ items.append([name, thumb, cmd])
return items
@@ -50,15 +99,18 @@ def writeFavourites(file, faves):
f.write('<favourites>')
for fave in faves:
- name = 'name="%s" ' % fave[0]
- thumb = 'thumb="%s">' % fave[1]
- cmd = fave[2]
-
- f.write('\n\t<favourite ')
- f.write(name)
- f.write(thumb)
- f.write(cmd)
- f.write('</favourite>')
+ try:
+ name = 'name="%s" ' % escape(fave[0])
+ thumb = 'thumb="%s">' % escape(fave[1])
+ cmd = escape(fave[2])
+
+ f.write('\n\t<favourite ')
+ f.write(name)
+ f.write(thumb)
+ f.write(cmd)
+ f.write('</favourite>')
+ except:
+ pass
f.write('\n</favourites>')
f.close()
\ No newline at end of file
diff --git
a/plugin.program.super.favourites/resources/language/English/strings.xml
b/plugin.program.super.favourites/resources/language/English/strings.xml
index e885006..a8f93bf 100644
--- a/plugin.program.super.favourites/resources/language/English/strings.xml
+++ b/plugin.program.super.favourites/resources/language/English/strings.xml
@@ -2,7 +2,7 @@
<strings>
<string id="30000">Super Favourites</string>
<string id="30001">Super Favourite</string>
- <string id="30004">New Super Folder</string>
+ <string id="30004">Create New Super Folder</string>
<string id="30005">Add-on settings</string>
<string id="30006">Add to XBMC favourites</string>
<string id="30007">Copy favourite</string>
@@ -37,7 +37,16 @@
<string id="30037">F10</string>
<string id="30038">F11</string>
<string id="30039">F12</string>
- <string id="30040">XBMC Favourites</string>
+ <string id="30040">Explore XBMC favourites</string>
<string id="30041">Move up</string>
<string id="30042">Move down</string>
+ <string id="30043">Choose thumbnail</string>
+ <string id="30044">Browse for image</string>
+ <string id="30046">Would you like to browse the current skin's built-in
icons?</string>
+ <string id="30047">Add to Super Favourites</string>
+ <string id="30048">Standard context menu</string>
+ <string id="30049">Super Favourites settings</string>
+ <string id="30050">Override context menu</string>
+ <string id="30051">Show separator</string>
+ <string id="30052">Change playback mode</string>
</strings>
\ No newline at end of file
diff --git a/plugin.program.super.favourites/resources/settings.xml
b/plugin.program.super.favourites/resources/settings.xml
index 072e1b4..7ed5e02 100644
--- a/plugin.program.super.favourites/resources/settings.xml
+++ b/plugin.program.super.favourites/resources/settings.xml
@@ -3,6 +3,8 @@
<category label="30022">
<setting id="SHOWNEW" label="30023" type="bool"
default="true" />
<setting id="SHOWXBMC" label="30024" type="bool"
default="true" />
+ <setting id="SHOWSEP" label="30051" type="bool"
default="true" />
+ <setting id="CONTEXT" label="30050" type="bool"
default="false" />
<setting id="HOTKEY" label="30026" type="labelenum"
lvalues="30027|30028|30029|30030|30031|30032|30033|30034|30035|30036|30037|30038|30039"/>
<setting id="VERSION" type="text" label="" default="0.0.0"
visible="false"/>
diff --git a/plugin.program.super.favourites/service.py
b/plugin.program.super.favourites/service.py
index 9a9e10b..09c8efd 100644
--- a/plugin.program.super.favourites/service.py
+++ b/plugin.program.super.favourites/service.py
@@ -24,22 +24,25 @@ utils.Verify()
import xbmc
import os
+
class MyMonitor(xbmc.Monitor):
def __init__(self):
xbmc.Monitor.__init__(self)
- self.hotkey = utils.ADDON.getSetting('HOTKEY')
+ self.hotkey = utils.ADDON.getSetting('HOTKEY')
+ self.context = utils.ADDON.getSetting('CONTEXT') == 'true'
def onSettingsChanged(self):
- hotkey = utils.ADDON.getSetting('HOTKEY')
+ hotkey = utils.ADDON.getSetting('HOTKEY')
+ context = utils.ADDON.getSetting('CONTEXT') == 'true'
- if self.hotkey == hotkey:
+ if self.hotkey == hotkey and self.context == context:
return
- self.hotkey = hotkey
+ self.hotkey = hotkey
+ self.context = context
- utils.DeleteKeymap()
- utils.VerifyKeymap()
+ utils.UpdateKeymaps()
monitor = MyMonitor()
diff --git a/plugin.program.super.favourites/utils.py
b/plugin.program.super.favourites/utils.py
index d1ce257..896b11c 100644
--- a/plugin.program.super.favourites/utils.py
+++ b/plugin.program.super.favourites/utils.py
@@ -42,25 +42,34 @@ FANART = os.path.join(HOME, 'fanart.jpg')
BLANK = os.path.join(HOME, 'resources', 'media', 'blank.png')
GETTEXT = ADDON.getLocalizedString
TITLE = GETTEXT(30000)
-KEYMAP = 'super_favourites.xml'
+
+KEYMAP_HOT = 'super_favourites_hot.xml'
+KEYMAP_MENU = 'super_favourites_menu.xml'
MAJOR, MINOR = GetXBMCVersion()
+FRODO = (MAJOR == 12) and (MINOR < 9)
GOTHAM = (MAJOR == 13) or (MAJOR == 12 and MINOR == 9)
+FILENAME = 'favourites.xml'
+FOLDERCFG = 'folder.cfg'
+
def DialogOK(line1, line2='', line3=''):
d = xbmcgui.Dialog()
d.ok(TITLE + ' - ' + VERSION, line1, line2 , line3)
-def DialogYesNo(line1, line2='', line3=''):
+def DialogYesNo(line1, line2='', line3='', noLabel=None, yesLabel=None):
d = xbmcgui.Dialog()
- return d.yesno(TITLE + ' - ' + VERSION, line1, line2 , line3) == True
+ if noLabel == None or yesLabel == None:
+ return d.yesno(TITLE + ' - ' + VERSION, line1, line2 , line3) == True
+ else:
+ return d.yesno(TITLE + ' - ' + VERSION, line1, line2 , line3, noLabel,
yesLabel) == True
def Verify():
CheckVersion()
- VerifyKeymap()
+ VerifyKeymaps()
def CheckVersion():
@@ -78,11 +87,17 @@ def CheckVersion():
if not os.path.isdir(folder):
os.makedirs(folder)
- VerifyKeymap()
-
+ VerifyKeymaps()
+
+
+def UpdateKeymaps():
+ DeleteKeymap(KEYMAP_HOT)
+ DeleteKeymap(KEYMAP_MENU)
+ VerifyKeymaps()
-def DeleteKeymap():
- path = os.path.join(xbmc.translatePath('special://userdata/keymaps'),
KEYMAP)
+
+def DeleteKeymap(map):
+ path = os.path.join(xbmc.translatePath('special://userdata/keymaps'), map)
tries = 5
while os.path.exists(path) and tries > 0:
@@ -94,22 +109,35 @@ def DeleteKeymap():
xbmc.sleep(500)
-def VerifyKeymap():
- dest = os.path.join(xbmc.translatePath('special://userdata/keymaps'),
KEYMAP)
+def VerifyKeymaps():
+ reload = False
- if os.path.exists(dest):
+ if VerifyKeymapHot(): reload = True
+ if VerifyKeymapMenu(): reload = True
+
+ if not reload:
return
+ xbmc.sleep(1000)
+ xbmc.executebuiltin('Action(reloadkeymaps)')
+
+
+def VerifyKeymapHot():
+ dest = os.path.join(xbmc.translatePath('special://userdata/keymaps'),
KEYMAP_HOT)
+
+ if os.path.exists(dest):
+ return False
+
key = ADDON.getSetting('HOTKEY').lower()
- if key not in ['f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9',
'f10', 'f11', 'f12']:
- DeleteKeymap()
- xbmc.sleep(1000)
- xbmc.executebuiltin('Action(reloadkeymaps)')
- return
-
- cmd =
'<keymap><Global><keyboard><%s>XBMC.RunAddon(plugin.program.super.favourites)</%s></keyboard></Global></keymap>'
% (key, key)
+ includeKey = key in ['f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9',
'f10', 'f11', 'f12']
+
+ if not includeKey:
+ DeleteKeymap(KEYMAP_HOT)
+ return True
+ cmd =
'<keymap><Global><keyboard><%s>XBMC.RunScript(special://home/addons/plugin.program.super.favourites/hot.py)</%s></keyboard></Global></keymap>'
% (key, key)
+
f = open(dest, mode='w')
f.write(cmd)
f.close()
@@ -122,8 +150,44 @@ def VerifyKeymap():
f.write(t)
f.close()
xbmc.sleep(1000)
-
- xbmc.executebuiltin('Action(reloadkeymaps)')
+
+ return True
+
+
+def VerifyKeymapMenu():
+ dest = os.path.join(xbmc.translatePath('special://userdata/keymaps'),
KEYMAP_MENU)
+
+ if os.path.exists(dest):
+ return False
+
+ context = ADDON.getSetting('CONTEXT') == 'true'
+
+ if not context:
+ DeleteKeymap(KEYMAP_MENU)
+ return True
+
+ src = os.path.join(HOME, 'resources', 'keymaps', KEYMAP_MENU)
+ dst = os.path.join(xbmc.translatePath('special://userdata/keymaps'),
KEYMAP_MENU)
+
+ import shutil
+ shutil.copy(src, dst)
+
+ return True
+
+
+
+def GetFolder(title):
+ default = ADDON.getAddonInfo('profile')
+ folder = xbmc.translatePath(PROFILE)
+
+ if not os.path.isdir(folder):
+ os.makedirs(folder)
+
+ folder = xbmcgui.Dialog().browse(3, title, 'files', '', False, False,
default)
+ if folder == default:
+ return None
+
+ return xbmc.translatePath(folder)
if __name__ == '__main__':
-----------------------------------------------------------------------
Summary of changes:
plugin.program.super.favourites/addon.xml | 4 +-
plugin.program.super.favourites/capture.py | 103 ++++++
plugin.program.super.favourites/changelog.txt | 19 +-
plugin.program.super.favourites/contextmenu.py | 88 +++++
plugin.program.super.favourites/default.py | 369 +++++++++++++++-----
plugin.program.super.favourites/fanart.jpg | Bin 147987 -> 391094
bytes
plugin.program.super.favourites/favourite.py | 76 ++++-
plugin.program.super.favourites/hot.py | 26 ++
plugin.program.super.favourites/imagebrowser.py | 98 ++++++
.../resources/keymaps/super_favourites_menu.xml | 79 +++++
.../resources/language/English/strings.xml | 13 +-
.../resources/media/blank.png | Bin 1283 -> 0 bytes
.../resources/settings.xml | 2 +
.../resources/skin.confluence/icons | 192 ++++++++++
.../resources/skin.re-touched/icons | 197 +++++++++++
.../resources/skins/Default/720p/contextmenu.xml | 105 ++++++
.../resources/skins/Default/720p/imagebrowser.xml | 132 +++++++
.../resources/skins/Default/media/DialogBack.png | Bin 0 -> 8551 bytes
.../Default/media/DialogCloseButton-focus.png | Bin 0 -> 5216 bytes
.../skins/Default/media/DialogCloseButton.png | Bin 0 -> 4522 bytes
.../skins/Default/media/Super Favourite.png} | Bin 44944 -> 44944 bytes
.../skins/Default/media/button-focus2.png | Bin 0 -> 24691 bytes
.../skins/Default/media/button-nofocus.png | Bin 0 -> 2935 bytes
.../resources/skins/Default/skin.xml | 8 +
plugin.program.super.favourites/service.py | 15 +-
plugin.program.super.favourites/utils.py | 104 +++++-
26 files changed, 1499 insertions(+), 131 deletions(-)
create mode 100644 plugin.program.super.favourites/capture.py
create mode 100644 plugin.program.super.favourites/contextmenu.py
create mode 100644 plugin.program.super.favourites/hot.py
create mode 100644 plugin.program.super.favourites/imagebrowser.py
create mode 100644
plugin.program.super.favourites/resources/keymaps/super_favourites_menu.xml
delete mode 100644 plugin.program.super.favourites/resources/media/blank.png
create mode 100644
plugin.program.super.favourites/resources/skin.confluence/icons
create mode 100644
plugin.program.super.favourites/resources/skin.re-touched/icons
create mode 100644
plugin.program.super.favourites/resources/skins/Default/720p/contextmenu.xml
create mode 100644
plugin.program.super.favourites/resources/skins/Default/720p/imagebrowser.xml
create mode 100644
plugin.program.super.favourites/resources/skins/Default/media/DialogBack.png
create mode 100644
plugin.program.super.favourites/resources/skins/Default/media/DialogCloseButton-focus.png
create mode 100644
plugin.program.super.favourites/resources/skins/Default/media/DialogCloseButton.png
copy plugin.program.super.favourites/{icon.png =>
resources/skins/Default/media/Super Favourite.png} (100%)
create mode 100644
plugin.program.super.favourites/resources/skins/Default/media/button-focus2.png
create mode 100644
plugin.program.super.favourites/resources/skins/Default/media/button-nofocus.png
create mode 100644
plugin.program.super.favourites/resources/skins/Default/skin.xml
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons