How get idFile from ListItem?
#1
For example
python:
listitem = sys.listitem

How get idFile (file Id from DB) associated with this listitem ?
Reply
#2
(2019-08-27, 16:43)FreakMurderer Wrote: For example
python:
listitem = sys.listitem

How get idFile (file Id from DB) associated with this listitem ?

1) The user selects a ListItem, Kodi goes to the URL that you set up on that item.
2) Assuming the URL is a route to your own add-on (a different folder of it etc.), you can access the chosen item's DBID with the function id = xbmc.getInfoLabel('ListItem.DBID')

See more InfoLabels here:
https://kodi.wiki/view/InfoLabels#ListItem

If that DBID infolabel didn't exist, you could also have stored a custom property in that ListItem and then queried it on the next add-on execution: listitem.setProperty('FreakMurderer', 'blablabla') -> xbmc.getInfoLabel('ListItem.Property(FreakMurderer)')
Reply
#3
python:
listitem = sys.listitem
dbid = listitem.getDbid()
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#4
Thanks

I forgot to add that I do not use listitems from my plugin, I use from the kodi.core.main standard video section. Click.

 
(2019-08-27, 20:04)doko-desuka Wrote: 2) Assuming the URL is a route to your own add-on (a different folder of it etc.), you can access the chosen item's DBID with the function id = xbmc.getInfoLabel('ListItem.DBID')
Cannot Get Id. EmptyString.
 
(2019-08-27, 20:26)Lunatixz Wrote: listitem = sys.listitem
dbid = listitem.getDbid()

Code:
AttributeError: 'xbmcgui.ListItem' object has no attribute 'getDbid'

-----------------------

But I'm sure that idFile is in the database, since I was able to extract it only by working with the database and using the following commands:
python:

.....
cursor = db.execute('SELECT idPath FROM main.path WHERE strPath=?', (dirPath,))
.....
cursor.execute('SELECT idFile FROM main.files WHERE idPath=? AND strFilename=?', (folderIds[0], os.path.basename(filePath),))
......
Reply
#5
the dbid is part of the video infotag, so:
python:
listitem = sys.listitem
dbid = listitem.getVideoInfoTag().getDbid()

ref:
https://codedocs.xyz/xbmc/xbmc/group__py...4c0af53c9d
https://codedocs.xyz/xbmc/xbmc/group__py...e58a9ed966
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#6
With getVideoInfoTag also not work
leya
.....
If troubles with idFile - another question.
How get bookmark timecodes from listitem (videofile)?
Reply
#7
The call listitem.getVideoInfoTag().getDbId() should work, by this post: https://forum.kodi.tv/showthread.php?tid=234184
Reply
#8
(2019-08-28, 00:47)doko-desuka Wrote: The call listitem.getVideoInfoTag().getDbId() should work, by this post: https://forum.kodi.tv/showthread.php?tid=234184

In my case, listitem.getVideoInfoTag ().GetDbId() only works with items that have content (movies, tvshows, etc).
With regular videofiles that I need to work with (without content) - the result of this function is -1.
So. How get idFile from listitem - videofiles without content?

Update:
In addition, the listitem.getVideoInfoTag().getDbId() command returns idMovie column (if we are talking about items-movies, or idShow column - if items-tvshows, ..... ) from the database, not the idFile column that I need.
Reply
#9
What are you going to do with the dbID?
Reply
#10
(2019-08-28, 13:32)doko-desuka Wrote: What are you going to do with the dbID?
I need get bookmark timecodes from listitem-videofile (another words: column timeInSeconds in table main.bookmark ('MyVideos116.db'))
Reply
#11
Would making a Python dictionary out of (strFilename, idFile) pairs from the 'files' table of MyVideosXXX.db, then matching it with the listitem.getVideoInfoTag().getPath() work?
(Assuming the .getPath() returns the same filenames as stored the 'strFilename' column.)

Edit: or rather use an SQL query to get the file based on its path. You don't have the DbID, but you should have its path.
Reply
#12
Here my code how i get timecodes for now:

python:

..........
dbPath = os.path.join(xbmc.translatePath("special://database"), 'MyVideos116.db')
db = sqlite.connect(dbPath)
filePath = li.getPath()
dirPath = os.path.dirname(filePath) + os.sep
cursor = db.execute('SELECT timeInSeconds FROM main.bookmark WHERE idFile=(SELECT idFile FROM main.files WHERE idPath=(SELECT idPath FROM main.path WHERE strPath=?) AND strFilename=?)',(dirPath, os.path.basename(filePath),))
..........
Reply

Logout Mark Read Team Forum Stats Members Help
How get idFile from ListItem?0