Optimize Kodi db method add_season
This commit is contained in:
parent
54a231a67f
commit
f2fea1bcde
2 changed files with 13 additions and 14 deletions
|
@ -755,7 +755,7 @@ class TVShows(Items):
|
|||
'Skipping season for now.', plex_id)
|
||||
return
|
||||
|
||||
seasonid = self.kodi_db.addSeason(showid, seasonnum)
|
||||
seasonid = self.kodi_db.add_season(showid, seasonnum)
|
||||
checksum = api.checksum()
|
||||
# Check whether Season already exists
|
||||
plex_dbitem = plex_db.getItem_byId(plex_id)
|
||||
|
@ -857,7 +857,7 @@ class TVShows(Items):
|
|||
except TypeError:
|
||||
LOG.error("Parent tvshow now found, skip item")
|
||||
return False
|
||||
seasonid = self.kodi_db.addSeason(showid, season)
|
||||
seasonid = self.kodi_db.add_season(showid, season)
|
||||
|
||||
# GET THE FILE AND PATH #####
|
||||
do_indirect = not state.DIRECT_PATHS
|
||||
|
|
|
@ -824,24 +824,23 @@ class KodiDBMethods(object):
|
|||
query = 'DELETE FROM sets WHERE idSet = ?'
|
||||
self.cursor.execute(query, (set_id,))
|
||||
|
||||
def addSeason(self, showid, seasonnumber):
|
||||
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT idSeason",
|
||||
"FROM seasons",
|
||||
"WHERE idShow = ?",
|
||||
"AND season = ?"
|
||||
))
|
||||
def add_season(self, showid, seasonnumber):
|
||||
"""
|
||||
Adds a TV show season to the Kodi video DB or simply returns the ID,
|
||||
if there already is an entry in the DB
|
||||
"""
|
||||
query = 'SELECT idSeason FROM seasons WHERE idShow = ? AND season = ?'
|
||||
self.cursor.execute(query, (showid, seasonnumber,))
|
||||
try:
|
||||
seasonid = self.cursor.fetchone()[0]
|
||||
except TypeError:
|
||||
self.cursor.execute("select coalesce(max(idSeason),0) from seasons")
|
||||
self.cursor.execute("SELECT COALESCE(MAX(idSeason),0) FROM seasons")
|
||||
seasonid = self.cursor.fetchone()[0] + 1
|
||||
query = "INSERT INTO seasons(idSeason, idShow, season) values(?, ?, ?)"
|
||||
query = '''
|
||||
INSERT INTO seasons(idSeason, idShow, season)
|
||||
VALUES (?, ?, ?)
|
||||
'''
|
||||
self.cursor.execute(query, (seasonid, showid, seasonnumber))
|
||||
|
||||
return seasonid
|
||||
|
||||
def addArtist(self, name, musicbrainz):
|
||||
|
|
Loading…
Reference in a new issue