get selected libary item filename
#1
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
Reply
#2
xbmc.getInfoLabel()

Link to pydocs and manual in my signature
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
Nuka1195 Wrote:xbmc.getInfoLabel()

Link to pydocs and manual in my signature

Ah ha, I was using InfoTagVideo() obviously on the wrong track, cheers
Reply
#4
that label is for what is currently playing.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#5
no joy with this, im using:

label1 = xbmc.getInfoLabel("listitem.filename")

the label returned is blank.

I can use other labels like listitem.title, which works fine

Is there a problem with asking the filename in a library view?


Nuka1195 Wrote:xbmc.getInfoLabel()

Link to pydocs and manual in my signature
Reply
#6
looks like listitem.filename returns filename without the full path.

Sounds like you may want the full path? IS this correct?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#7
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?
Reply
#8
nothing, i'm testing something right now, just wondered if thats what you needed.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#9
ok, when i run from library, it returns the idMovie column of the database. Are you sure your getting nothing?

One way to return this strictly from python, would be to use an sql statement and httpapi to get the resulting path and filename. But I'm testing a new infolabel, with a correction for library. If this works then it will need to be approved before commiting and you'll need to compile your own or wait for the next t3ch.

If you want to just use the httpapi.

PHP Code:
import xbmc
from urllib import quote_plus
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;" % ( xbmc.getInfoLabel"ListItem.filename" ), )
records xbmc.executehttpapi"QueryVideoDatabase(%s)" % ( quote_plusnew_sql ), ) )
print 
records.replace"<field>""" ).replace"</field>""" 
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#10
yes im getting nothing

When i run your alternate sql script im getting a sql error and when i look into it it seems that 'movie.idmovie=' and then it just stops so its not getting anything from xbmc.getInfoLabel( "ListItem.filename" )

thoughts?

Nuka1195 Wrote:ok, when i run from library, it returns the idMovie column of the database. Are you sure your getting nothing?
Reply
#11
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
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#12
Im using March 9th 2008 build, is this too old?


Nuka1195 Wrote: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
Reply
#13
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?
Reply
#14
hmm, I didn't know there was a listitem.path, i missed that, so that is what you will use in the future.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#15
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>", "" )
Reply

Logout Mark Read Team Forum Stats Members Help
get selected libary item filename0