mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
verify season index before use
This commit is contained in:
parent
cde774fc9e
commit
ef41e69771
1 changed files with 6 additions and 5 deletions
|
@ -948,7 +948,7 @@ class WriteKodiDB():
|
||||||
cursor.execute("SELECT idSeason FROM seasons WHERE idShow = ? and season = ?",(showid, season))
|
cursor.execute("SELECT idSeason FROM seasons WHERE idShow = ? and season = ?",(showid, season))
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
if(result == None):
|
if(result == None):
|
||||||
utils.logMsg("Emby","Error adding episode to Kodi Library, season does not exist - ID: " + MBitem["Id"] + " - " + MBitem["Name"])
|
utils.logMsg("Emby","Error adding episode to Kodi Library, season does not exist - ShowId: " + str(showid) + " SeasonNo: " + str(season) + " EmbyId: " + MBitem["Id"] + " Name: " + MBitem["Name"])
|
||||||
actionPerformed = False
|
actionPerformed = False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1097,15 +1097,16 @@ class WriteKodiDB():
|
||||||
seasonData = ReadEmbyDB().getTVShowSeasons(MBitem["Id"])
|
seasonData = ReadEmbyDB().getTVShowSeasons(MBitem["Id"])
|
||||||
if seasonData != None:
|
if seasonData != None:
|
||||||
for season in seasonData:
|
for season in seasonData:
|
||||||
if season.has_key("IndexNumber"):
|
seasonNum = season.get("IndexNumber")
|
||||||
cursor.execute("SELECT idSeason as seasonid FROM seasons WHERE idShow = ? and season = ?",(tvshowid,season["IndexNumber"]))
|
if seasonNum != None and seasonNum >= 0 and seasonNum <= 1000:
|
||||||
|
cursor.execute("SELECT idSeason as seasonid FROM seasons WHERE idShow = ? and season = ?",(tvshowid, seasonNum))
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
if result == None:
|
if result == None:
|
||||||
#create the season
|
#create the season
|
||||||
cursor.execute("select coalesce(max(idSeason),0) as seasonid from seasons")
|
cursor.execute("select coalesce(max(idSeason),0) as seasonid from seasons")
|
||||||
seasonid = cursor.fetchone()[0]
|
seasonid = cursor.fetchone()[0]
|
||||||
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, seasonNum))
|
||||||
else:
|
else:
|
||||||
seasonid = result[0]
|
seasonid = result[0]
|
||||||
|
|
||||||
|
@ -1133,7 +1134,7 @@ class WriteKodiDB():
|
||||||
else:
|
else:
|
||||||
url = result[0];
|
url = result[0];
|
||||||
if(url != imageUrl):
|
if(url != imageUrl):
|
||||||
utils.logMsg("SeasonArt", "Updating Art Link for SeasonId: " + seasonid + " (" + url + ") -> (" + imageUrl + ")")
|
utils.logMsg("SeasonArt", "Updating Art Link for SeasonId: " + str(seasonid) + " (" + url + ") -> (" + imageUrl + ")")
|
||||||
cursor.execute("UPDATE art set url = ? WHERE media_id = ? AND media_type = ? AND type = ?", (imageUrl, seasonid, "season", imageType))
|
cursor.execute("UPDATE art set url = ? WHERE media_id = ? AND media_type = ? AND type = ?", (imageUrl, seasonid, "season", imageType))
|
||||||
updateDone = True
|
updateDone = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue