improvement to tvshows sync: also process updates at tv show level at first sync

This commit is contained in:
Marcel van der Veldt 2015-03-20 11:08:22 +01:00
parent cbfc40f430
commit 6eba8db57a
4 changed files with 36 additions and 17 deletions

View file

@ -119,7 +119,10 @@ class CreateFiles():
if seasonData != None: if seasonData != None:
for season in seasonData: for season in seasonData:
if season.has_key("IndexNumber"): if season.has_key("IndexNumber"):
SubElement(root, "thumb",{"type":"season","season":str(season["IndexNumber"])}).text = API().getArtwork(season, "Primary") seasonart = API().getArtwork(season, "Primary")
if seasonart == None:
seasonart = API().getArtwork(item, "Primary")
SubElement(root, "thumb",{"type":"season","season":str(season["IndexNumber"])}).text = seasonart
SubElement(root, "thumb",{"type":"season","season":"0"}).text = API().getArtwork(item, "Primary") SubElement(root, "thumb",{"type":"season","season":"0"}).text = API().getArtwork(item, "Primary")
SubElement(root, "fanart").text = API().getArtwork(item, "Backdrop") SubElement(root, "fanart").text = API().getArtwork(item, "Backdrop")

View file

@ -324,7 +324,7 @@ class LibrarySync():
allEpisodes = list() allEpisodes = list()
#FIXME --> for now pull all tv shows and use the incremental update only at episode level #FIXME --> for now pull all tv shows and use the incremental update only at episode level
tvShowData = ReadEmbyDB().getTVShows(True,True) tvShowData = ReadEmbyDB().getTVShows(True,True)
allKodiIds = set(ReadKodiDB().getKodiTvShowsIds(True))
updateNeeded = False updateNeeded = False
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
@ -341,16 +341,11 @@ class LibrarySync():
for item in tvShowData: for item in tvShowData:
if item.get('IsFolder'): if item.get('IsFolder'):
kodiItem = ReadKodiDB().getKodiTVShow(item["Id"])
allTVShows.append(item["Id"]) allTVShows.append(item["Id"])
progMessage = "Processing" progMessage = "Processing"
if kodiItem == None: if item["Id"] not in allKodiIds:
WriteKodiDB().addTVShowToKodiLibrary(item) WriteKodiDB().addMovieToKodiLibrary(item)
updateNeeded = True updateNeeded = True
progMessage = "Adding"
else:
WriteKodiDB().updateTVShowToKodiLibrary(item, kodiItem)
progMessage = "Updating"
if(self.ShouldStop(pDialog)): if(self.ShouldStop(pDialog)):
return True return True
@ -358,7 +353,7 @@ class LibrarySync():
# update progress bar # update progress bar
if(pDialog != None): if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100)) percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, progressTitle, progMessage + " Tv Show: " + str(count)) pDialog.update(percentage, progressTitle, "Adding Tv Show: " + str(count))
count += 1 count += 1
#initiate library update and wait for finish before processing any updates #initiate library update and wait for finish before processing any updates
@ -373,9 +368,32 @@ class LibrarySync():
if(pDialog != None and type(pDialog) == xbmcgui.DialogProgressBG): if(pDialog != None and type(pDialog) == xbmcgui.DialogProgressBG):
pDialog.create('Sync DB', 'Sync DB') pDialog.create('Sync DB', 'Sync DB')
if(pDialog != None):
#process episodes (will only be possible when tv show is scanned to library) progressTitle = "Sync DB : Processing TV Shows"
#TODO --> maybe pull full info only when needed ? pDialog.update(0, progressTitle, "")
total = len(allMB3Movies) + 1
count = 1
#process updates at TV Show level
allKodiTVShows = ReadKodiDB().getKodiTvShows(True)
for item in tvShowData:
if item.get('IsFolder'):
kodishow = allKodiTVShows.get(item["Id"],None)
if(kodishow != None):
WriteKodiDB().updateTVShowToKodiLibrary(item,kodishow)
if(self.ShouldStop(pDialog)):
return True
# update progress bar
if(pDialog != None):
percentage = int(((float(count) / float(total)) * 100))
pDialog.update(percentage, progressTitle, "Updating Tv Show: " + str(count))
count += 1
#process episodes
allEpisodes = list() allEpisodes = list()
showTotal = len(allTVShows) showTotal = len(allTVShows)

View file

@ -94,9 +94,7 @@ class ReadKodiDB():
allKodiTvShowsIds.append(id) allKodiTvShowsIds.append(id)
return allKodiTvShowsIds return allKodiTvShowsIds
def getKodiTvShows(self,fullInfo = False): def getKodiTvShows(self,fullInfo = False):
#returns all tvshows in Kodi db inserted by MB #returns all tvshows in Kodi db inserted by MB
xbmc.sleep(sleepVal) xbmc.sleep(sleepVal)

View file

@ -176,7 +176,7 @@ class WriteKodiDB():
changes = False changes = False
#update artwork #update artwork
#changes |= self.updateArtWork(KodiItem,"poster", API().getArtwork(MBitem, "Primary"),"tvshow") changes |= self.updateArtWork(KodiItem,"poster", API().getArtwork(MBitem, "Primary"),"tvshow")
changes |= self.updateArtWork(KodiItem,"clearlogo", API().getArtwork(MBitem, "Logo"),"tvshow") changes |= self.updateArtWork(KodiItem,"clearlogo", API().getArtwork(MBitem, "Logo"),"tvshow")
changes |= self.updateArtWork(KodiItem,"clearart", API().getArtwork(MBitem, "Art"),"tvshow") changes |= self.updateArtWork(KodiItem,"clearart", API().getArtwork(MBitem, "Art"),"tvshow")
changes |= self.updateArtWork(KodiItem,"banner", API().getArtwork(MBitem, "Banner"),"tvshow") changes |= self.updateArtWork(KodiItem,"banner", API().getArtwork(MBitem, "Banner"),"tvshow")