Sync name and user rating of a TV show season to Kodi
This commit is contained in:
parent
07ed0d1105
commit
9150e168f6
3 changed files with 40 additions and 7 deletions
|
@ -270,6 +270,7 @@ class Show(TvShowMixin, ItemBase):
|
||||||
unique_ids.get('imdb',
|
unique_ids.get('imdb',
|
||||||
unique_ids.get('tmdb')))
|
unique_ids.get('tmdb')))
|
||||||
|
|
||||||
|
|
||||||
class Season(TvShowMixin, ItemBase):
|
class Season(TvShowMixin, ItemBase):
|
||||||
def add_update(self, xml, section_name=None, section_id=None,
|
def add_update(self, xml, section_name=None, section_id=None,
|
||||||
children=None):
|
children=None):
|
||||||
|
@ -279,7 +280,7 @@ class Season(TvShowMixin, ItemBase):
|
||||||
api = API(xml)
|
api = API(xml)
|
||||||
if not self.sync_this_item(section_id or api.library_section_id()):
|
if not self.sync_this_item(section_id or api.library_section_id()):
|
||||||
LOG.debug('Skipping sync of %s %s: %s - section %s not synched to '
|
LOG.debug('Skipping sync of %s %s: %s - section %s not synched to '
|
||||||
'Kodi', api.plex_type, api.plex_id, api.title(),
|
'Kodi', api.plex_type, api.plex_id, api.season_name(),
|
||||||
section_id or api.library_section_id())
|
section_id or api.library_section_id())
|
||||||
return
|
return
|
||||||
plex_id = api.plex_id
|
plex_id = api.plex_id
|
||||||
|
@ -317,15 +318,24 @@ class Season(TvShowMixin, ItemBase):
|
||||||
if key in artwork and artwork[key] == parent_artwork[key]:
|
if key in artwork and artwork[key] == parent_artwork[key]:
|
||||||
del artwork[key]
|
del artwork[key]
|
||||||
if update_item:
|
if update_item:
|
||||||
LOG.info('UPDATE season plex_id %s - %s', plex_id, api.title())
|
LOG.info('UPDATE season plex_id %s - %s',
|
||||||
|
plex_id, api.season_name())
|
||||||
kodi_id = season['kodi_id']
|
kodi_id = season['kodi_id']
|
||||||
|
self.kodidb.update_season(kodi_id,
|
||||||
|
parent_id,
|
||||||
|
api.index(),
|
||||||
|
api.season_name(),
|
||||||
|
api.userrating() or None)
|
||||||
if app.SYNC.artwork:
|
if app.SYNC.artwork:
|
||||||
self.kodidb.modify_artwork(artwork,
|
self.kodidb.modify_artwork(artwork,
|
||||||
kodi_id,
|
kodi_id,
|
||||||
v.KODI_TYPE_SEASON)
|
v.KODI_TYPE_SEASON)
|
||||||
else:
|
else:
|
||||||
LOG.info('ADD season plex_id %s - %s', plex_id, api.title())
|
LOG.info('ADD season plex_id %s - %s', plex_id, api.season_name())
|
||||||
kodi_id = self.kodidb.add_season(parent_id, api.index())
|
kodi_id = self.kodidb.add_season(parent_id,
|
||||||
|
api.index(),
|
||||||
|
api.season_name(),
|
||||||
|
api.userrating() or None)
|
||||||
if app.SYNC.artwork:
|
if app.SYNC.artwork:
|
||||||
self.kodidb.add_artwork(artwork,
|
self.kodidb.add_artwork(artwork,
|
||||||
kodi_id,
|
kodi_id,
|
||||||
|
|
|
@ -718,15 +718,32 @@ class KodiVideoDB(common.KodiDBBase):
|
||||||
self.cursor.execute('DELETE FROM sets WHERE idSet = ?', (set_id,))
|
self.cursor.execute('DELETE FROM sets WHERE idSet = ?', (set_id,))
|
||||||
|
|
||||||
@db.catch_operationalerrors
|
@db.catch_operationalerrors
|
||||||
def add_season(self, showid, seasonnumber):
|
def add_season(self, showid, seasonnumber, name, userrating):
|
||||||
"""
|
"""
|
||||||
Adds a TV show season to the Kodi video DB or simply returns the ID,
|
Adds a TV show season to the Kodi video DB or simply returns the ID,
|
||||||
if there already is an entry in the DB
|
if there already is an entry in the DB
|
||||||
"""
|
"""
|
||||||
self.cursor.execute('INSERT INTO seasons(idShow, season) VALUES (?, ?)',
|
self.cursor.execute('''
|
||||||
(showid, seasonnumber))
|
INSERT INTO seasons(
|
||||||
|
idShow, season, name, userrating)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
''', (showid, seasonnumber, name, userrating))
|
||||||
return self.cursor.lastrowid
|
return self.cursor.lastrowid
|
||||||
|
|
||||||
|
@db.catch_operationalerrors
|
||||||
|
def update_season(self, seasonid, showid, seasonnumber, name, userrating):
|
||||||
|
"""
|
||||||
|
Updates a TV show season with a certain seasonid
|
||||||
|
"""
|
||||||
|
self.cursor.execute('''
|
||||||
|
UPDATE seasons
|
||||||
|
SET idShow = ?,
|
||||||
|
season = ?,
|
||||||
|
name = ?,
|
||||||
|
userrating = ?
|
||||||
|
WHERE idSeason = ?
|
||||||
|
''', (showid, seasonnumber, name, userrating, seasonid))
|
||||||
|
|
||||||
@db.catch_operationalerrors
|
@db.catch_operationalerrors
|
||||||
def add_uniqueid(self, *args):
|
def add_uniqueid(self, *args):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -398,6 +398,12 @@ class Base(object):
|
||||||
"""
|
"""
|
||||||
return self.parent_index()
|
return self.parent_index()
|
||||||
|
|
||||||
|
def season_name(self):
|
||||||
|
"""
|
||||||
|
Returns the season's name/title or None
|
||||||
|
"""
|
||||||
|
return self.xml.get('title')
|
||||||
|
|
||||||
def artist_name(self):
|
def artist_name(self):
|
||||||
"""
|
"""
|
||||||
Returns the artist name for an album: first it attempts to return
|
Returns the artist name for an album: first it attempts to return
|
||||||
|
|
Loading…
Reference in a new issue