Merge pull request #201 from druscoe/in_progress_ui_updates

Allow for UI updates as the library is being sync'ed
This commit is contained in:
mcarlton00 2020-02-20 19:20:07 -05:00 committed by GitHub
commit 2fbdd191d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
##################################################################################################
from contextlib import contextmanager
import datetime
import logging
@ -248,6 +249,13 @@ class FullSync(object):
raise
@contextmanager
def video_database_locks(self):
with self.library.database_lock:
with Database() as videodb:
with Database('jellyfin') as jellyfindb:
yield videodb, jellyfindb
@progress()
def movies(self, library, dialog):
@ -255,14 +263,11 @@ class FullSync(object):
'''
Movies = self.library.media['Movies']
with self.library.database_lock:
with Database() as videodb:
with Database('jellyfin') as jellyfindb:
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
for items in server.get_items(library['Id'], "Movie", False, self.sync['RestorePoint'].get('params')):
with self.video_database_locks() as (videodb, jellyfindb):
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']
@ -273,6 +278,9 @@ class FullSync(object):
message=movie['Name'])
obj.movie(movie, library=library)
with self.video_database_locks() as (videodb, jellyfindb):
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
if self.update_library:
self.movies_compare(library, obj, jellyfindb)
@ -296,13 +304,11 @@ class FullSync(object):
'''
TVShows = self.library.media['TVShows']
with self.library.database_lock:
with Database() as videodb:
with Database('jellyfin') as jellyfindb:
obj = TVShows(self.server, jellyfindb, videodb, self.direct_path, True)
for items in server.get_items(library['Id'], "Series", False, self.sync['RestorePoint'].get('params')):
with self.video_database_locks() as (videodb, jellyfindb):
obj = TVShows(self.server, jellyfindb, videodb, self.direct_path, True)
self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']
@ -320,6 +326,8 @@ class FullSync(object):
dialog.update(percent, message="%s/%s" % (message, episode['Name'][:10]))
obj.episode(episode)
with self.video_database_locks() as (videodb, jellyfindb):
obj = TVShows(self.server, jellyfindb, videodb, self.direct_path, True)
if self.update_library:
self.tvshows_compare(library, obj, jellyfindb)
@ -346,13 +354,11 @@ class FullSync(object):
'''
MusicVideos = self.library.media['MusicVideos']
with self.library.database_lock:
with Database() as videodb:
with Database('jellyfin') as jellyfindb:
obj = MusicVideos(self.server, jellyfindb, videodb, self.direct_path)
for items in server.get_items(library['Id'], "MusicVideo", False, self.sync['RestorePoint'].get('params')):
with self.video_database_locks() as (videodb, jellyfindb):
obj = MusicVideos(self.server, jellyfindb, videodb, self.direct_path)
self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']
@ -363,6 +369,8 @@ class FullSync(object):
message=mvideo['Name'])
obj.musicvideo(mvideo, library=library)
with self.video_database_locks() as (videodb, jellyfindb):
obj = MusicVideos(self.server, jellyfindb, videodb, self.direct_path)
if self.update_library:
self.musicvideos_compare(library, obj, jellyfindb)
@ -447,13 +455,11 @@ class FullSync(object):
'''
Movies = self.library.media['Movies']
with self.library.database_lock:
with Database() as videodb:
with Database('jellyfin') as jellyfindb:
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
for items in server.get_items(library_id, "BoxSet", False, self.sync['RestorePoint'].get('params')):
with self.video_database_locks() as (videodb, jellyfindb):
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']
@ -470,10 +476,7 @@ class FullSync(object):
'''
Movies = self.library.media['Movies']
with self.library.database_lock:
with Database() as videodb:
with Database('jellyfin') as jellyfindb:
with self.video_database_locks() as (videodb, jellyfindb):
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
obj.boxsets_reset()