Need a bit of help for Kodi service to share bookmarks among many Kodi devices
#1
Hi,

I'm trying to write a Kodi service that will scan all the bookmarks.db from a kodi device and store all their contents into a common structure, the goal is to make a super bookmarks.db and store it on a shared local drive

So all my kodi device will have access to it.

Eventually it mean that any of my kodi device can resume a movie or a tv show where left viewing
My local share drive can be mapped through Samba like : smb://192.168.1.1/kodi

So far here my code.. I have issue with the opening SQL section and processing the SQL

Thanks for your suggestion 

python:
import time
import xbmc
import shutil
import os
import glob

try:
from sqlite3 import dbapi2 as database
except:
from pysqlite2 import dbapi2 as database


if __name__ == '__main__':
monitor = xbmc.Monitor()
userdata_folder = xbmc.translatePath('special://userdata/')

while not monitor.abortRequested():
# Sleep/wait for abort for 10 seconds
if monitor.waitForAbort(120):
# Abort was requested while waiting. We should exit
break

os.chdir(userdata_folder)

for root, dirs, files in os.walk(userdata_folder):
for file in files:
if file == "bookmarks.db":
#bookmarksFile = os.path.join(userdata_folder, 'bookmarks.db')
xbmc.log("hello addon! %s %s" % (time.time() ,os.path.join(root, file)), level=xbmc.LOGNOTICE)

try:
bookmarksFile = os.path.join(dataPath, 'bookmarks.db')

#os.chdir(os.path.join(root, file))
dbcon = database.connect(bookmarksFile)
dbcur = dbcon.cursor()

dbcur.execute('SELECT * FROM bookmark')

results = cursor.fetchall()

for row in results:
xbmc.log("hello addon SQL ! %s %s" % row[0] ,row[1], level=xbmc.LOGNOTICE)

dbcon,close

except:
pass
Reply
#2
FYI, bookmarks can also shared be via a centralized MySQL database (not a local SQLite database).

Then not only bookmarks are available to every connected Kodi device, but also your media collection and the watched states and resume points.
Reply
#3
(2019-10-03, 11:52)Klojum Wrote: FYI, bookmarks can also shared be via a centralized MySQL database (not a local SQLite database).

Then not only bookmarks are available to every connected Kodi device, but also your media collection and the watched states and resume points.

does it is still working with Leia ?
Reply
#4
In your code you have this line:
bookmarksFile = os.path.join(dataPath, 'bookmarks.db')

But I don't see where dataPath has been initialized.

Where does dataPath get its value?
Reply
#5
(2019-10-03, 14:18)regismaltais33 Wrote: does it is still working with Leia ?
Yep, since XBMC Dharma... Looking at it and working with it right now.
Reply

Logout Mark Read Team Forum Stats Members Help
Need a bit of help for Kodi service to share bookmarks among many Kodi devices0