Skip to content

Commit

Permalink
Merge pull request #66 from Ignoble61/node-editor
Browse files Browse the repository at this point in the history
Support adding music nodes from library node editor
  • Loading branch information
marcelveldt committed Sep 18, 2015
2 parents 4eaff79 + 177a5ea commit 7df4678
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 14 additions & 0 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ def __init__(self):
if result == False:
# The item failed to add to the menu
xbmcgui.dialog().ok( __addon__.getAddonInfo( "name" ), __language__(32091) )

if self.TYPE=="addMusicNode":
# We've been sent a node from plugin.program.video.node.editor
targetDir = "library://music" + self.OPTIONS[ 0 ]

icon = "DefaultShortcut.png"
if self.OPTIONS[ 2 ] != "None":
icon = self.OPTIONS[ 2 ].decode( "utf-8" )

result = nodefunctions.NodeFunctions().addNodeToMenu( targetDir, urllib.unquote( self.OPTIONS[ 1 ] ).decode( "utf-8" ), icon, DATA, isVideo = False )

if result == False:
# The item failed to add to the menu
xbmcgui.dialog().ok( __addon__.getAddonInfo( "name" ), __language__(32091) )

if self.TYPE=="resetall":
# Tell XBMC not to try playing any media
Expand Down
14 changes: 10 additions & 4 deletions resources/lib/nodefunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def get_mediaType( self, path ):
# Functions used to add a node to the menu #
############################################

def addNodeToMenu( self, node, label, icon, DATA ):
def addNodeToMenu( self, node, label, icon, DATA, isVideo = False ):
# Get a list of all nodes within
json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Files.GetDirectory", "params": { "properties": ["title", "file", "thumbnail"], "directory": "' + node + '", "media": "files" } }')
json_query = unicode(json_query, 'utf-8', errors='ignore')
Expand Down Expand Up @@ -332,7 +332,10 @@ def addNodeToMenu( self, node, label, icon, DATA ):
xmltree.SubElement( newelement, "label2" ).text = "32024" # Custom shortcut
xmltree.SubElement( newelement, "icon" ).text = icon
xmltree.SubElement( newelement, "thumb" )
xmltree.SubElement( newelement, "action" ).text = "ActivateWindow(10025," + paths[ selected ] + ",return)"
if isVideo:
xmltree.SubElement( newelement, "action" ).text = "ActivateWindow(10025," + paths[ selected ] + ",return)"
else:
xmltree.SubElement( newelement, "action" ).text = "ActivateWindow(10502," + paths[ selected ] + ",return)"

DATA.indent( menuitems.getroot() )
path = xbmc.translatePath( os.path.join( "special://profile", "addon_data", __addonid__, "mainmenu.DATA.xml" ).encode('utf-8') )
Expand All @@ -348,7 +351,10 @@ def addNodeToMenu( self, node, label, icon, DATA ):
xmltree.SubElement( newelement, "label2" ).text = "32024" # Custom shortcut
xmltree.SubElement( newelement, "icon" ).text = item[ "thumbnail" ]
xmltree.SubElement( newelement, "thumb" )
xmltree.SubElement( newelement, "action" ).text = "ActivateWindow(10025," + item[ "file" ] + ",return)"
if isVideo:
xmltree.SubElement( newelement, "action" ).text = "ActivateWindow(10025," + item[ "file" ] + ",return)"
else:
xmltree.SubElement( newelement, "action" ).text = "ActivateWindow(10502," + item[ "file" ] + ",return)"

DATA.indent( menuitems.getroot() )
path = xbmc.translatePath( os.path.join( "special://profile", "addon_data", __addonid__, DATA.slugify( labelID ) + ".DATA.xml" ).encode('utf-8') )
Expand All @@ -360,4 +366,4 @@ def addNodeToMenu( self, node, label, icon, DATA ):
# And tell the user it all worked
xbmcgui.Dialog().ok( __addon__.getAddonInfo( "name" ), __language__(32090) )

return True
return True

0 comments on commit 7df4678

Please sign in to comment.