Allow for view deletion
This commit is contained in:
parent
4360b6b7de
commit
954e78db55
1 changed files with 22 additions and 4 deletions
|
@ -447,6 +447,15 @@ class LibrarySync(Thread):
|
||||||
"viewname: %s" % current_viewname,
|
"viewname: %s" % current_viewname,
|
||||||
"viewtype: %s" % current_viewtype,
|
"viewtype: %s" % current_viewtype,
|
||||||
"tagid: %s" % current_tagid)), 2)
|
"tagid: %s" % current_tagid)), 2)
|
||||||
|
|
||||||
|
# Remove views that are still valid to delete rest later
|
||||||
|
try:
|
||||||
|
# View is still valid
|
||||||
|
self.old_views.remove(folderid)
|
||||||
|
except ValueError:
|
||||||
|
# View was just created, nothing to remove
|
||||||
|
pass
|
||||||
|
|
||||||
# View was modified, update with latest info
|
# View was modified, update with latest info
|
||||||
if current_viewname != foldername:
|
if current_viewname != foldername:
|
||||||
self.logMsg("viewid: %s new viewname: %s"
|
self.logMsg("viewid: %s new viewname: %s"
|
||||||
|
@ -511,9 +520,9 @@ class LibrarySync(Thread):
|
||||||
vnodes = self.vnodes
|
vnodes = self.vnodes
|
||||||
|
|
||||||
# Get views
|
# Get views
|
||||||
result = downloadutils.DownloadUtils().downloadUrl(
|
sections = downloadutils.DownloadUtils().downloadUrl(
|
||||||
"{server}/library/sections")
|
"{server}/library/sections")
|
||||||
if not result:
|
if not sections:
|
||||||
self.logMsg("Error download PMS views, abort maintainViews", -1)
|
self.logMsg("Error download PMS views, abort maintainViews", -1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -522,8 +531,11 @@ class LibrarySync(Thread):
|
||||||
totalnodes = 0
|
totalnodes = 0
|
||||||
|
|
||||||
with embydb.GetEmbyDB() as emby_db:
|
with embydb.GetEmbyDB() as emby_db:
|
||||||
|
# Backup old views to delete them later, if needed (at the end
|
||||||
|
# of this method, only unused views will be left in oldviews)
|
||||||
|
self.old_views = emby_db.getViews()
|
||||||
with kodidb.GetKodiDB('video') as kodi_db:
|
with kodidb.GetKodiDB('video') as kodi_db:
|
||||||
for folderItem in result:
|
for folderItem in sections:
|
||||||
self.processView(folderItem, kodi_db, emby_db, totalnodes)
|
self.processView(folderItem, kodi_db, emby_db, totalnodes)
|
||||||
else:
|
else:
|
||||||
# Add video nodes listings
|
# Add video nodes listings
|
||||||
|
@ -545,11 +557,13 @@ class LibrarySync(Thread):
|
||||||
# Save total
|
# Save total
|
||||||
utils.window('Emby.nodes.total', str(totalnodes))
|
utils.window('Emby.nodes.total', str(totalnodes))
|
||||||
|
|
||||||
|
# Reopen DB connection to ensure that changes are commited
|
||||||
|
with embydb.GetEmbyDB() as emby_db:
|
||||||
# update views for all:
|
# update views for all:
|
||||||
self.views = emby_db.getAllViewInfo()
|
self.views = emby_db.getAllViewInfo()
|
||||||
# Append music views only to self.views (no custom views otherwise)
|
# Append music views only to self.views (no custom views otherwise)
|
||||||
if self.enableMusic:
|
if self.enableMusic:
|
||||||
for folderItem in result:
|
for folderItem in sections:
|
||||||
if folderItem.attrib['type'] == 'artist':
|
if folderItem.attrib['type'] == 'artist':
|
||||||
entry = {
|
entry = {
|
||||||
'id': folderItem.attrib['key'],
|
'id': folderItem.attrib['key'],
|
||||||
|
@ -558,6 +572,10 @@ class LibrarySync(Thread):
|
||||||
}
|
}
|
||||||
self.views.append(entry)
|
self.views.append(entry)
|
||||||
|
|
||||||
|
log("Removing views: %s" % self.old_views, 1)
|
||||||
|
for view in self.old_views:
|
||||||
|
emby_db.removeView(view)
|
||||||
|
|
||||||
self.logMsg("views saved: %s" % self.views, 1)
|
self.logMsg("views saved: %s" % self.views, 1)
|
||||||
|
|
||||||
def GetUpdatelist(self, xml, itemType, method, viewName, viewId,
|
def GetUpdatelist(self, xml, itemType, method, viewName, viewId,
|
||||||
|
|
Loading…
Reference in a new issue