Posts: 37
Joined: Apr 2008
Reputation:
0
netmgr
Junior Member
Posts: 37
Can i get the currently select library item (say from my movies) via a script?
i want to alter the keymap.xml file so that on a certain keypress whilst viewing my library it runs a script (ive done this part) the script should then be able to tell me which library item is selected, ie its filename
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
xbmc.getInfoLabel()
Link to pydocs and manual in my signature
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
that label is for what is currently playing.
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
looks like listitem.filename returns filename without the full path.
Sounds like you may want the full path? IS this correct?
Posts: 37
Joined: Apr 2008
Reputation:
0
netmgr
Junior Member
Posts: 37
i do want the full path yep, however the request returns nothing at all, full or partial.
What should i be doing to get the full path?
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
nothing, i'm testing something right now, just wondered if thats what you needed.
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
Weird unless your xbmc is out of date.
I have the new infolabels working, so if it's accepted it will work from library or files view, for music and video.
Also you would want to use ListItem.FilenameAndPath for the full path. <-new infolabel
Posts: 37
Joined: Apr 2008
Reputation:
0
netmgr
Junior Member
Posts: 37
interestingly if i use listitem.path then that actually returns the idmovie number albeit encoded into other data, for example if idnumber should be 44, if i run litsitem.path i get videodb://1/2/44/
so i can get the number i just have to play around with the string.
I just dont understand why mine is working differently to seemingly everyone elses?
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
hmm, I didn't know there was a listitem.path, i missed that, so that is what you will use in the future.
Posts: 37
Joined: Apr 2008
Reputation:
0
netmgr
Junior Member
Posts: 37
this is my new script to get the filename:
import xbmcgui, xbmc
from urllib import quote_plus
newpath=xbmc.getInfoLabel("listitem.path")
newpath = newpath.replace("videodb://1/2/","")
newpath = newpath.replace("/","")
new_sql = "SELECT path.strPath, files.strFileName FROM movie JOIN files ON files.idFile=movie.idFile JOIN path ON
files.idPath=path.idPath WHERE movie.idMovie=%s;" % (newpath)
records = xbmc.executehttpapi( "QueryVideoDatabase(%s)" % ( quote_plus( new_sql ), ) )
records=records.replace( "<field>", "" )
records=records.replace( "</field>", "" )