mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Only request updates for synced libraries
This commit is contained in:
parent
66ef0a5100
commit
d6b68f44ea
1 changed files with 31 additions and 31 deletions
|
@ -372,17 +372,32 @@ 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'])
|
||||||
|
@ -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,10 +714,9 @@ class SortWorker(threading.Thread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
media = database.get_media_by_id(item_id)
|
media = database.get_media_by_id(item_id)
|
||||||
|
if media:
|
||||||
self.output[media].put({'Id': item_id, 'Type': media})
|
self.output[media].put({'Id': item_id, 'Type': media})
|
||||||
except Exception as error:
|
else:
|
||||||
LOG.exception(error)
|
|
||||||
|
|
||||||
items = database.get_media_by_parent_id(item_id)
|
items = database.get_media_by_parent_id(item_id)
|
||||||
|
|
||||||
if not items:
|
if not items:
|
||||||
|
@ -726,6 +724,8 @@ class SortWorker(threading.Thread):
|
||||||
else:
|
else:
|
||||||
for item in items:
|
for item in items:
|
||||||
self.output[item[1]].put({'Id': item[0], 'Type': item[1]})
|
self.output[item[1]].put({'Id': item[0], 'Type': item[1]})
|
||||||
|
except Exception as error:
|
||||||
|
LOG.exception(error)
|
||||||
|
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue