fixed small error in the checksum code
This commit is contained in:
parent
8839b3b323
commit
b081f87e29
2 changed files with 91 additions and 85 deletions
|
@ -132,7 +132,7 @@ class API():
|
||||||
|
|
||||||
if item.get("Etag") != None:
|
if item.get("Etag") != None:
|
||||||
checksum = item.get("Etag")
|
checksum = item.get("Etag")
|
||||||
userData = item.get("UserData")
|
userData = item.get("UserData")
|
||||||
if(userData != None):
|
if(userData != None):
|
||||||
checksum += str(userData.get("Played"))
|
checksum += str(userData.get("Played"))
|
||||||
checksum += str(userData.get("IsFavorite"))
|
checksum += str(userData.get("IsFavorite"))
|
||||||
|
|
|
@ -504,100 +504,106 @@ class LibrarySync():
|
||||||
WriteKodiMusicDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
WriteKodiMusicDB().deleteItemFromKodiLibrary(kodiId, connection, cursor)
|
||||||
|
|
||||||
def IncrementalSync(self, itemList):
|
def IncrementalSync(self, itemList):
|
||||||
#this will only perform sync for items received by the websocket
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
|
||||||
dbSyncIndication = addon.getSetting("dbSyncIndication") == "true"
|
|
||||||
WINDOW.setProperty("SyncDatabaseRunning", "true")
|
|
||||||
|
|
||||||
#show the progress dialog
|
startupDone = WINDOW.getProperty("startup") == "done"
|
||||||
pDialog = None
|
|
||||||
if (dbSyncIndication):
|
|
||||||
pDialog = xbmcgui.DialogProgressBG()
|
|
||||||
pDialog.create('Emby for Kodi', 'Performing incremental sync...')
|
|
||||||
|
|
||||||
connection = utils.KodiSQL("video")
|
#only perform incremental scan when full scan is completed
|
||||||
cursor = connection.cursor()
|
if startupDone:
|
||||||
|
|
||||||
try:
|
#this will only perform sync for items received by the websocket
|
||||||
#### PROCESS MOVIES ####
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
views = ReadEmbyDB().getCollections("movies")
|
dbSyncIndication = addon.getSetting("dbSyncIndication") == "true"
|
||||||
for view in views:
|
WINDOW.setProperty("SyncDatabaseRunning", "true")
|
||||||
allEmbyMovies = ReadEmbyDB().getMovies(view.get('id'), itemList)
|
|
||||||
for item in allEmbyMovies:
|
|
||||||
|
|
||||||
if not item.get('IsFolder'):
|
#show the progress dialog
|
||||||
WriteKodiVideoDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
pDialog = None
|
||||||
|
if (dbSyncIndication):
|
||||||
|
pDialog = xbmcgui.DialogProgressBG()
|
||||||
|
pDialog.create('Emby for Kodi', 'Performing incremental sync...')
|
||||||
|
|
||||||
|
connection = utils.KodiSQL("video")
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
|
try:
|
||||||
|
#### PROCESS MOVIES ####
|
||||||
|
views = ReadEmbyDB().getCollections("movies")
|
||||||
|
for view in views:
|
||||||
|
allEmbyMovies = ReadEmbyDB().getMovies(view.get('id'), itemList)
|
||||||
|
for item in allEmbyMovies:
|
||||||
|
|
||||||
|
if not item.get('IsFolder'):
|
||||||
|
WriteKodiVideoDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||||
|
|
||||||
|
|
||||||
#### PROCESS BOX SETS #####
|
#### PROCESS BOX SETS #####
|
||||||
boxsets = ReadEmbyDB().getBoxSets()
|
boxsets = ReadEmbyDB().getBoxSets()
|
||||||
|
|
||||||
for boxset in boxsets:
|
for boxset in boxsets:
|
||||||
boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"])
|
boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"])
|
||||||
WriteKodiVideoDB().addBoxsetToKodiLibrary(boxset,connection, cursor)
|
WriteKodiVideoDB().addBoxsetToKodiLibrary(boxset,connection, cursor)
|
||||||
|
|
||||||
for boxsetMovie in boxsetMovies:
|
for boxsetMovie in boxsetMovies:
|
||||||
WriteKodiVideoDB().updateBoxsetToKodiLibrary(boxsetMovie,boxset, connection, cursor)
|
WriteKodiVideoDB().updateBoxsetToKodiLibrary(boxsetMovie,boxset, connection, cursor)
|
||||||
|
|
||||||
|
|
||||||
#### PROCESS TV SHOWS ####
|
#### PROCESS TV SHOWS ####
|
||||||
views = ReadEmbyDB().getCollections("tvshows")
|
views = ReadEmbyDB().getCollections("tvshows")
|
||||||
for view in views:
|
for view in views:
|
||||||
allEmbyTvShows = ReadEmbyDB().getTvShows(view.get('id'),itemList)
|
allEmbyTvShows = ReadEmbyDB().getTvShows(view.get('id'),itemList)
|
||||||
for item in allEmbyTvShows:
|
for item in allEmbyTvShows:
|
||||||
if item.get('IsFolder') and item.get('RecursiveItemCount') != 0:
|
if item.get('IsFolder') and item.get('RecursiveItemCount') != 0:
|
||||||
kodiId = WriteKodiVideoDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
kodiId = WriteKodiVideoDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
|
||||||
|
|
||||||
#### PROCESS EPISODES ######
|
#### PROCESS EPISODES ######
|
||||||
for item in itemList:
|
|
||||||
|
|
||||||
MBitem = ReadEmbyDB().getItem(item)
|
|
||||||
if MBitem["Type"] == "Episode":
|
|
||||||
|
|
||||||
#get the tv show
|
|
||||||
cursor.execute("SELECT kodi_id FROM emby WHERE media_type='tvshow' AND emby_id=?", (MBitem["SeriesId"],))
|
|
||||||
result = cursor.fetchone()
|
|
||||||
if result:
|
|
||||||
kodi_show_id = result[0]
|
|
||||||
else:
|
|
||||||
kodi_show_id = None
|
|
||||||
|
|
||||||
if kodi_show_id:
|
|
||||||
WriteKodiVideoDB().addOrUpdateEpisodeToKodiLibrary(MBitem["Id"], kodi_show_id, connection, cursor)
|
|
||||||
|
|
||||||
#### PROCESS MUSICVIDEOS ####
|
|
||||||
allEmbyMusicvideos = ReadEmbyDB().getMusicVideos(itemList)
|
|
||||||
for item in allEmbyMusicvideos:
|
|
||||||
if not item.get('IsFolder'):
|
|
||||||
WriteKodiVideoDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor)
|
|
||||||
|
|
||||||
### commit all changes to database ###
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
|
|
||||||
### PROCESS MUSIC LIBRARY ###
|
|
||||||
if performMusicSync:
|
|
||||||
connection = utils.KodiSQL("music")
|
|
||||||
cursor = connection.cursor()
|
|
||||||
for item in itemList:
|
for item in itemList:
|
||||||
|
|
||||||
MBitem = ReadEmbyDB().getItem(item)
|
MBitem = ReadEmbyDB().getItem(item)
|
||||||
if MBitem["Type"] == "MusicArtist":
|
if MBitem["Type"] == "Episode":
|
||||||
WriteKodiMusicDB().addOrUpdateArtistToKodiLibrary(MBitem["Id"],connection, cursor)
|
|
||||||
if MBitem["Type"] == "MusicAlbum":
|
#get the tv show
|
||||||
WriteKodiMusicDB().addOrUpdateAlbumToKodiLibraryToKodiLibrary(MBitem["Id"],connection, cursor)
|
cursor.execute("SELECT kodi_id FROM emby WHERE media_type='tvshow' AND emby_id=?", (MBitem["SeriesId"],))
|
||||||
if MBitem["Type"] == "Audio":
|
result = cursor.fetchone()
|
||||||
WriteKodiMusicDB().addOrUpdateSongToKodiLibraryToKodiLibrary(MBitem["Id"],connection, cursor)
|
if result:
|
||||||
|
kodi_show_id = result[0]
|
||||||
|
else:
|
||||||
|
kodi_show_id = None
|
||||||
|
|
||||||
|
if kodi_show_id:
|
||||||
|
WriteKodiVideoDB().addOrUpdateEpisodeToKodiLibrary(MBitem["Id"], kodi_show_id, connection, cursor)
|
||||||
|
|
||||||
|
#### PROCESS MUSICVIDEOS ####
|
||||||
|
allEmbyMusicvideos = ReadEmbyDB().getMusicVideos(itemList)
|
||||||
|
for item in allEmbyMusicvideos:
|
||||||
|
if not item.get('IsFolder'):
|
||||||
|
WriteKodiVideoDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor)
|
||||||
|
|
||||||
|
### commit all changes to database ###
|
||||||
connection.commit()
|
connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
finally:
|
### PROCESS MUSIC LIBRARY ###
|
||||||
|
if performMusicSync:
|
||||||
|
connection = utils.KodiSQL("music")
|
||||||
|
cursor = connection.cursor()
|
||||||
|
for item in itemList:
|
||||||
|
MBitem = ReadEmbyDB().getItem(item)
|
||||||
|
if MBitem["Type"] == "MusicArtist":
|
||||||
|
WriteKodiMusicDB().addOrUpdateArtistToKodiLibrary(MBitem["Id"],connection, cursor)
|
||||||
|
if MBitem["Type"] == "MusicAlbum":
|
||||||
|
WriteKodiMusicDB().addOrUpdateAlbumToKodiLibraryToKodiLibrary(MBitem["Id"],connection, cursor)
|
||||||
|
if MBitem["Type"] == "Audio":
|
||||||
|
WriteKodiMusicDB().addOrUpdateSongToKodiLibraryToKodiLibrary(MBitem["Id"],connection, cursor)
|
||||||
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
|
||||||
xbmc.executebuiltin("UpdateLibrary(video)")
|
finally:
|
||||||
WINDOW.setProperty("SyncDatabaseRunning", "false")
|
|
||||||
|
|
||||||
#close the progress dialog
|
xbmc.executebuiltin("UpdateLibrary(video)")
|
||||||
if(pDialog != None):
|
WINDOW.setProperty("SyncDatabaseRunning", "false")
|
||||||
pDialog.close()
|
|
||||||
|
#close the progress dialog
|
||||||
|
if(pDialog != None):
|
||||||
|
pDialog.close()
|
||||||
|
|
||||||
def ShouldStop(self):
|
def ShouldStop(self):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue