mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
Merge pull request #305 from mcarlton00/incremental-sync
Only request updates for synced libraries
This commit is contained in:
commit
60e80254ec
1 changed files with 31 additions and 31 deletions
|
@ -372,21 +372,36 @@ class Library(threading.Thread):
|
||||||
''' Movie and userdata not provided by server yet.
|
''' Movie and userdata not provided by server yet.
|
||||||
'''
|
'''
|
||||||
last_sync = settings('LastIncrementalSync')
|
last_sync = settings('LastIncrementalSync')
|
||||||
|
include = []
|
||||||
filters = ["tvshows", "boxsets", "musicvideos", "music", "movies"]
|
filters = ["tvshows", "boxsets", "musicvideos", "music", "movies"]
|
||||||
sync = get_sync()
|
sync = get_sync()
|
||||||
LOG.info("--[ retrieve changes ] %s", last_sync)
|
LOG.info("--[ retrieve changes ] %s", last_sync)
|
||||||
|
|
||||||
|
# Get the item type of each synced library and build list of types to request
|
||||||
|
for item_id in sync['Whitelist']:
|
||||||
|
library = self.server.jellyfin.get_item(item_id)
|
||||||
|
library_type = library.get('CollectionType')
|
||||||
|
if library_type in filters:
|
||||||
|
include.append(library_type)
|
||||||
|
|
||||||
|
# Include boxsets if movies are synced
|
||||||
|
if 'movies' in include:
|
||||||
|
include.append('boxsets')
|
||||||
|
|
||||||
|
# Filter down to the list of library types we want to exclude
|
||||||
|
query_filter = list(set(filters) - set(include))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
updated = []
|
updated = []
|
||||||
userdata = []
|
userdata = []
|
||||||
removed = []
|
removed = []
|
||||||
|
|
||||||
for media in filters:
|
# Get list of updates from server for synced library types and populate work queues
|
||||||
result = self.server.jellyfin.get_sync_queue(last_sync, ",".join([x for x in filters if x != media]))
|
result = self.server.jellyfin.get_sync_queue(last_sync, ",".join([ x for x in query_filter ]))
|
||||||
updated.extend(result['ItemsAdded'])
|
updated.extend(result['ItemsAdded'])
|
||||||
updated.extend(result['ItemsUpdated'])
|
updated.extend(result['ItemsUpdated'])
|
||||||
userdata.extend(result['UserDataChanged'])
|
userdata.extend(result['UserDataChanged'])
|
||||||
removed.extend(result['ItemsRemoved'])
|
removed.extend(result['ItemsRemoved'])
|
||||||
|
|
||||||
total = len(updated) + len(userdata)
|
total = len(updated) + len(userdata)
|
||||||
|
|
||||||
|
@ -403,22 +418,6 @@ class Library(threading.Thread):
|
||||||
self.userdata(userdata)
|
self.userdata(userdata)
|
||||||
self.removed(removed)
|
self.removed(removed)
|
||||||
|
|
||||||
"""
|
|
||||||
result = self.server.jellyfin.get_sync_queue(last_sync)
|
|
||||||
self.userdata(result['UserDataChanged'])
|
|
||||||
self.removed(result['ItemsRemoved'])
|
|
||||||
|
|
||||||
|
|
||||||
filters.extend(["tvshows", "boxsets", "musicvideos", "music"])
|
|
||||||
|
|
||||||
# Get only movies.
|
|
||||||
result = self.server.jellyfin.get_sync_queue(last_sync, ",".join(filters))
|
|
||||||
self.updated(result['ItemsAdded'])
|
|
||||||
self.updated(result['ItemsUpdated'])
|
|
||||||
self.userdata(result['UserDataChanged'])
|
|
||||||
self.removed(result['ItemsRemoved'])
|
|
||||||
"""
|
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
LOG.exception(error)
|
LOG.exception(error)
|
||||||
|
|
||||||
|
@ -715,18 +714,19 @@ class SortWorker(threading.Thread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
media = database.get_media_by_id(item_id)
|
media = database.get_media_by_id(item_id)
|
||||||
self.output[media].put({'Id': item_id, 'Type': media})
|
if media:
|
||||||
|
self.output[media].put({'Id': item_id, 'Type': media})
|
||||||
|
else:
|
||||||
|
items = database.get_media_by_parent_id(item_id)
|
||||||
|
|
||||||
|
if not items:
|
||||||
|
LOG.info("Could not find media %s in the jellyfin database.", item_id)
|
||||||
|
else:
|
||||||
|
for item in items:
|
||||||
|
self.output[item[1]].put({'Id': item[0], 'Type': item[1]})
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
LOG.exception(error)
|
LOG.exception(error)
|
||||||
|
|
||||||
items = database.get_media_by_parent_id(item_id)
|
|
||||||
|
|
||||||
if not items:
|
|
||||||
LOG.info("Could not find media %s in the jellyfin database.", item_id)
|
|
||||||
else:
|
|
||||||
for item in items:
|
|
||||||
self.output[item[1]].put({'Id': item[0], 'Type': item[1]})
|
|
||||||
|
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
|
|
||||||
if window('jellyfin_should_stop.bool'):
|
if window('jellyfin_should_stop.bool'):
|
||||||
|
|
Loading…
Reference in a new issue