diff --git a/resources/lib/clientinfo.py b/resources/lib/clientinfo.py index 6779b648..2596abaf 100644 --- a/resources/lib/clientinfo.py +++ b/resources/lib/clientinfo.py @@ -60,7 +60,7 @@ class ClientInfo(): else: return "Unknown" - def getDeviceId(self): + def getDeviceId(self, reset=False): """ Returns a unique Plex client id "X-Plex-Client-Identifier" from Kodi settings file. @@ -68,6 +68,11 @@ class ClientInfo(): If id does not exist, create one and save in Kodi settings file. """ + + if reset: + utils.window('plex_client_Id', clear=True) + utils.settings('plex_client_Id', value="") + clientId = utils.window('plex_client_Id') if clientId: return clientId diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index b244f7fc..ea97dba8 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -215,15 +215,17 @@ def resetDeviceId(): utils.window('emby_deviceId', clear=True) deviceId = clientinfo.ClientInfo().getDeviceId(reset=True) except Exception as e: - utils.logMsg("EMBY", "Failed to generate a new device Id: %s" % e, 1) + utils.logMsg(addonName, + "Failed to generate a new device Id: %s" % e, 1) dialog.ok( - heading="Emby for Kodi", + heading=addonName, line1=language(33032)) else: - utils.logMsg("EMBY", "Successfully removed old deviceId: %s New deviceId: %s" - % (deviceId_old, deviceId), 1) + utils.logMsg(addonName, + "Successfully removed old deviceId: %s New deviceId: %s" + % (deviceId_old, deviceId), 1) dialog.ok( - heading="Emby for Kodi", + heading=addonName, line1=language(33033)) xbmc.executebuiltin('RestartApp') diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index b2f4204a..8183b96a 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -521,6 +521,29 @@ class LibrarySync(Thread): vnodes.clearProperties() totalnodes = 0 + with embydb.GetEmbyDB() as emby_db: + with kodidb.GetKodiDB('video') as kodi_db: + for folderItem in result: + self.processView(folderItem, kodi_db, emby_db, totalnodes) + else: + # Add video nodes listings + vnodes.singleNode(totalnodes, + "Favorite movies", + "movies", + "favourites") + totalnodes += 1 + vnodes.singleNode(totalnodes, + "Favorite tvshows", + "tvshows", + "favourites") + totalnodes += 1 + vnodes.singleNode(totalnodes, + "channels", + "movies", + "channels") + totalnodes += 1 + # Save total + utils.window('Emby.nodes.total', str(totalnodes)) # update views for all: self.views = emby_db.getAllViewInfo() @@ -534,8 +557,6 @@ class LibrarySync(Thread): 'itemtype': 'artist' } self.views.append(entry) - nodes = [] # Prevent duplicate for nodes of the same type - playlists = [] # Prevent duplicate for playlists of the same type self.logMsg("views saved: %s" % self.views, 1) @@ -623,17 +644,6 @@ class LibrarySync(Thread): itemNumber = len(self.updatelist) if itemNumber == 0: return True - # Validate the playlist exists or recreate it - if (foldername not in playlists and - mediatype in ('movies', 'tvshows', 'musicvideos')): - utils.playlistXSP(mediatype, foldername, folderid, viewtype) - playlists.append(foldername) - if foldername not in nodes and mediatype != "musicvideos": - vnodes.viewNode(sorted_views.index(foldername), foldername, - mediatype, viewtype, folderid) - if viewtype == "mixed": # Change the value - sorted_views[sorted_views.index(foldername)] = "%ss" % foldername - nodes.append(foldername) # Run through self.updatelist, get XML metadata per item # Initiate threads @@ -682,10 +692,6 @@ class LibrarySync(Thread): thread.start() threads.append(thread) self.logMsg("Kodi Infobox thread spawned", 1) - # Remove any old referenced views - log("Removing views: %s" % current_views, 1) - for view in current_views: - emby_db.removeView(view) # Wait until finished getMetadataQueue.join() diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 233ac0cc..9cf19ec0 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -11,6 +11,7 @@ import unicodedata import xml.etree.ElementTree as etree from functools import wraps from calendar import timegm +import os import xbmc import xbmcaddon