Prepare DB for selective Plex library sync

This commit is contained in:
tomkat83 2017-02-01 10:41:44 +01:00
parent 3871af77e6
commit 16e6fc5ca4
2 changed files with 24 additions and 12 deletions

View File

@ -552,7 +552,8 @@ class LibrarySync(Thread):
view_id TEXT UNIQUE,
view_name TEXT,
kodi_type TEXT,
kodi_tagid INTEGER)
kodi_tagid INTEGER,
sync_to_kodi INTEGER)
''')
plex_db.plexcursor.execute('''
CREATE TABLE IF NOT EXISTS version(idVersion TEXT)

View File

@ -51,21 +51,26 @@ class Plex_DB_Functions():
def getAllViewInfo(self):
"""
Returns a list of dicts:
{'id': view_id, 'name': view_name, 'itemtype': kodi_type}
Returns a list of dicts for all Plex libraries:
{
'id': view_id,
'name': view_name,
'itemtype': kodi_type
'kodi_tagid'
'sync_to_kodi'
}
"""
plexcursor = self.plexcursor
views = []
query = '''
SELECT view_id, view_name, kodi_type
FROM view
'''
query = '''SELECT * FROM view'''
plexcursor.execute(query)
rows = plexcursor.fetchall()
for row in rows:
views.append({'id': row[0],
'name': row[1],
'itemtype': row[2]})
'itemtype': row[2],
'kodi_tagid': row[3],
'sync_to_kodi': row[4]})
return views
def getView_byId(self, view_id):
@ -118,17 +123,23 @@ class Plex_DB_Functions():
view = None
return view
def addView(self, view_id, view_name, kodi_type, kodi_tagid):
def addView(self, view_id, view_name, kodi_type, kodi_tagid, sync=True):
"""
Appends an entry to the view table
sync=False: Plex library won't be synced to Kodi
"""
query = '''
INSERT INTO view(
view_id, view_name, kodi_type, kodi_tagid)
VALUES (?, ?, ?, ?)
view_id, view_name, kodi_type, kodi_tagid, sync_to_kodi)
VALUES (?, ?, ?, ?, ?)
'''
self.plexcursor.execute(query,
(view_id, view_name, kodi_type, kodi_tagid))
(view_id,
view_name,
kodi_type,
kodi_tagid,
1 if sync is True else 0))
def updateView(self, view_name, kodi_tagid, view_id):
"""