Merge pull request #635 from croneter/fix_slow_playback_startup

Hopefully fix slow playback startup just after Kodi startup
This commit is contained in:
croneter 2019-01-28 20:22:05 +01:00 committed by GitHub
commit 0278e16de0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -29,7 +29,7 @@ def kodiid_from_filename(path, kodi_type=None, db_type=None):
filename = path.rsplit('\\', 1)[1] filename = path.rsplit('\\', 1)[1]
path = path.rsplit('\\', 1)[0] + '\\' path = path.rsplit('\\', 1)[0] + '\\'
if kodi_type == v.KODI_TYPE_SONG or db_type == 'music': if kodi_type == v.KODI_TYPE_SONG or db_type == 'music':
with KodiMusicDB() as kodidb: with KodiMusicDB(lock=False) as kodidb:
try: try:
kodi_id = kodidb.song_id_from_filename(filename, path) kodi_id = kodidb.song_id_from_filename(filename, path)
except TypeError: except TypeError:
@ -37,7 +37,7 @@ def kodiid_from_filename(path, kodi_type=None, db_type=None):
else: else:
kodi_type = v.KODI_TYPE_SONG kodi_type = v.KODI_TYPE_SONG
else: else:
with KodiVideoDB() as kodidb: with KodiVideoDB(lock=False) as kodidb:
try: try:
kodi_id, kodi_type = kodidb.video_id_from_filename(filename, kodi_id, kodi_type = kodidb.video_id_from_filename(filename,
path) path)

View file

@ -23,7 +23,7 @@ else:
LOG = getLogger('PLEX.sync.full_sync') LOG = getLogger('PLEX.sync.full_sync')
# How many items will be put through the processing chain at once? # How many items will be put through the processing chain at once?
BATCH_SIZE = 2000 BATCH_SIZE = 200
# Safety margin to filter PMS items - how many seconds to look into the past? # Safety margin to filter PMS items - how many seconds to look into the past?
UPDATED_AT_SAFETY = 60 * 5 UPDATED_AT_SAFETY = 60 * 5
LAST_VIEWED_AT_SAFETY = 60 * 5 LAST_VIEWED_AT_SAFETY = 60 * 5

View file

@ -320,7 +320,7 @@ def playlist_item_from_kodi(kodi_item):
item.kodi_id = kodi_item.get('id') item.kodi_id = kodi_item.get('id')
item.kodi_type = kodi_item.get('type') item.kodi_type = kodi_item.get('type')
if item.kodi_id: if item.kodi_id:
with PlexDB() as plexdb: with PlexDB(lock=False) as plexdb:
db_item = plexdb.item_by_kodi_id(kodi_item['id'], kodi_item['type']) db_item = plexdb.item_by_kodi_id(kodi_item['id'], kodi_item['type'])
if db_item: if db_item:
item.plex_id = db_item['plex_id'] item.plex_id = db_item['plex_id']
@ -397,7 +397,7 @@ def playlist_item_from_plex(plex_id):
""" """
item = Playlist_Item() item = Playlist_Item()
item.plex_id = plex_id item.plex_id = plex_id
with PlexDB() as plexdb: with PlexDB(lock=False) as plexdb:
db_item = plexdb.item_by_id(plex_id) db_item = plexdb.item_by_id(plex_id)
if db_item: if db_item:
item.plex_type = db_item['plex_type'] item.plex_type = db_item['plex_type']
@ -429,7 +429,7 @@ def playlist_item_from_xml(xml_video_element, kodi_id=None, kodi_type=None):
item.kodi_id = kodi_id item.kodi_id = kodi_id
item.kodi_type = kodi_type item.kodi_type = kodi_type
elif item.plex_id is not None and item.plex_type != v.PLEX_TYPE_CLIP: elif item.plex_id is not None and item.plex_type != v.PLEX_TYPE_CLIP:
with PlexDB() as plexdb: with PlexDB(lock=False) as plexdb:
db_element = plexdb.item_by_id(item.plex_id) db_element = plexdb.item_by_id(item.plex_id)
if db_element: if db_element:
item.kodi_id = db_element['kodi_id'] item.kodi_id = db_element['kodi_id']