fixed small error in the checksum code

This commit is contained in:
Marcel van der Veldt 2015-05-08 00:06:49 +02:00
parent 8839b3b323
commit b081f87e29
2 changed files with 91 additions and 85 deletions

View file

@ -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"))

View file

@ -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: #show the progress dialog
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 #####
boxsets = ReadEmbyDB().getBoxSets()
for boxset in boxsets:
boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"])
WriteKodiVideoDB().addBoxsetToKodiLibrary(boxset,connection, cursor)
if not item.get('IsFolder'): for boxsetMovie in boxsetMovies:
WriteKodiVideoDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title')) WriteKodiVideoDB().updateBoxsetToKodiLibrary(boxsetMovie,boxset, connection, cursor)
#### PROCESS BOX SETS ##### #### PROCESS TV SHOWS ####
boxsets = ReadEmbyDB().getBoxSets() views = ReadEmbyDB().getCollections("tvshows")
for view in views:
for boxset in boxsets: allEmbyTvShows = ReadEmbyDB().getTvShows(view.get('id'),itemList)
boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"]) for item in allEmbyTvShows:
WriteKodiVideoDB().addBoxsetToKodiLibrary(boxset,connection, cursor) if item.get('IsFolder') and item.get('RecursiveItemCount') != 0:
kodiId = WriteKodiVideoDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
for boxsetMovie in boxsetMovies:
WriteKodiVideoDB().updateBoxsetToKodiLibrary(boxsetMovie,boxset, connection, cursor) #### PROCESS EPISODES ######
#### PROCESS TV SHOWS ####
views = ReadEmbyDB().getCollections("tvshows")
for view in views:
allEmbyTvShows = ReadEmbyDB().getTvShows(view.get('id'),itemList)
for item in allEmbyTvShows:
if item.get('IsFolder') and item.get('RecursiveItemCount') != 0:
kodiId = WriteKodiVideoDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title'))
#### 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()
finally:
xbmc.executebuiltin("UpdateLibrary(video)")
WINDOW.setProperty("SyncDatabaseRunning", "false")
xbmc.executebuiltin("UpdateLibrary(video)") #close the progress dialog
WINDOW.setProperty("SyncDatabaseRunning", "false") if(pDialog != None):
pDialog.close()
#close the progress dialog
if(pDialog != None):
pDialog.close()
def ShouldStop(self): def ShouldStop(self):