Fix some items rarely not being synced
This commit is contained in:
parent
889b6094d9
commit
3b9fce7470
4 changed files with 18 additions and 7 deletions
|
@ -263,13 +263,15 @@ class Movie(ItemBase):
|
||||||
"""
|
"""
|
||||||
Updates the Kodi watched state of the item from PMS. Also retrieves
|
Updates the Kodi watched state of the item from PMS. Also retrieves
|
||||||
Plex resume points for movies in progress.
|
Plex resume points for movies in progress.
|
||||||
|
|
||||||
|
Returns True if successful, False otherwise (e.g. item missing)
|
||||||
"""
|
"""
|
||||||
api = API(xml_element)
|
api = API(xml_element)
|
||||||
# Get key and db entry on the Kodi db side
|
# Get key and db entry on the Kodi db side
|
||||||
db_item = self.plexdb.item_by_id(api.plex_id(), plex_type)
|
db_item = self.plexdb.item_by_id(api.plex_id(), plex_type)
|
||||||
if not db_item:
|
if not db_item:
|
||||||
LOG.error('Item not yet synced: %s', xml_element.attrib)
|
LOG.info('Item not yet synced: %s', xml_element.attrib)
|
||||||
return
|
return False
|
||||||
# Grab the user's viewcount, resume points etc. from PMS' answer
|
# Grab the user's viewcount, resume points etc. from PMS' answer
|
||||||
userdata = api.userdata()
|
userdata = api.userdata()
|
||||||
# Write to Kodi DB
|
# Write to Kodi DB
|
||||||
|
@ -282,3 +284,4 @@ class Movie(ItemBase):
|
||||||
self.kodidb.update_userrating(db_item['kodi_id'],
|
self.kodidb.update_userrating(db_item['kodi_id'],
|
||||||
db_item['kodi_type'],
|
db_item['kodi_type'],
|
||||||
userdata['UserRating'])
|
userdata['UserRating'])
|
||||||
|
return True
|
||||||
|
|
|
@ -37,13 +37,15 @@ class MusicMixin(object):
|
||||||
"""
|
"""
|
||||||
Updates the Kodi watched state of the item from PMS. Also retrieves
|
Updates the Kodi watched state of the item from PMS. Also retrieves
|
||||||
Plex resume points for movies in progress.
|
Plex resume points for movies in progress.
|
||||||
|
|
||||||
|
Returns True if successful, False otherwise (e.g. item missing)
|
||||||
"""
|
"""
|
||||||
api = API(xml_element)
|
api = API(xml_element)
|
||||||
# Get key and db entry on the Kodi db side
|
# Get key and db entry on the Kodi db side
|
||||||
db_item = self.plexdb.item_by_id(api.plex_id(), plex_type)
|
db_item = self.plexdb.item_by_id(api.plex_id(), plex_type)
|
||||||
if not db_item:
|
if not db_item:
|
||||||
LOG.error('Item not yet synced: %s', xml_element.attrib)
|
LOG.info('Item not yet synced: %s', xml_element.attrib)
|
||||||
return
|
return False
|
||||||
# Grab the user's viewcount, resume points etc. from PMS' answer
|
# Grab the user's viewcount, resume points etc. from PMS' answer
|
||||||
userdata = api.userdata()
|
userdata = api.userdata()
|
||||||
self.kodidb.update_userrating(db_item['kodi_id'],
|
self.kodidb.update_userrating(db_item['kodi_id'],
|
||||||
|
@ -56,6 +58,7 @@ class MusicMixin(object):
|
||||||
userdata['PlayCount'],
|
userdata['PlayCount'],
|
||||||
userdata['LastPlayedDate'],
|
userdata['LastPlayedDate'],
|
||||||
plex_type)
|
plex_type)
|
||||||
|
return True
|
||||||
|
|
||||||
def remove(self, plex_id, plex_type=None):
|
def remove(self, plex_id, plex_type=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -20,8 +20,8 @@ class TvShowMixin(object):
|
||||||
# Get key and db entry on the Kodi db side
|
# Get key and db entry on the Kodi db side
|
||||||
db_item = self.plexdb.item_by_id(api.plex_id(), plex_type)
|
db_item = self.plexdb.item_by_id(api.plex_id(), plex_type)
|
||||||
if not db_item:
|
if not db_item:
|
||||||
LOG.error('Item not yet synced: %s', xml_element.attrib)
|
LOG.info('Item not yet synced: %s', xml_element.attrib)
|
||||||
return
|
return False
|
||||||
# Grab the user's viewcount, resume points etc. from PMS' answer
|
# Grab the user's viewcount, resume points etc. from PMS' answer
|
||||||
userdata = api.userdata()
|
userdata = api.userdata()
|
||||||
self.kodidb.update_userrating(db_item['kodi_id'],
|
self.kodidb.update_userrating(db_item['kodi_id'],
|
||||||
|
@ -34,6 +34,7 @@ class TvShowMixin(object):
|
||||||
userdata['PlayCount'],
|
userdata['PlayCount'],
|
||||||
userdata['LastPlayedDate'],
|
userdata['LastPlayedDate'],
|
||||||
plex_type)
|
plex_type)
|
||||||
|
return True
|
||||||
|
|
||||||
def remove(self, plex_id, plex_type=None):
|
def remove(self, plex_id, plex_type=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -229,7 +229,11 @@ class FullSync(common.fullsync_mixin):
|
||||||
for i, (last, xml_item) in enumerate(loop):
|
for i, (last, xml_item) in enumerate(loop):
|
||||||
if self.isCanceled():
|
if self.isCanceled():
|
||||||
return False
|
return False
|
||||||
itemtype.update_userdata(xml_item, section['plex_type'])
|
if not itemtype.update_userdata(xml_item, section['plex_type']):
|
||||||
|
# Somehow did not sync this item yet
|
||||||
|
itemtype.add_update(xml_item,
|
||||||
|
section['section_name'],
|
||||||
|
section['section_id'])
|
||||||
itemtype.plexdb.update_last_sync(int(xml_item.attrib['ratingKey']),
|
itemtype.plexdb.update_last_sync(int(xml_item.attrib['ratingKey']),
|
||||||
section['plex_type'],
|
section['plex_type'],
|
||||||
self.current_sync)
|
self.current_sync)
|
||||||
|
|
Loading…
Reference in a new issue