diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 4ea566f4..990356ac 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -238,12 +238,12 @@ Sync Extra Fanart Sync Movie BoxSets - Reset + Reset Local Kodi DB Enable watched/resume status sync DB Sync Indication: Play Count Sync Indication: Enable HTTPS - + Use Season 100 for TV Show Specials (Requires Reset) Active diff --git a/resources/lib/ConnectionManager.py b/resources/lib/ConnectionManager.py index b46e0075..e55b0624 100644 --- a/resources/lib/ConnectionManager.py +++ b/resources/lib/ConnectionManager.py @@ -129,15 +129,19 @@ class ConnectionManager(): xbmc.executebuiltin('Addon.OpenSettings(%s)' % self.addonId) return + #TV Show specual as season 100 + setSpecialAction = xbmcgui.Dialog().yesno("TV Show Specials Handling", "Use season 100 for TV Show Specials?") + if setSpecialAction == 1: + self.logMsg("TV Show Specials will be assigned season 100", 0) + addon.setSetting("useSeason100ForSpecials", "true") + # Option to play from http setPlayback = xbmcgui.Dialog().yesno("Playback option", "Play your files using HTTP?") if setPlayback == 1: self.logMsg("Playback will be set using HTTP.", 1) addon.setSetting("playFromStream", "true") - return else: self.logMsg("Playback will be set using SMB.", 1) - return def getServerDetails(self): diff --git a/resources/lib/ReadEmbyDB.py b/resources/lib/ReadEmbyDB.py index f7c7626d..640176aa 100644 --- a/resources/lib/ReadEmbyDB.py +++ b/resources/lib/ReadEmbyDB.py @@ -164,9 +164,30 @@ class ReadEmbyDB(): result = json.loads(jsonData) if(result.has_key('Items')): result = result['Items'] + result = self.changeSeasonSpecialToSeason100(result) return result + def changeSeasonSpecialToSeason100(self, result): + addon = xbmcaddon.Addon(id='plugin.video.emby') + if(addon.getSetting("useSeason100ForSpecials") != "true"): + return result + + for item in result: + if(item != None and item.get("IndexNumber") != None and item.get("IndexNumber") == 0): + item["IndexNumber"] = 100 + return result + + def changeEpisodeSpecialToSeason100(self, result): + addon = xbmcaddon.Addon(id='plugin.video.emby') + if(addon.getSetting("useSeason100ForSpecials") != "true"): + return result + + for item in result: + if(item != None and item.get("ParentIndexNumber") != None and item.get("ParentIndexNumber") == 0): + item["ParentIndexNumber"] = 100 + return result + def getEpisodes(self, showId, fullinfo = False): result = None @@ -189,6 +210,8 @@ class ReadEmbyDB(): result = json.loads(jsonData) if(result.has_key('Items')): result = result['Items'] + result = self.changeEpisodeSpecialToSeason100(result) + return result def getLatestEpisodes(self, fullinfo = False, itemList = []): @@ -217,6 +240,8 @@ class ReadEmbyDB(): result = json.loads(jsonData) if(result.has_key('Items')): result = result['Items'] + result = self.changeEpisodeSpecialToSeason100(result) + return result def getCollections(self, type): diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py index da3a07ad..4c82ddbc 100644 --- a/resources/lib/Utils.py +++ b/resources/lib/Utils.py @@ -170,37 +170,26 @@ def reset(): dialog.ok('Warning', 'Could not stop DB sync, you should try again.') return xbmc.sleep(1000) + + # delete db table data + print "Doing DB Reset" + connection = KodiSQL() + cursor = connection.cursor( ) + cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"') + rows = cursor.fetchall() + for row in rows: + tableName = row[0] + print tableName + if(tableName != "version"): + cursor.execute("DELETE FROM " + tableName) + connection.commit() + cursor.close() - # remove from addon data directory + # reset the install run flag addon = xbmcaddon.Addon(id='plugin.video.emby') - addondir = xbmc.translatePath(addon.getAddonInfo('profile')) - dataPath = os.path.join(addondir + os.sep) - removeDirectory(dataPath) - - # delete db - deletecount = 0 - deleted = False - while(deleted == False): - try: - xbmcvfs.delete(getKodiDBPath()) - deleted = True - except: - deletecount += 1 - if(deletecount > 10): - dialog = xbmcgui.Dialog() - dialog.ok('Warning', 'Could not delete Database, please try again later') - return - xbmc.sleep(1000) - - # extra check on the database to see it has been removed - if xbmcvfs.exists(getKodiDBPath()): - dialog = xbmcgui.Dialog() - dialog.ok('Error', 'The video database could not be deleted, this will need to be done manually. Remove: '+getKodiDBPath() + ' then restart Kodi') - return - - # remove old entries from sources.xml - + addon.setSetting("SyncInstallRunDone", "false") # this is not working for some reason + dialog = xbmcgui.Dialog() - dialog.ok('Emby Reset', 'Reset of Emby has completed, kodi will now restart to apply the changes.') + dialog.ok('Emby Reset', 'Database reset has completed, kodi will now restart to apply the changes.') xbmc.executebuiltin("RestartApp") diff --git a/resources/lib/WriteKodiDB.py b/resources/lib/WriteKodiDB.py index d3315154..b2ac6aa4 100644 --- a/resources/lib/WriteKodiDB.py +++ b/resources/lib/WriteKodiDB.py @@ -1087,6 +1087,10 @@ class WriteKodiDB(): seasonid = seasonid + 1 cursor.execute("INSERT into seasons(idSeason, idShow, season) values(?, ?, ?)", (seasonid, tvshowid, season["IndexNumber"])) + # this is for handling specials as season 100, it allows art to be correctly set form the season 0 Emby data + if(season["IndexNumber"] == 100): + season["IndexNumber"] = 0 + #insert artwork if API().getArtwork(season, "Thumb") != "": cursor.execute("INSERT into art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid,"season","landscape",API().getArtwork(season, "Thumb"))) diff --git a/resources/settings.xml b/resources/settings.xml index d23bbb80..ae2bf36a 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -13,6 +13,7 @@ +