add Special TV Show mapping to Season 100 and use Delete from table for DB reset
This commit is contained in:
parent
ff437bc439
commit
9d2d2788b2
6 changed files with 56 additions and 33 deletions
|
@ -238,12 +238,12 @@
|
||||||
<string id="30237">Sync Extra Fanart</string>
|
<string id="30237">Sync Extra Fanart</string>
|
||||||
<string id="30238">Sync Movie BoxSets</string>
|
<string id="30238">Sync Movie BoxSets</string>
|
||||||
|
|
||||||
<string id="30239">Reset</string>
|
<string id="30239">Reset Local Kodi DB</string>
|
||||||
<string id="30240">Enable watched/resume status sync</string>
|
<string id="30240">Enable watched/resume status sync</string>
|
||||||
<string id="30241">DB Sync Indication:</string>
|
<string id="30241">DB Sync Indication:</string>
|
||||||
<string id="30242">Play Count Sync Indication:</string>
|
<string id="30242">Play Count Sync Indication:</string>
|
||||||
<string id="30243">Enable HTTPS</string>
|
<string id="30243">Enable HTTPS</string>
|
||||||
|
<string id="30244">Use Season 100 for TV Show Specials (Requires Reset)</string>
|
||||||
|
|
||||||
<!-- Default views -->
|
<!-- Default views -->
|
||||||
<string id="30300">Active</string>
|
<string id="30300">Active</string>
|
||||||
|
|
|
@ -129,15 +129,19 @@ class ConnectionManager():
|
||||||
xbmc.executebuiltin('Addon.OpenSettings(%s)' % self.addonId)
|
xbmc.executebuiltin('Addon.OpenSettings(%s)' % self.addonId)
|
||||||
return
|
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
|
# Option to play from http
|
||||||
setPlayback = xbmcgui.Dialog().yesno("Playback option", "Play your files using HTTP?")
|
setPlayback = xbmcgui.Dialog().yesno("Playback option", "Play your files using HTTP?")
|
||||||
if setPlayback == 1:
|
if setPlayback == 1:
|
||||||
self.logMsg("Playback will be set using HTTP.", 1)
|
self.logMsg("Playback will be set using HTTP.", 1)
|
||||||
addon.setSetting("playFromStream", "true")
|
addon.setSetting("playFromStream", "true")
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
self.logMsg("Playback will be set using SMB.", 1)
|
self.logMsg("Playback will be set using SMB.", 1)
|
||||||
return
|
|
||||||
|
|
||||||
def getServerDetails(self):
|
def getServerDetails(self):
|
||||||
|
|
||||||
|
|
|
@ -164,9 +164,30 @@ class ReadEmbyDB():
|
||||||
result = json.loads(jsonData)
|
result = json.loads(jsonData)
|
||||||
if(result.has_key('Items')):
|
if(result.has_key('Items')):
|
||||||
result = result['Items']
|
result = result['Items']
|
||||||
|
result = self.changeSeasonSpecialToSeason100(result)
|
||||||
|
|
||||||
return 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):
|
def getEpisodes(self, showId, fullinfo = False):
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
|
@ -189,6 +210,8 @@ class ReadEmbyDB():
|
||||||
result = json.loads(jsonData)
|
result = json.loads(jsonData)
|
||||||
if(result.has_key('Items')):
|
if(result.has_key('Items')):
|
||||||
result = result['Items']
|
result = result['Items']
|
||||||
|
result = self.changeEpisodeSpecialToSeason100(result)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getLatestEpisodes(self, fullinfo = False, itemList = []):
|
def getLatestEpisodes(self, fullinfo = False, itemList = []):
|
||||||
|
@ -217,6 +240,8 @@ class ReadEmbyDB():
|
||||||
result = json.loads(jsonData)
|
result = json.loads(jsonData)
|
||||||
if(result.has_key('Items')):
|
if(result.has_key('Items')):
|
||||||
result = result['Items']
|
result = result['Items']
|
||||||
|
result = self.changeEpisodeSpecialToSeason100(result)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getCollections(self, type):
|
def getCollections(self, type):
|
||||||
|
|
|
@ -171,36 +171,25 @@ def reset():
|
||||||
return
|
return
|
||||||
xbmc.sleep(1000)
|
xbmc.sleep(1000)
|
||||||
|
|
||||||
# remove from addon data directory
|
# 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()
|
||||||
|
|
||||||
|
# reset the install run flag
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
addondir = xbmc.translatePath(addon.getAddonInfo('profile'))
|
addon.setSetting("SyncInstallRunDone", "false") # this is not working for some reason
|
||||||
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
|
|
||||||
|
|
||||||
dialog = xbmcgui.Dialog()
|
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")
|
xbmc.executebuiltin("RestartApp")
|
||||||
|
|
||||||
|
|
|
@ -1087,6 +1087,10 @@ class WriteKodiDB():
|
||||||
seasonid = seasonid + 1
|
seasonid = seasonid + 1
|
||||||
cursor.execute("INSERT into seasons(idSeason, idShow, season) values(?, ?, ?)", (seasonid, tvshowid, season["IndexNumber"]))
|
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
|
#insert artwork
|
||||||
if API().getArtwork(season, "Thumb") != "":
|
if API().getArtwork(season, "Thumb") != "":
|
||||||
cursor.execute("INSERT into art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid,"season","landscape",API().getArtwork(season, "Thumb")))
|
cursor.execute("INSERT into art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid,"season","landscape",API().getArtwork(season, "Thumb")))
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<category label="Sync Options">
|
<category label="Sync Options">
|
||||||
<!-- <setting id="syncMovieBoxSets" type="bool" label="30238" default="true" visible="true" enable="true" /> -->
|
<!-- <setting id="syncMovieBoxSets" type="bool" label="30238" default="true" visible="true" enable="true" /> -->
|
||||||
<setting id="enablePlayCountSync" type="bool" label="30240" default="true" visible="true" enable="true" />
|
<setting id="enablePlayCountSync" type="bool" label="30240" default="true" visible="true" enable="true" />
|
||||||
|
<setting id="useSeason100ForSpecials" type="bool" label="30244" default="false" visible="true" enable="true" />
|
||||||
<setting id="dbSyncIndication" type="labelenum" label="30241" values="None|Notify OnChange|Notify OnFinish|BG Progress|Dialog Progress" default="None" />
|
<setting id="dbSyncIndication" type="labelenum" label="30241" values="None|Notify OnChange|Notify OnFinish|BG Progress|Dialog Progress" default="None" />
|
||||||
<setting id="playCountSyncIndication" type="labelenum" label="30242" values="None|Notify OnChange|Notify OnFinish|BG Progress|Dialog Progress" default="None" />
|
<setting id="playCountSyncIndication" type="labelenum" label="30242" values="None|Notify OnChange|Notify OnFinish|BG Progress|Dialog Progress" default="None" />
|
||||||
</category>
|
</category>
|
||||||
|
|
Loading…
Reference in a new issue