Safe section uuid when synching

This commit is contained in:
croneter 2019-04-27 11:17:29 +02:00
parent ab5ab966e4
commit e76fd03915
7 changed files with 100 additions and 56 deletions

View file

@ -217,6 +217,7 @@ class Movie(ItemBase):
self.plexdb.add_movie(plex_id=plex_id, self.plexdb.add_movie(plex_id=plex_id,
checksum=api.checksum(), checksum=api.checksum(),
section_id=section.id, section_id=section.id,
section_uuid=section.uuid,
kodi_id=kodi_id, kodi_id=kodi_id,
kodi_fileid=file_id, kodi_fileid=file_id,
kodi_pathid=kodi_pathid, kodi_pathid=kodi_pathid,

View file

@ -210,6 +210,7 @@ class Artist(MusicMixin, ItemBase):
self.plexdb.add_artist(plex_id, self.plexdb.add_artist(plex_id,
api.checksum(), api.checksum(),
section.id, section.id,
section.uuid,
kodi_id, kodi_id,
self.last_sync) self.last_sync)
@ -361,6 +362,7 @@ class Album(MusicMixin, ItemBase):
self.plexdb.add_album(plex_id, self.plexdb.add_album(plex_id,
api.checksum(), api.checksum(),
section.id, section.id,
section.uuid,
artist_id, artist_id,
parent_id, parent_id,
kodi_id, kodi_id,
@ -653,6 +655,7 @@ class Song(MusicMixin, ItemBase):
self.plexdb.add_song(plex_id, self.plexdb.add_song(plex_id,
api.checksum(), api.checksum(),
section.id, section.id,
section.uuid,
artist_id, artist_id,
grandparent_id, grandparent_id,
album_id, album_id,

View file

@ -279,6 +279,7 @@ class Show(TvShowMixin, ItemBase):
self.plexdb.add_show(plex_id=plex_id, self.plexdb.add_show(plex_id=plex_id,
checksum=api.checksum(), checksum=api.checksum(),
section_id=section.id, section_id=section.id,
section_uuid=section.uuid,
kodi_id=kodi_id, kodi_id=kodi_id,
kodi_pathid=kodi_pathid, kodi_pathid=kodi_pathid,
last_sync=self.last_sync) last_sync=self.last_sync)
@ -344,6 +345,7 @@ class Season(TvShowMixin, ItemBase):
self.plexdb.add_season(plex_id=plex_id, self.plexdb.add_season(plex_id=plex_id,
checksum=api.checksum(), checksum=api.checksum(),
section_id=section.id, section_id=section.id,
section_uuid=section.uuid,
show_id=show_id, show_id=show_id,
parent_id=parent_id, parent_id=parent_id,
kodi_id=kodi_id, kodi_id=kodi_id,
@ -538,6 +540,7 @@ class Episode(TvShowMixin, ItemBase):
self.plexdb.add_episode(plex_id=plex_id, self.plexdb.add_episode(plex_id=plex_id,
checksum=api.checksum(), checksum=api.checksum(),
section_id=section.id, section_id=section.id,
section_uuid=section.uuid,
show_id=show_id, show_id=show_id,
grandparent_id=grandparent_id, grandparent_id=grandparent_id,
season_id=season_id, season_id=season_id,
@ -614,6 +617,7 @@ class Episode(TvShowMixin, ItemBase):
self.plexdb.add_episode(plex_id=plex_id, self.plexdb.add_episode(plex_id=plex_id,
checksum=api.checksum(), checksum=api.checksum(),
section_id=section.id, section_id=section.id,
section_uuid=section.uuid,
show_id=show_id, show_id=show_id,
grandparent_id=grandparent_id, grandparent_id=grandparent_id,
season_id=season_id, season_id=season_id,

View file

@ -205,6 +205,7 @@ def initialize():
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER, kodi_id INTEGER,
kodi_fileid INTEGER, kodi_fileid INTEGER,
kodi_pathid INTEGER, kodi_pathid INTEGER,
@ -216,6 +217,7 @@ def initialize():
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER, kodi_id INTEGER,
kodi_pathid INTEGER, kodi_pathid INTEGER,
fanart_synced INTEGER, fanart_synced INTEGER,
@ -226,6 +228,7 @@ def initialize():
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
show_id INTEGER, show_id INTEGER,
parent_id INTEGER, parent_id INTEGER,
kodi_id INTEGER, kodi_id INTEGER,
@ -237,6 +240,7 @@ def initialize():
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
show_id INTEGER, show_id INTEGER,
grandparent_id INTEGER, grandparent_id INTEGER,
season_id INTEGER, season_id INTEGER,
@ -253,6 +257,7 @@ def initialize():
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER, kodi_id INTEGER,
last_sync INTEGER) last_sync INTEGER)
''') ''')
@ -261,6 +266,7 @@ def initialize():
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
artist_id INTEGER, artist_id INTEGER,
parent_id INTEGER, parent_id INTEGER,
kodi_id INTEGER, kodi_id INTEGER,
@ -271,6 +277,7 @@ def initialize():
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
artist_id INTEGER, artist_id INTEGER,
grandparent_id INTEGER, grandparent_id INTEGER,
album_id INTEGER, album_id INTEGER,

View file

@ -5,8 +5,8 @@ from .. import variables as v
class Movies(object): class Movies(object):
def add_movie(self, plex_id, checksum, section_id, kodi_id, kodi_fileid, def add_movie(self, plex_id, checksum, section_id, section_uuid, kodi_id,
kodi_pathid, last_sync): kodi_fileid, kodi_pathid, last_sync):
""" """
Appends or replaces an entry into the plex table for movies Appends or replaces an entry into the plex table for movies
""" """
@ -15,18 +15,20 @@ class Movies(object):
plex_id, plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
kodi_id, kodi_id,
kodi_fileid, kodi_fileid,
kodi_pathid, kodi_pathid,
fanart_synced, fanart_synced,
last_sync) last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
''' '''
self.cursor.execute( self.cursor.execute(
query, query,
(plex_id, (plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
kodi_id, kodi_id,
kodi_fileid, kodi_fileid,
kodi_pathid, kodi_pathid,
@ -39,6 +41,7 @@ class Movies(object):
plex_id INTEGER PRIMARY KEY ASC, plex_id INTEGER PRIMARY KEY ASC,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER, kodi_id INTEGER,
kodi_fileid INTEGER, kodi_fileid INTEGER,
kodi_pathid INTEGER, kodi_pathid INTEGER,
@ -61,9 +64,10 @@ class Movies(object):
'plex_id': entry[0], 'plex_id': entry[0],
'checksum': entry[1], 'checksum': entry[1],
'section_id': entry[2], 'section_id': entry[2],
'kodi_id': entry[3], 'section_uuid': entry[3],
'kodi_fileid': entry[4], 'kodi_id': entry[4],
'kodi_pathid': entry[5], 'kodi_fileid': entry[5],
'fanart_synced': entry[6], 'kodi_pathid': entry[6],
'last_sync': entry[7] 'fanart_synced': entry[7],
'last_sync': entry[8]
} }

View file

@ -5,7 +5,8 @@ from .. import variables as v
class Music(object): class Music(object):
def add_artist(self, plex_id, checksum, section_id, kodi_id, last_sync): def add_artist(self, plex_id, checksum, section_id, section_uuid, kodi_id,
last_sync):
""" """
Appends or replaces music artist entry into the plex table Appends or replaces music artist entry into the plex table
""" """
@ -14,20 +15,22 @@ class Music(object):
plex_id, plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
kodi_id, kodi_id,
last_sync) last_sync)
VALUES (?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?)
''' '''
self.cursor.execute( self.cursor.execute(
query, query,
(plex_id, (plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
kodi_id, kodi_id,
last_sync)) last_sync))
def add_album(self, plex_id, checksum, section_id, artist_id, parent_id, def add_album(self, plex_id, checksum, section_id, section_uuid, artist_id,
kodi_id, last_sync): parent_id, kodi_id, last_sync):
""" """
Appends or replaces an entry into the plex table Appends or replaces an entry into the plex table
""" """
@ -36,24 +39,27 @@ class Music(object):
plex_id, plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
artist_id, artist_id,
parent_id, parent_id,
kodi_id, kodi_id,
last_sync) last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
''' '''
self.cursor.execute( self.cursor.execute(
query, query,
(plex_id, (plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
artist_id, artist_id,
parent_id, parent_id,
kodi_id, kodi_id,
last_sync)) last_sync))
def add_song(self, plex_id, checksum, section_id, artist_id, grandparent_id, def add_song(self, plex_id, checksum, section_id, section_uuid, artist_id,
album_id, parent_id, kodi_id, kodi_pathid, last_sync): grandparent_id, album_id, parent_id, kodi_id, kodi_pathid,
last_sync):
""" """
Appends or replaces an entry into the plex table Appends or replaces an entry into the plex table
""" """
@ -62,6 +68,7 @@ class Music(object):
plex_id, plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
artist_id, artist_id,
grandparent_id, grandparent_id,
album_id, album_id,
@ -69,13 +76,14 @@ class Music(object):
kodi_id, kodi_id,
kodi_pathid, kodi_pathid,
last_sync) last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''' '''
self.cursor.execute( self.cursor.execute(
query, query,
(plex_id, (plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
artist_id, artist_id,
grandparent_id, grandparent_id,
album_id, album_id,
@ -90,6 +98,7 @@ class Music(object):
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER, kodi_id INTEGER,
last_sync INTEGER last_sync INTEGER
""" """
@ -105,6 +114,7 @@ class Music(object):
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
artist_id INTEGER, # plex_id of the parent artist artist_id INTEGER, # plex_id of the parent artist
parent_id INTEGER, # kodi_id of the parent artist parent_id INTEGER, # kodi_id of the parent artist
kodi_id INTEGER, kodi_id INTEGER,
@ -122,6 +132,7 @@ class Music(object):
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
artist_id INTEGER, # plex_id of the parent artist artist_id INTEGER, # plex_id of the parent artist
grandparent_id INTEGER, # kodi_id of the parent artist grandparent_id INTEGER, # kodi_id of the parent artist
album_id INTEGER, # plex_id of the parent album album_id INTEGER, # plex_id of the parent album
@ -146,13 +157,14 @@ class Music(object):
'plex_id': entry[0], 'plex_id': entry[0],
'checksum': entry[1], 'checksum': entry[1],
'section_id': entry[2], 'section_id': entry[2],
'artist_id': entry[3], 'section_uuid': entry[3],
'grandparent_id': entry[4], 'artist_id': entry[4],
'album_id': entry[5], 'grandparent_id': entry[5],
'parent_id': entry[6], 'album_id': entry[6],
'kodi_id': entry[7], 'parent_id': entry[7],
'kodi_pathid': entry[8], 'kodi_id': entry[8],
'last_sync': entry[9] 'kodi_pathid': entry[9],
'last_sync': entry[10]
} }
@staticmethod @staticmethod
@ -165,10 +177,11 @@ class Music(object):
'plex_id': entry[0], 'plex_id': entry[0],
'checksum': entry[1], 'checksum': entry[1],
'section_id': entry[2], 'section_id': entry[2],
'artist_id': entry[3], 'section_uuid': entry[3],
'parent_id': entry[4], 'artist_id': entry[4],
'kodi_id': entry[5], 'parent_id': entry[5],
'last_sync': entry[6] 'kodi_id': entry[6],
'last_sync': entry[7]
} }
@staticmethod @staticmethod
@ -181,8 +194,9 @@ class Music(object):
'plex_id': entry[0], 'plex_id': entry[0],
'checksum': entry[1], 'checksum': entry[1],
'section_id': entry[2], 'section_id': entry[2],
'kodi_id': entry[3], 'section_uuid': entry[3],
'last_sync': entry[4] 'kodi_id': entry[4],
'last_sync': entry[5]
} }
def album_has_songs(self, plex_id): def album_has_songs(self, plex_id):

View file

@ -5,8 +5,8 @@ from .. import variables as v
class TVShows(object): class TVShows(object):
def add_show(self, plex_id, checksum, section_id, kodi_id, kodi_pathid, def add_show(self, plex_id, checksum, section_id, section_uuid, kodi_id,
last_sync): kodi_pathid, last_sync):
""" """
Appends or replaces tv show entry into the plex table Appends or replaces tv show entry into the plex table
""" """
@ -16,22 +16,24 @@ class TVShows(object):
plex_id, plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
kodi_id, kodi_id,
kodi_pathid, kodi_pathid,
fanart_synced, fanart_synced,
last_sync) last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
''', ''',
(plex_id, (plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
kodi_id, kodi_id,
kodi_pathid, kodi_pathid,
0, 0,
last_sync)) last_sync))
def add_season(self, plex_id, checksum, section_id, show_id, parent_id, def add_season(self, plex_id, checksum, section_id, section_uuid, show_id,
kodi_id, last_sync): parent_id, kodi_id, last_sync):
""" """
Appends or replaces an entry into the plex table Appends or replaces an entry into the plex table
""" """
@ -41,23 +43,25 @@ class TVShows(object):
plex_id, plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
show_id, show_id,
parent_id, parent_id,
kodi_id, kodi_id,
fanart_synced, fanart_synced,
last_sync) last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
''', ''',
(plex_id, (plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
show_id, show_id,
parent_id, parent_id,
kodi_id, kodi_id,
0, 0,
last_sync)) last_sync))
def add_episode(self, plex_id, checksum, section_id, show_id, def add_episode(self, plex_id, checksum, section_id, section_uuid, show_id,
grandparent_id, season_id, parent_id, kodi_id, kodi_fileid, grandparent_id, season_id, parent_id, kodi_id, kodi_fileid,
kodi_fileid_2, kodi_pathid, last_sync): kodi_fileid_2, kodi_pathid, last_sync):
""" """
@ -69,6 +73,7 @@ class TVShows(object):
plex_id, plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
show_id, show_id,
grandparent_id, grandparent_id,
season_id, season_id,
@ -79,11 +84,12 @@ class TVShows(object):
kodi_pathid, kodi_pathid,
fanart_synced, fanart_synced,
last_sync) last_sync)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', ''',
(plex_id, (plex_id,
checksum, checksum,
section_id, section_id,
section_uuid,
show_id, show_id,
grandparent_id, grandparent_id,
season_id, season_id,
@ -101,6 +107,7 @@ class TVShows(object):
plex_id INTEGER PRIMARY KEY ASC, plex_id INTEGER PRIMARY KEY ASC,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
kodi_id INTEGER, kodi_id INTEGER,
kodi_pathid INTEGER, kodi_pathid INTEGER,
fanart_synced INTEGER, fanart_synced INTEGER,
@ -118,6 +125,7 @@ class TVShows(object):
plex_id INTEGER PRIMARY KEY, plex_id INTEGER PRIMARY KEY,
checksum INTEGER UNIQUE, checksum INTEGER UNIQUE,
section_id INTEGER, section_id INTEGER,
section_uuid TEXT,
show_id INTEGER, # plex_id of the parent show show_id INTEGER, # plex_id of the parent show
parent_id INTEGER, # kodi_id of the parent show parent_id INTEGER, # kodi_id of the parent show
kodi_id INTEGER, kodi_id INTEGER,
@ -147,16 +155,17 @@ class TVShows(object):
'plex_id': entry[0], 'plex_id': entry[0],
'checksum': entry[1], 'checksum': entry[1],
'section_id': entry[2], 'section_id': entry[2],
'show_id': entry[3], 'section_uuid': entry[3],
'grandparent_id': entry[4], 'show_id': entry[4],
'season_id': entry[5], 'grandparent_id': entry[5],
'parent_id': entry[6], 'season_id': entry[6],
'kodi_id': entry[7], 'parent_id': entry[7],
'kodi_fileid': entry[8], 'kodi_id': entry[8],
'kodi_fileid_2': entry[9], 'kodi_fileid': entry[9],
'kodi_pathid': entry[10], 'kodi_fileid_2': entry[10],
'fanart_synced': entry[11], 'kodi_pathid': entry[11],
'last_sync': entry[12] 'fanart_synced': entry[12],
'last_sync': entry[13]
} }
@staticmethod @staticmethod
@ -169,10 +178,11 @@ class TVShows(object):
'plex_id': entry[0], 'plex_id': entry[0],
'checksum': entry[1], 'checksum': entry[1],
'section_id': entry[2], 'section_id': entry[2],
'kodi_id': entry[3], 'section_uuid': entry[3],
'kodi_pathid': entry[4], 'kodi_id': entry[4],
'fanart_synced': entry[5], 'kodi_pathid': entry[5],
'last_sync': entry[6] 'fanart_synced': entry[6],
'last_sync': entry[7]
} }
@staticmethod @staticmethod
@ -185,11 +195,12 @@ class TVShows(object):
'plex_id': entry[0], 'plex_id': entry[0],
'checksum': entry[1], 'checksum': entry[1],
'section_id': entry[2], 'section_id': entry[2],
'show_id': entry[3], 'section_uuid': entry[3],
'parent_id': entry[4], 'show_id': entry[4],
'kodi_id': entry[5], 'parent_id': entry[5],
'fanart_synced': entry[6], 'kodi_id': entry[6],
'last_sync': entry[7] 'fanart_synced': entry[7],
'last_sync': entry[8]
} }
def season_has_episodes(self, plex_id): def season_has_episodes(self, plex_id):