how to use field in MyVideosxxx.db
#1
my purpose is to show the list of all the date where i saw a movie
I have 3 options (at least)
    1) create a database with a table with movie/date_seen
    2) create a filed in a existing table (say files)
    3) use a field not use in movie table (say c04) or in view movie_view and  concatenate all the date for a movie (something like c04[movie]= yy1/mm1/dd1;yy2/mm2/dd2;... )

https://kodi.wiki/view/Databases/MyVideos#movie

for the moment, this database or field are fill with a sql script outside kodi.

it seen to me that the simpliest job is 3)
my question here is how to see the result in a skin (say estuary)

I have seen that i can see (for example) LastPlayed date  in "dialogvideoinfo.xml
<param name="label" value="Derniere vue: $INFO[ListItem.LastPlayed]" />

i would like to know how  to "listitem" c04 ?   something like $INFO[ListItem.c04] !!
or use the external table ?
Reply
#2
I'm pretty sure you can't use an infolabel to just randomly access fields from the database.  I would strongly discourage you from rewriting the Kodi database, as whatever you do could either have adverse affects on other parts of Kodi (you can't assume just because a field is blank that it isn't used) or could be deleted/overwritten during a Kodi database upgrade.  You would probably need to look at developing an addon that would have it's own datastore that you could match against the Kodi database (all movies have a unique identifier, so you could do it that way).  You should also probably look at either using JSON or the native Python APIs to access stuff in the Kodi database rather than reading it directly:

https://kodi.wiki/view/JSON-RPC_API/v10

https://codedocs.xyz/xbmc/xbmc/group__python.html
Reply
#3
ok, so the best practice is to use my first proposal  :  1) create a database with a table with movie/date_seen
but once it's done, how can i saw the results inside a skin ?
Reply
#4
(2020-08-18, 22:35)michelb2 Wrote: ok, so the best practice is to use my first proposal  :  1) create a database with a table with movie/date_seen
but once it's done, how can i saw the results inside a skin ?
You have two choices:

1- have the addon populate skin INFOLABELS (that's an entire process all it's own) that you could then read using the INFOLABEL tags in the skin. That requires you to either create a new skin or modify an existing one.
2- Have the addon generate a context menu item (that would let you pick the movie and then run the addon from the context menu and know which movie to find) and then have a small amount of XML for the addon to show the information. Building XML files for an addon is mostly the same as doing it for a skin.

The advantage to #2 is that it is skin independent.  Both will require you to have a pretty good understanding of the Kodi Python API and/or JSON calls I referenced in my first reply. Basically these are not Into to Kodi Addons 101 level things.  I'm not saying don't do it, but do expect it to take awhile if you've never done any work developing Kodi addons before.

Here's some info on developing Kodi addons to get you started:

https://kodi.wiki/view/Add-on_development
Reply
#5
ok,
first step trying to use a python script (for estuary)
please forgive me , it's my first try in python kodi, script kodi, .... and i don't write english very well (as you can see)

add
in  e:\kodi\addons\skin.estuary\addon.xml

<extension point="kodi.context.item">
  <menu id="kodi.core.main">
    <item library="0mbtest.py">
      <label>ceci est un test mb</label>
      <visible>true</visible>
    </item>
  </menu>
</extension>

and in  e:\kodi\addons\skin.estuary\0mbtest.py

import sys
import xbmcgui
if __name__ == '__main__':
    message = "Clicked on '{}'".format(sys.listitem.getLabel())
    xbmcgui.Dialog().notification("Hello context items!", message)


by the way in this example  in  https://kodi.wiki/view/Context_Item_Add-ons  i  have to change "import xmbc" to "import xbmcgui"

and that's ok (except when the rightclick is already used like in  dialogvideoinfo.xml where the click return to the upside menu. Otherwhise  the right popup appears.
i can now continue trying to view info of my own database.
Reply
#6
here is my python code to display a notification with the right info.
my next step is to insert it inside the skin and not in a popup
any help would be appreciate !
(btw how to insert file in the forum or how to hide/unhide the code)

import sys
import xbmcgui
import sqlite3

if __name__ == '__main__':
titre=''.join(sys.listitem.getLabel())
message = "'{}'".format(titre)
xbmcgui.Dialog().notification("Recherche", message)

try:
conn = sqlite3.connect('e:/kodi/portable_data/userdata/Database/datesvu.db')
cur = conn.cursor()
rq="select datevu from liste_dates where strfilename like ('%" +titre + "%')"
result = cur.execute(rq)
rows=cur.fetchall()
b=''
for row in rows:
b = b + ''.join(row)+";"
xbmcgui.Dialog().notification(titre, b)
#conn.commit()
conn.close()
except Exception as e:
mes="exception:"+str(e) + " Error on line {}".format(sys.exc_info()[-1].tb_lineno)
xbmcgui.Dialog().notification(message, mes)
Reply
#7
@michelb2 click the </> icon in the bar above where you enter your reply.  The forum will ask you for the syntax (in your case python) and then paste your code between the two boxes that appear.  Magically, it will then look like this

python:
import sys
import xbmcgui
import sqlite3

if __name__ == '__main__':
titre=''.join(sys.listitem.getLabel())
message = "'{}'".format(titre)
xbmcgui.Dialog().notification("Recherche", message)

try:
conn = sqlite3.connect('e:/kodi/portable_data/userdata/Database/datesvu.db')
cur = conn.cursor()
rq="select datevu from liste_dates where strfilename like ('%" +titre + "%')"
result = cur.execute(rq)
rows=cur.fetchall()
b=''
for row in rows:
b = b + ''.join(row)+";"
xbmcgui.Dialog().notification(titre, b)
#conn.commit()
conn.close()
except Exception as e:
mes="exception:"+str(e) + " Error on line {}".format(sys.exc_info()[-1].tb_lineno)
xbmcgui.Dialog().notification(message, mes)

You can also use https://paste.kodi.tv/ and post a link to a paste you have saved there if the code is more than a few lines. 

You could get the output into a skin by using
python:
WINDOW = xbmcgui.Window(windowid)
WINDOW.SetProperty("propertyname", value)

and then read it in a skin with

xml:
$INFO[Window(windowid).Property(propertyname)]

Put that in a label control as the label and if your script has set a value it will be displayed by the label control.
Learning Linux the hard way !!
Reply
#8
thank's for the tips to include code
i try your help
python:
windowID = xbmcgui.getCurrentWindowId()
WINDOW = xbmcgui.Window(windowID)
WINDOW.SetProperty("propertyname", b)

but the answer is
window object has no attribute SetProperty
Reply
#9
(2020-08-19, 19:12)michelb2 Wrote: thank's for the tips to include code
i try your help
python:
windowID = xbmcgui.getCurrentWindowId()
WINDOW = xbmcgui.Window(windowID)
WINDOW.SetProperty("propertyname", b)

but the answer is
window object has no attribute SetProperty
rectif : xbmcgui.window object has no attribute SetProperty
Reply
#10
(2020-08-19, 19:15)michelb2 Wrote:
(2020-08-19, 19:12)michelb2 Wrote: thank's for the tips to include code
i try your help
python:
windowID = xbmcgui.getCurrentWindowId()
WINDOW = xbmcgui.Window(windowID)
WINDOW.SetProperty("propertyname", b)

but the answer is
window object has no attribute SetProperty
rectif : xbmcgui.window object has no attribute SetProperty

First letter should be lowercase - should be WINDOW.setProperty("propertyname", b)

See python module methods here:
https://codedocs.xyz/AlwinEsch/kodi/grou...eedded7b3e
Arctic Fuse - Alpha now available. Support me on Ko-fi.
Reply
#11
ok thanks
Reply
#12
The deal is to know all the date where i saw a movie (database datesvu.db is fill outside kodi) and saw the answers in dialogvideoinfo window (in estuary skin)

Thank you for all your previous help.
If someone is interested 
my code (not very clean but works, any help to improve it is welcome)

create a database  datesvu.db into special://database/   path  (e:\kodi\portable_data\userdata\Database\datesvu.db)
python:

CREATE TABLE "liste_dates" (
    "strfilename"    TEXT,
    "datevu"    TEXT
)

in dialogvideoinfo.xml, at the beginning just after the fisrt <onload>
add
python:

   <onload>RunScript(special://skin/0mbtest.py)</onload>
after a line like <param name="visible" value="!String.IsEmpty(ListItem.PlayCount)" />
add
python:

                <param name="altlabel" value="Liste dates vu: $INFO[Window(10000).Property(propertyname)]" />
create a python script and put it in the root of your skin (e:\kodi\addons\skin.estuary\0mbtest.py )
python:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import xbmc
import xbmcgui
import sqlite3
import re

if __name__ == '__main__':
    #t0=xbmc.getInfoLabel('ListItem.Title')+" ("+xbmc.getInfoLabel('ListItem.Year')+")"
    t0=xbmc.getInfoLabel('ListItem.FileName')
    #t0=re.sub(r'\.\w{3}','',t0)
    t0=re.sub(r'(?:part\d{1}\s?)?\.\w{3,4}(?:\.disc)?$','',t0)                                # suppress .extension.disc if exists in filename
    titre=''.join(t0)
  try:
    database=xbmc.translatePath('special://database/datesvu.db')
    conn = sqlite3.connect(database)
    cur = conn.cursor()
    rq='select datevu from liste_dates where strfilename like ("%' +titre + '%") order by datevu desc'
    result = cur.execute(rq)
    rows=cur.fetchall()
    b=''
    for row in rows:
        a=''.join(row)
        try:
            b0 = re.sub(r"(\d{4})-(\d{2})-(\d{2}).*", "\\3/\\2/\\1", a, 0, re.MULTILINE)            # french date format
        except:
            b0 = a
        b = b + b0+"; "
    xbmcgui.Dialog().notification(titre, b,'',1000)
    conn.close()
    #windowID = xbmcgui.getCurrentWindowId()
    #xbmcgui.Dialog().notification("test", str(windowID))
    windowID=10000                                                                                    # home id
    WINDOW = xbmcgui.Window(windowID)
    WINDOW.setProperty('propertyname', str(b))
except Exception as e:
    mes="exception:"+str(e) + " Error on line {}".format(sys.exc_info()[-1].tb_lineno)
    xbmcgui.Dialog().notification(titre, mes)
Reply

Logout Mark Read Team Forum Stats Members Help
how to use field in MyVideosxxx.db0