Onscanfinished ?
#1
I am sure this has already been asked but when I search I get old results...

With my special features addon I want to add the ablilty auto update.. my thoughts are to have it run after the user scans movies into the kodi database.. but when attempting to use 

monitor.onScanFinished('video') I always get 'none' as a return.... 

is there a way to get the trigger for when the library is updated or cleaned so I can update and clean the database my addon makes?
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#2
Hi you can't just call the method you need to implement a class extending monitor and than the method will get called. plus you need to keep the thread alive. something like this (untestet):

class MyMonitor(xbmc.Monitor):
  def __init__(self, *args, **kwargs):
    xbmc.Monitor.__init__(self)

  def onDatabaseUpdated(self,db):
    xbmc.log('database updated')

if (__name__ == "__main__"):
  monitor = MyMonitor()
  while (not xbmc.abortRequested):
     xbmc.sleep(10000)
  del monitor

have a look here for a running implementation
https://github.com/pilluli/service.xbmc.callbacks
that's where i started of with when playing around with the monitor class
Reply
#3
Thanks for the reply but, That's what I have now ... It I added it to a working while notabort loop in the service part of my add-on that monitor the list item and set a property so I know the monitor loop is working on a .6 sec loop


So I added

Test=xbmc.monitoir().onscanfinished('video')
Xbmcgui(). notification ("",str(test))

Into the loop while in Kodi I only get

None in the notification...
I did update library and scan new content but never saw it change. I am using Krypton if it makes a difference..
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#4
Hi,

few things. Like said you can't just call the on<whatever> methods from the monitor they will always return null. Kodi calls this methods on the implementations of monitor. Monitor is a listener and creating one will will automatically hook it into kodi and kodi will send notifications/call the on<whatever> methods. It is a oberserver pattern if you want to look it up (https://en.wikipedia.org/wiki/Observer_pattern)
The abortRequested loop is only there to keep your script and the instance of the monitor alive.

In your case you would need a monitor impl like this.

class MyMonitor(xbmc.Monitor):
  def __init__(self, *args, **kwargs):
    xbmc.Monitor.__init__(self)

  def onScanFinished(self, library):
#if you only want to act on video lib updates   
    if library == "video":
      doWhatYouNeedToDo()

If you still have trouble maybe post your complete code so i can have a look at it and maybe give you a hand to help.
Reply
#5
You can see a working implementation in my addon for next-episode.net site:
https://github.com/santah/next-episode-k...service.py
https://github.com/santah/next-episode-k...py#L19-L43
Reply
#6
Thanks Roman I will give it another go this evening.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#7
(2018-01-16, 12:23)Takezo36 Wrote: if (__name__ == "__main__"):
  monitor = MyMonitor()
  while (not xbmc.abortRequested):
     xbmc.sleep(10000)
  del monitor

I know this is example code but just in case anyone implements it xmbc.sleep(10000) is a bad idea as it will delay Kodi shutdown. Instead use monitor.waitForAbort() - you won't need the while loop and Kodi will not be delayed while it waits for the add-on to wake up and exit.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#8
Roman it works perfectly... now I need to learn how to actually use the class part of python the right way and redo the whole addon lol. thanks you again... I a determined to learn this stuff one day.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply

Logout Mark Read Team Forum Stats Members Help
Onscanfinished ?0