Optimize code
This commit is contained in:
parent
0fa72faf61
commit
120a616331
1 changed files with 4 additions and 5 deletions
|
@ -125,22 +125,21 @@ class Show(ItemBase, TvShowMixin):
|
||||||
Process a single show
|
Process a single show
|
||||||
"""
|
"""
|
||||||
api = API(xml)
|
api = API(xml)
|
||||||
update_item = True
|
|
||||||
plex_id = api.plex_id()
|
plex_id = api.plex_id()
|
||||||
LOG.debug('Adding show with plex_id %s', plex_id)
|
LOG.debug('Adding show with plex_id %s', plex_id)
|
||||||
if not plex_id:
|
if not plex_id:
|
||||||
LOG.error("Cannot parse XML data for TV show: %s", xml.attrib)
|
LOG.error("Cannot parse XML data for TV show: %s", xml.attrib)
|
||||||
return
|
return
|
||||||
show = self.plexdb.show(plex_id)
|
show = self.plexdb.show(plex_id)
|
||||||
try:
|
if not show:
|
||||||
kodi_id = show['kodi_id']
|
|
||||||
kodi_pathid = show['kodi_pathid']
|
|
||||||
except TypeError:
|
|
||||||
update_item = False
|
update_item = False
|
||||||
query = 'SELECT COALESCE(MAX(idShow), 0) FROM tvshow'
|
query = 'SELECT COALESCE(MAX(idShow), 0) FROM tvshow'
|
||||||
self.kodicursor.execute(query)
|
self.kodicursor.execute(query)
|
||||||
kodi_id = self.kodicursor.fetchone()[0] + 1
|
kodi_id = self.kodicursor.fetchone()[0] + 1
|
||||||
else:
|
else:
|
||||||
|
update_item = True
|
||||||
|
kodi_id = show['kodi_id']
|
||||||
|
kodi_pathid = show['kodi_pathid']
|
||||||
# Verification the item is still in Kodi
|
# Verification the item is still in Kodi
|
||||||
self.kodicursor.execute('SELECT * FROM tvshow WHERE idShow = ?',
|
self.kodicursor.execute('SELECT * FROM tvshow WHERE idShow = ?',
|
||||||
(kodi_id,))
|
(kodi_id,))
|
||||||
|
|
Loading…
Reference in a new issue