Add progress dialog for gathering

It's not very precise since we gather in batch, but better than nothing.
This commit is contained in:
angelblue05 2016-01-18 03:23:56 -06:00
parent 2bd1d139c1
commit 08581dbc18
2 changed files with 34 additions and 30 deletions

View file

@ -494,7 +494,7 @@ class LibrarySync(threading.Thread):
heading="Emby for Kodi", heading="Emby for Kodi",
message="Comparing movies from view: %s..." % viewName) message="Comparing movies from view: %s..." % viewName)
all_embymovies = emby.getMovies(viewId, basic=True) all_embymovies = emby.getMovies(viewId, basic=True, dialog=pdialog)
for embymovie in all_embymovies['Items']: for embymovie in all_embymovies['Items']:
if self.shouldStop(): if self.shouldStop():
@ -515,7 +515,7 @@ class LibrarySync(threading.Thread):
del updatelist[:] del updatelist[:]
else: else:
# Initial or repair sync # Initial or repair sync
all_embymovies = emby.getMovies(viewId) all_embymovies = emby.getMovies(viewId, dialog=pdialog)
total = all_embymovies['TotalRecordCount'] total = all_embymovies['TotalRecordCount']
embymovies = all_embymovies['Items'] embymovies = all_embymovies['Items']
@ -543,7 +543,7 @@ class LibrarySync(threading.Thread):
if pdialog: if pdialog:
pdialog.update(heading="Emby for Kodi", message="Gathering boxsets from server...") pdialog.update(heading="Emby for Kodi", message="Gathering boxsets from server...")
boxsets = emby.getBoxset() boxsets = emby.getBoxset(dialog=pdialog)
if compare: if compare:
# Manual sync # Manual sync
@ -652,7 +652,7 @@ class LibrarySync(threading.Thread):
heading="Emby for Kodi", heading="Emby for Kodi",
message="Comparing musicvideos from view: %s..." % viewName) message="Comparing musicvideos from view: %s..." % viewName)
all_embymvideos = emby.getMusicVideos(viewId, basic=True) all_embymvideos = emby.getMusicVideos(viewId, basic=True, dialog=pdialog)
for embymvideo in all_embymvideos['Items']: for embymvideo in all_embymvideos['Items']:
if self.shouldStop(): if self.shouldStop():
@ -673,7 +673,7 @@ class LibrarySync(threading.Thread):
del updatelist[:] del updatelist[:]
else: else:
# Initial or repair sync # Initial or repair sync
all_embymvideos = emby.getMusicVideos(viewId) all_embymvideos = emby.getMusicVideos(viewId, dialog=pdialog)
total = all_embymvideos['TotalRecordCount'] total = all_embymvideos['TotalRecordCount']
embymvideos = all_embymvideos['Items'] embymvideos = all_embymvideos['Items']
@ -755,7 +755,7 @@ class LibrarySync(threading.Thread):
heading="Emby for Kodi", heading="Emby for Kodi",
message="Comparing tvshows from view: %s..." % viewName) message="Comparing tvshows from view: %s..." % viewName)
all_embytvshows = emby.getShows(viewId, basic=True) all_embytvshows = emby.getShows(viewId, basic=True, dialog=pdialog)
for embytvshow in all_embytvshows['Items']: for embytvshow in all_embytvshows['Items']:
if self.shouldStop(): if self.shouldStop():
@ -775,7 +775,7 @@ class LibrarySync(threading.Thread):
total = len(updatelist) total = len(updatelist)
del updatelist[:] del updatelist[:]
else: else:
all_embytvshows = emby.getShows(viewId) all_embytvshows = emby.getShows(viewId, dialog=pdialog)
total = all_embytvshows['TotalRecordCount'] total = all_embytvshows['TotalRecordCount']
embytvshows = all_embytvshows['Items'] embytvshows = all_embytvshows['Items']
@ -818,7 +818,7 @@ class LibrarySync(threading.Thread):
heading="Emby for Kodi", heading="Emby for Kodi",
message="Comparing episodes from view: %s..." % viewName) message="Comparing episodes from view: %s..." % viewName)
all_embyepisodes = emby.getEpisodes(viewId, basic=True) all_embyepisodes = emby.getEpisodes(viewId, basic=True, dialog=pdialog)
for embyepisode in all_embyepisodes['Items']: for embyepisode in all_embyepisodes['Items']:
if self.shouldStop(): if self.shouldStop():
@ -921,9 +921,9 @@ class LibrarySync(threading.Thread):
message="Comparing %s..." % type) message="Comparing %s..." % type)
if type != "artists": if type != "artists":
all_embyitems = process[type][0](basic=True) all_embyitems = process[type][0](basic=True, dialog=pdialog)
else: else:
all_embyitems = process[type][0]() all_embyitems = process[type][0](dialog=pdialog)
for embyitem in all_embyitems['Items']: for embyitem in all_embyitems['Items']:
if self.shouldStop(): if self.shouldStop():
@ -952,7 +952,7 @@ class LibrarySync(threading.Thread):
total = len(updatelist) total = len(updatelist)
del updatelist[:] del updatelist[:]
else: else:
all_embyitems = process[type][0]() all_embyitems = process[type][0](dialog=pdialog)
total = all_embyitems['TotalRecordCount'] total = all_embyitems['TotalRecordCount']
embyitems = all_embyitems['Items'] embyitems = all_embyitems['Items']

View file

@ -149,7 +149,7 @@ class Read_EmbyServer():
} }
return doUtils.downloadUrl(url, parameters=params) return doUtils.downloadUrl(url, parameters=params)
def getSection(self, parentid, itemtype=None, sortby="SortName", basic=False): def getSection(self, parentid, itemtype=None, sortby="SortName", basic=False, dialog=None):
doUtils = self.doUtils doUtils = self.doUtils
items = { items = {
@ -219,7 +219,9 @@ class Read_EmbyServer():
self.logMsg("New throttle for items requested: %s" % jump, 1) self.logMsg("New throttle for items requested: %s" % jump, 1)
else: else:
index += jump index += jump
if dialog:
percentage = int((float(index) / float(total))*100)
dialog.update(percentage)
return items return items
def getViews(self, type, root=False): def getViews(self, type, root=False):
@ -276,15 +278,15 @@ class Read_EmbyServer():
return views return views
def getMovies(self, parentId, basic=False): def getMovies(self, parentId, basic=False, dialog=None):
items = self.getSection(parentId, "Movie", basic=basic) items = self.getSection(parentId, "Movie", basic=basic, dialog=dialog)
return items return items
def getBoxset(self): def getBoxset(self, dialog=None):
items = self.getSection(None, "BoxSet") items = self.getSection(None, "BoxSet", dialog=dialog)
return items return items
@ -294,9 +296,9 @@ class Read_EmbyServer():
return items return items
def getMusicVideos(self, parentId, basic=False): def getMusicVideos(self, parentId, basic=False, dialog=None):
items = self.getSection(parentId, "MusicVideo", basic=basic) items = self.getSection(parentId, "MusicVideo", basic=basic, dialog=dialog)
return items return items
@ -306,9 +308,9 @@ class Read_EmbyServer():
return items return items
def getShows(self, parentId, basic=False): def getShows(self, parentId, basic=False, dialog=None):
items = self.getSection(parentId, "Series", basic=basic) items = self.getSection(parentId, "Series", basic=basic, dialog=dialog)
return items return items
@ -332,9 +334,9 @@ class Read_EmbyServer():
return items return items
def getEpisodes(self, parentId, basic=False): def getEpisodes(self, parentId, basic=False, dialog=None):
items = self.getSection(parentId, "Episode", basic=basic) items = self.getSection(parentId, "Episode", basic=basic, dialog=dialog)
return items return items
@ -350,7 +352,7 @@ class Read_EmbyServer():
return items return items
def getArtists(self): def getArtists(self, dialog=None):
doUtils = self.doUtils doUtils = self.doUtils
items = { items = {
@ -406,12 +408,14 @@ class Read_EmbyServer():
self.logMsg("New throttle for items requested: %s" % jump, 1) self.logMsg("New throttle for items requested: %s" % jump, 1)
else: else:
index += jump index += jump
if dialog:
percentage = int((float(index) / float(total))*100)
dialog.update(percentage)
return items return items
def getAlbums(self, basic=False): def getAlbums(self, basic=False, dialog=None):
items = self.getSection(None, "MusicAlbum", sortby="DateCreated", basic=basic) items = self.getSection(None, "MusicAlbum", sortby="DateCreated", basic=basic, dialog=dialog)
return items return items
@ -421,9 +425,9 @@ class Read_EmbyServer():
return items return items
def getSongs(self, basic=False): def getSongs(self, basic=False, dialog=None):
items = self.getSection(None, "Audio", basic=basic) items = self.getSection(None, "Audio", basic=basic, dialog=dialog)
return items return items
@ -460,4 +464,4 @@ class Read_EmbyServer():
if mediatype: if mediatype:
sorted_items.setdefault(mediatype, []).append(item) sorted_items.setdefault(mediatype, []).append(item)
return sorted_items return sorted_items