Remove library_check wrapper

This commit is contained in:
Matt 2020-08-02 17:00:34 -04:00
parent 0ee5b616a5
commit eca9630918
9 changed files with 129 additions and 188 deletions

View file

@ -270,7 +270,7 @@ class FullSync(object):
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)
obj = Movies(self.server, jellyfindb, videodb, self.direct_path, library)
self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']
@ -280,11 +280,11 @@ class FullSync(object):
dialog.update(int((float(start_index + index) / float(items['TotalRecordCount'])) * 100),
heading="%s: %s" % (translate('addon_name'), library['Name']),
message=movie['Name'])
obj.movie(movie, library=library)
obj.movie(movie)
processed_ids.append(movie['Id'])
with self.video_database_locks() as (videodb, jellyfindb):
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
obj = Movies(self.server, jellyfindb, videodb, self.direct_path, library)
obj.item_ids = processed_ids
if self.update_library:
@ -313,7 +313,7 @@ class FullSync(object):
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)
obj = TVShows(self.server, jellyfindb, videodb, self.direct_path, library, True)
self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']
@ -324,7 +324,7 @@ class FullSync(object):
message = show['Name']
dialog.update(percent, heading="%s: %s" % (translate('addon_name'), library['Name']), message=message)
if obj.tvshow(show, library=library) is not False:
if obj.tvshow(show) is not False:
for episodes in server.get_episode_by_show(show['Id']):
for episode in episodes['Items']:
@ -334,7 +334,7 @@ class FullSync(object):
processed_ids.append(show['Id'])
with self.video_database_locks() as (videodb, jellyfindb):
obj = TVShows(self.server, jellyfindb, videodb, self.direct_path, True)
obj = TVShows(self.server, jellyfindb, videodb, self.direct_path, library, True)
obj.item_ids = processed_ids
if self.update_library:
self.tvshows_compare(library, obj, jellyfindb)
@ -365,7 +365,7 @@ class FullSync(object):
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)
obj = MusicVideos(self.server, jellyfindb, videodb, self.direct_path, library)
self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']
@ -375,11 +375,11 @@ class FullSync(object):
dialog.update(int((float(start_index + index) / float(items['TotalRecordCount'])) * 100),
heading="%s: %s" % (translate('addon_name'), library['Name']),
message=mvideo['Name'])
obj.musicvideo(mvideo, library=library)
obj.musicvideo(mvideo)
processed_ids.append(mvideo['Id'])
with self.video_database_locks() as (videodb, jellyfindb):
obj = MusicVideos(self.server, jellyfindb, videodb, self.direct_path)
obj = MusicVideos(self.server, jellyfindb, videodb, self.direct_path, library)
obj.item_ids = processed_ids
if self.update_library:
self.musicvideos_compare(library, obj, jellyfindb)
@ -405,9 +405,11 @@ class FullSync(object):
with self.library.music_database_lock:
with Database('music') as musicdb:
with Database('jellyfin') as jellyfindb:
obj = Music(self.server, jellyfindb, musicdb, self.direct_path)
obj = Music(self.server, jellyfindb, musicdb, self.direct_path, library)
library_id = library['Id']
# Get all items in the library to process locally
artists_data = server.get_artists(library_id)
artists = artists_data['Items']
num_artists = artists_data['TotalRecordCount']
@ -417,53 +419,27 @@ class FullSync(object):
for index, artist in enumerate(artists):
artist_name = artist.get('Name')
# Update percentage dialog
percent = int((float(index) / float(num_artists)) * 100)
message = artist_name
dialog.update(percent, heading="%s: %s" % (translate('addon_name'), library['Name']), message=message)
obj.artist(artist, library=library)
# Add artist to database
obj.artist(artist)
# Get all albums for each artist
artist_albums = [ album for album in albums if artist_name in album.get('Artists') ]
for album in artist_albums:
# Add album to database
obj.album(album)
album_id = album.get('Id')
# Get all songs in each album
album_songs = [ song for song in songs if album_id == song.get('AlbumId') ]
for song in album_songs:
dialog.update(percent,
message="%s/%s/%s" % (message, album['Name'][:7], song['Name'][:7]))
# Add song to database
obj.song(song)
# for items in server.get_artists(library['Id'], False, self.sync['RestorePoint'].get('params')):
#
# self.sync['RestorePoint'] = items['RestorePoint']
# start_index = items['RestorePoint']['params']['StartIndex']
#
# for index, artist in enumerate(items['Items']):
#
# percent = int((float(start_index + index) / float(items['TotalRecordCount'])) * 100)
# message = artist['Name']
# dialog.update(percent, heading="%s: %s" % (translate('addon_name'), library['Name']), message=message)
# obj.artist(artist, library=library)
#
# import web_pdb; web_pdb.set_trace()
# for albums in server.get_albums_by_artist(artist['Id']):
#
# for album in albums['Items']:
# obj.album(album)
#
# for songs in server.get_items(album['Id'], "Audio"):
# for song in songs['Items']:
#
# dialog.update(percent,
# message="%s/%s/%s" % (message, album['Name'][:7], song['Name'][:7]))
# obj.song(song)
#
# for songs in server.get_songs_by_artist(artist['Id']):
# for song in songs['Items']:
#
# dialog.update(percent, message="%s/%s" % (message, song['Name']))
# obj.song(song)
#
if self.update_library:
self.music_compare(library, obj, jellyfindb)
@ -492,7 +468,7 @@ class FullSync(object):
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)
obj = Movies(self.server, jellyfindb, videodb, self.direct_path, library)
self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']
@ -509,7 +485,7 @@ class FullSync(object):
''' Delete all exisitng boxsets and re-add.
'''
with self.video_database_locks() as (videodb, jellyfindb):
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
obj = Movies(self.server, jellyfindb, videodb, self.direct_path, library)
obj.boxsets_reset()
self.boxsets(None)
@ -542,7 +518,7 @@ class FullSync(object):
movies = [x for x in items if x[1] == 'Movie']
tvshows = [x for x in items if x[1] == 'Series']
obj = Movies(self.server, jellyfindb, kodidb, direct_path).remove
obj = Movies(self.server, jellyfindb, kodidb, direct_path, library).remove
for item in movies:
@ -550,7 +526,7 @@ class FullSync(object):
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (translate('addon_name'), library[0]))
count += 1
obj = TVShows(self.server, jellyfindb, kodidb, direct_path).remove
obj = TVShows(self.server, jellyfindb, kodidb, direct_path, library).remove
for item in tvshows: