Fix specials airs before, Remove Special Season 100 Mapping, Update season art

Fix specials airs before values, set to -1 to make them only show up in
Specials
Remove Special Season 100 Mapping option
Update season art when changed
This commit is contained in:
shaun 2015-04-15 12:20:08 +10:00
parent 3ac1835800
commit 19e38bec8e
6 changed files with 88 additions and 59 deletions

View file

@ -243,7 +243,6 @@
<string id="30241">DB Sync Indication:</string>
<string id="30242">Play Count Sync Indication:</string>
<string id="30243">Enable HTTPS</string>
<string id="30244">Use Season 100 for TV Show Specials (Requires Reset)</string>
<string id="30245">Force Transcoding Codecs</string>
<!-- Default views -->

View file

@ -129,12 +129,6 @@ 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:

View file

@ -160,30 +160,9 @@ 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
@ -205,7 +184,6 @@ class ReadEmbyDB():
result = json.loads(jsonData)
if(result.has_key('Items')):
result = result['Items']
result = self.changeEpisodeSpecialToSeason100(result)
return result
@ -234,7 +212,6 @@ class ReadEmbyDB():
result = json.loads(jsonData)
if(result.has_key('Items')):
result = result['Items']
result = self.changeEpisodeSpecialToSeason100(result)
return result

View file

@ -154,20 +154,17 @@ def removeDirectory(path):
def reset():
WINDOW = xbmcgui.Window( 10000 )
username = WINDOW.getProperty('currUser')
user_delete = False
return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local database?")
return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local Kodi database?")
if return_value == 0:
return
# Ask if user information should be deleted too.
return_user = xbmcgui.Dialog().yesno("Warning", "Do you wish to erase your saved Emby user information for %s?" % username)
return_user = xbmcgui.Dialog().yesno("Warning", "Reset all Emby Addon settings?")
delete_settings = False
if return_user == 1:
user_delete = True
delete_settings = True
# first stop any db sync
WINDOW = xbmcgui.Window( 10000 )
@ -175,6 +172,7 @@ def reset():
count = 0
while(WINDOW.getProperty("SyncDatabaseRunning") == "true"):
xbmc.log("Sync Running, will wait : " + str(count))
count += 1
if(count > 10):
dialog = xbmcgui.Dialog()
@ -199,11 +197,11 @@ def reset():
# reset the install run flag
WINDOW.setProperty("SyncInstallRunDone", "false")
if (user_delete == True):
if (delete_settings == True):
addondir = xbmc.translatePath(addonSettings.getAddonInfo('profile'))
dataPath = os.path.join(addondir + "settings.xml")
xbmcvfs.delete(dataPath)
xbmc.log("Deleted saved user information for: %s" % username)
xbmc.log("Deleting : settings.xml")
dialog = xbmcgui.Dialog()
dialog.ok('Emby Reset', 'Database reset has completed, Kodi will now restart to apply the changes.')

View file

@ -377,7 +377,7 @@ class WriteKodiDB():
#set Filename (will update the filename in db if changed)
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
self.setKodiFilename(KodiItem["episodeid"], KodiItem["file"], playurl, "episode", MBitem["Id"], connection, cursor)
changes |= self.setKodiFilename(KodiItem["episodeid"], KodiItem["file"], playurl, "episode", MBitem["Id"], connection, cursor)
#update common properties
if KodiItem["runtime"] == 0:
@ -399,7 +399,11 @@ class WriteKodiDB():
if MBitem.get("ParentIndexNumber") != None:
season = int(MBitem.get("ParentIndexNumber"))
#print "ParentIndexNumber:" + str(season)
changes |= self.updateProperty(KodiItem,"season",season,"episode")
# removed for now as setting c15 and c16 to -1 just shows specials in the special folder only
#if(season == 0):
# changes |= self.setSpecialAirsDetails(MBitem, KodiItem, connection, cursor)
if MBitem.get("IndexNumber") != None:
episode = int(MBitem.get("IndexNumber"))
@ -955,8 +959,8 @@ class WriteKodiDB():
cursor.execute("select coalesce(max(idEpisode),0) as episodeid from episode")
episodeid = cursor.fetchone()[0]
episodeid = episodeid + 1
pathsql="INSERT into episode(idEpisode, idFile, c00, c01, c03, c05, c09, c20, c12, c13, c14, idShow) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
cursor.execute(pathsql, (episodeid, fileid, title, plot, rating, premieredate, runtime, MBitem["Id"], season, episode, title, showid))
pathsql = "INSERT into episode(idEpisode, idFile, c00, c01, c03, c05, c09, c20, c12, c13, c14, idShow, c15, c16) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
cursor.execute(pathsql, (episodeid, fileid, title, plot, rating, premieredate, runtime, MBitem["Id"], season, episode, title, showid, "-1", "-1"))
try:
connection.commit()
@ -1090,21 +1094,39 @@ class WriteKodiDB():
seasonid = cursor.fetchone()[0]
seasonid = seasonid + 1
cursor.execute("INSERT into seasons(idSeason, idShow, season) values(?, ?, ?)", (seasonid, tvshowid, season["IndexNumber"]))
else:
seasonid = result[0]
# 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
#update artwork
imageUrl = API().getArtwork(season, "Thumb")
self.updateSeasonArt(imageUrl, seasonid, "landscape", cursor)
#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")))
if API().getArtwork(season, "Primary") != "":
cursor.execute("INSERT into art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid,"season","poster",API().getArtwork(season, "Primary")))
if API().getArtwork(season, "Banner") != "":
cursor.execute("INSERT into art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid,"season","banner",API().getArtwork(season, "Banner")))
imageUrl = API().getArtwork(season, "Primary")
self.updateSeasonArt(imageUrl, seasonid, "poster", cursor)
imageUrl = API().getArtwork(season, "Banner")
self.updateSeasonArt(imageUrl, seasonid, "banner", cursor)
connection.commit()
def updateSeasonArt(self, imageUrl, seasonid, imageType, cursor):
updateDone = False
if imageUrl != "":
cursor.execute("SELECT url FROM art WHERE media_id = ? AND media_type = ? AND type = ?", (seasonid, "season", imageType))
result = cursor.fetchone()
if(result == None):
utils.logMsg("SeasonArt", "Adding Art Link for SeasonId: " + str(seasonid) + " (" + imageUrl + ")")
cursor.execute("INSERT INTO art(media_id, media_type, type, url) values(?, ?, ?, ?)", (seasonid, "season", imageType, imageUrl))
updateDone = True
else:
url = result[0];
if(url != imageUrl):
utils.logMsg("SeasonArt", "Updating Art Link for SeasonId: " + seasonid + " (" + url + ") -> (" + imageUrl + ")")
cursor.execute("UPDATE art set url = ? WHERE media_id = ? AND media_type = ? AND type = ?", (imageUrl, seasonid, "season", imageType))
updateDone = True
return updateDone
def setKodiResumePoint(self, id, resume_seconds, total_seconds, fileType):
#use sqlite to set the resume point while json api doesn't support this yet
#todo --> submit PR to kodi team to get this added to the jsonrpc api
@ -1132,6 +1154,46 @@ class WriteKodiDB():
connection.commit()
cursor.close()
'''
# removed for now as setting c15 and c16 to -1 looks like it just shows specials in the special folder only
def setSpecialAirsDetails(self, MBitem, KodiItem, connection, cursor):
changes = False
cursor.execute("SELECT c15, c16 FROM episode WHERE idEpisode = ?",(KodiItem["episodeid"],))
result = cursor.fetchone()
if(result != None):
c15 = -1
c16 = -1
if(result[0] != None and result[0] != "" and result[0] != "None"):
c15 = int(result[0])
if(result[1] != None and result[1] != "" and result[1] != "None"):
c16 = int(result[1])
airsBeforeSeasonNumber = MBitem.get("AirsBeforeSeasonNumber")
airsBeforeEpisodeNumber = MBitem.get("AirsBeforeEpisodeNumber")
#AirsAfterSeasonNumber
if(airsBeforeSeasonNumber == None):
airsBeforeSeasonNumber = 0
if(airsBeforeEpisodeNumber == None):
airsBeforeEpisodeNumber = 0
if(airsBeforeSeasonNumber != None and airsBeforeEpisodeNumber != None):
if(airsBeforeSeasonNumber != c15 or airsBeforeEpisodeNumber != c16):
utils.logMsg("Emby","Special_Airs_Info Kodi: " + str(c15) + " " + str(c16))
utils.logMsg("Emby","Special_Airs_Info Emby : " + str(airsBeforeSeasonNumber) + " " + str(airsBeforeEpisodeNumber))
sql = "UPDATE episode set c15 = ?, c16 = ? WHERE idEpisode = ?"
cursor.execute(sql, (airsBeforeSeasonNumber, airsBeforeEpisodeNumber, KodiItem["episodeid"]))
connection.commit()
changes = True
return changes
'''
def setKodiFilename(self, id, oldFileName, newFileName, fileType, mbId, connection, cursor):
#use sqlite to set the filename in DB -- needed to avoid problems with resumepoints etc
#return True if any action is performed, False if no action is performed

View file

@ -15,7 +15,6 @@
<category label="Sync Options">
<!-- <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="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="playCountSyncIndication" type="labelenum" label="30242" values="None|Notify OnChange|Notify OnFinish|BG Progress|Dialog Progress" default="None" />
</category>