diff --git a/resources/lib/KodiMonitor.py b/resources/lib/KodiMonitor.py index a9104355..8e3a439c 100644 --- a/resources/lib/KodiMonitor.py +++ b/resources/lib/KodiMonitor.py @@ -9,7 +9,7 @@ import xbmcaddon import json import Utils as utils -from WriteKodiDB import WriteKodiDB +from WriteKodiVideoDB import WriteKodiVideoDB from ReadKodiDB import ReadKodiDB from LibrarySync import LibrarySync from PlayUtils import PlayUtils @@ -46,7 +46,7 @@ class Kodi_Monitor(xbmc.Monitor): if (playcount != None) and (prop != "true"): WINDOW.setProperty("Played%s%s" % (type,item), "true") utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2) - WriteKodiDB().updatePlayCountFromKodi(item, type, playcount) + WriteKodiVideoDB().updatePlayCountFromKodi(item, type, playcount) self.clearProperty(type,item) diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index 1f9a493f..9c47615d 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -21,7 +21,7 @@ import Utils as utils from DownloadUtils import DownloadUtils from ReadEmbyDB import ReadEmbyDB from ReadKodiDB import ReadKodiDB -from WriteKodiDB import WriteKodiDB +from WriteKodiVideoDB import WriteKodiVideoDB from VideoNodes import VideoNodes addondir = xbmc.translatePath(xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('profile')) @@ -142,10 +142,10 @@ class LibrarySync(): kodiMovie = kodimovie if kodiMovie == None: - WriteKodiDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title')) + WriteKodiVideoDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title')) else: if kodiMovie[2] != API().getChecksum(item): - WriteKodiDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title')) + WriteKodiVideoDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title')) @@ -163,12 +163,12 @@ class LibrarySync(): if(self.ShouldStop()): return False boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"]) - WriteKodiDB().addBoxsetToKodiLibrary(boxset,connection, cursor) + WriteKodiVideoDB().addBoxsetToKodiLibrary(boxset,connection, cursor) for boxsetMovie in boxsetMovies: if(self.ShouldStop()): return False - WriteKodiDB().updateBoxsetToKodiLibrary(boxsetMovie,boxset, connection, cursor) + WriteKodiVideoDB().updateBoxsetToKodiLibrary(boxsetMovie,boxset, connection, cursor) utils.logMsg("Sync Movies", "BoxSet Sync Finished", 1) @@ -177,7 +177,7 @@ class LibrarySync(): for kodiId in allKodiMovieIds: if not kodiId in allEmbyMovieIds: WINDOW.setProperty(kodiId,"deleted") - WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor) + WriteKodiVideoDB().deleteItemFromKodiLibrary(kodiId, connection, cursor) ### commit all changes to database ### connection.commit() @@ -216,17 +216,17 @@ class LibrarySync(): kodiVideo = kodivideo if kodiVideo == None: - WriteKodiDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor) + WriteKodiVideoDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor) else: if kodiVideo[2] != API().getChecksum(item): - WriteKodiDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor) + WriteKodiVideoDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor) #### PROCESS DELETES ##### allEmbyMusicvideoIds = set(allEmbyMusicvideoIds) for kodiId in allKodiMusicvideoIds: if not kodiId in allEmbyMusicvideoIds: WINDOW.setProperty(kodiId,"deleted") - WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor) + WriteKodiVideoDB().deleteItemFromKodiLibrary(kodiId, connection, cursor) ### commit all changes to database ### connection.commit() @@ -271,11 +271,11 @@ class LibrarySync(): if kodiShow == None: # Tv show doesn't exist in Kodi yet so proceed and add it - WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title')) + WriteKodiVideoDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title')) else: # If there are changes to the item, perform a full sync of the item if kodiShow[2] != API().getChecksum(item): - WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title')) + WriteKodiVideoDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title')) #### PROCESS EPISODES ###### self.EpisodesFullSync(connection,cursor,item["Id"]) @@ -285,7 +285,7 @@ class LibrarySync(): for kodiId in allKodiTvShowIds: if not kodiId in allEmbyTvShowIds: WINDOW.setProperty(kodiId,"deleted") - WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor) + WriteKodiVideoDB().deleteItemFromKodiLibrary(kodiId, connection, cursor) ### commit all changes to database ### connection.commit() @@ -323,18 +323,18 @@ class LibrarySync(): if kodiEpisode == None: # Episode doesn't exist in Kodi yet so proceed and add it - WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodiShowId, connection, cursor) + WriteKodiVideoDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodiShowId, connection, cursor) else: # If there are changes to the item, perform a full sync of the item if kodiEpisode[2] != API().getChecksum(item): - WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodiShowId, connection, cursor) + WriteKodiVideoDB().addOrUpdateEpisodeToKodiLibrary(item["Id"], kodiShowId, connection, cursor) #### EPISODES: PROCESS DELETES ##### allEmbyEpisodeIds = set(allEmbyEpisodeIds) for kodiId in allKodiEpisodeIds: if (not kodiId in allEmbyEpisodeIds): WINDOW.setProperty(kodiId,"deleted") - WriteKodiDB().deleteItemFromKodiLibrary(kodiId, connection, cursor) + WriteKodiVideoDB().deleteItemFromKodiLibrary(kodiId, connection, cursor) def IncrementalSync(self, itemList): @@ -360,7 +360,7 @@ class LibrarySync(): for item in allEmbyMovies: if not item.get('IsFolder'): - WriteKodiDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title')) + WriteKodiVideoDB().addOrUpdateMovieToKodiLibrary(item["Id"],connection, cursor, view.get('title')) #### PROCESS BOX SETS ##### @@ -368,10 +368,10 @@ class LibrarySync(): for boxset in boxsets: boxsetMovies = ReadEmbyDB().getMoviesInBoxSet(boxset["Id"]) - WriteKodiDB().addBoxsetToKodiLibrary(boxset,connection, cursor) + WriteKodiVideoDB().addBoxsetToKodiLibrary(boxset,connection, cursor) for boxsetMovie in boxsetMovies: - WriteKodiDB().updateBoxsetToKodiLibrary(boxsetMovie,boxset, connection, cursor) + WriteKodiVideoDB().updateBoxsetToKodiLibrary(boxsetMovie,boxset, connection, cursor) #### PROCESS TV SHOWS #### @@ -380,7 +380,7 @@ class LibrarySync(): allEmbyTvShows = ReadEmbyDB().getTvShows(view.get('id'),itemList) for item in allEmbyTvShows: if item.get('IsFolder') and item.get('RecursiveItemCount') != 0: - kodiId = WriteKodiDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title')) + kodiId = WriteKodiVideoDB().addOrUpdateTvShowToKodiLibrary(item["Id"],connection, cursor, view.get('title')) #### PROCESS EPISODES ###### for item in itemList: @@ -397,13 +397,13 @@ class LibrarySync(): kodi_show_id = None if kodi_show_id: - WriteKodiDB().addOrUpdateEpisodeToKodiLibrary(MBitem["Id"], kodi_show_id, connection, cursor) + WriteKodiVideoDB().addOrUpdateEpisodeToKodiLibrary(MBitem["Id"], kodi_show_id, connection, cursor) #### PROCESS MUSICVIDEOS #### allEmbyMusicvideos = ReadEmbyDB().getMusicVideos(itemList) for item in allEmbyMusicvideos: if not item.get('IsFolder'): - WriteKodiDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor) + WriteKodiVideoDB().addOrUpdateMusicVideoToKodiLibrary(item["Id"],connection, cursor) ### commit all changes to database ### connection.commit() diff --git a/resources/lib/WebSocketClient.py b/resources/lib/WebSocketClient.py index 013715b7..76531369 100644 --- a/resources/lib/WebSocketClient.py +++ b/resources/lib/WebSocketClient.py @@ -19,7 +19,7 @@ from ClientInformation import ClientInformation from DownloadUtils import DownloadUtils from PlaybackUtils import PlaybackUtils from LibrarySync import LibrarySync -from WriteKodiDB import WriteKodiDB +from WriteKodiVideoDB import WriteKodiVideoDB from ReadEmbyDB import ReadEmbyDB pendingUserDataList = [] @@ -184,7 +184,7 @@ class WebSocketThread(threading.Thread): cursor = connection.cursor() for item in itemsRemoved: self.logMsg("Message : Doing LibraryChanged : Items Removed : Calling deleteEpisodeFromKodiLibraryByMbId: " + item, 0) - WriteKodiDB().deleteItemFromKodiLibrary(item, connection, cursor) + WriteKodiVideoDB().deleteItemFromKodiLibrary(item, connection, cursor) connection.commit() cursor.close() diff --git a/resources/lib/WriteKodiDB.py b/resources/lib/WriteKodiVideoDB.py similarity index 99% rename from resources/lib/WriteKodiDB.py rename to resources/lib/WriteKodiVideoDB.py index 133cd8ab..4f522489 100644 --- a/resources/lib/WriteKodiDB.py +++ b/resources/lib/WriteKodiVideoDB.py @@ -1,5 +1,5 @@ ################################################################################################# -# WriteKodiDB +# WriteKodiVideoDB ################################################################################################# @@ -25,7 +25,7 @@ from xml.etree import ElementTree from xml.dom import minidom import xml.etree.cElementTree as ET -class WriteKodiDB(): +class WriteKodiVideoDB(): def updatePlayCountFromKodi(self, id, type, playcount=0): #when user marks item watched from kodi interface update this in Emby