Cleanup code around removing libraries

This commit is contained in:
Matt 2020-03-28 23:25:13 -04:00
parent 97de6f9d11
commit aeca1a0049
3 changed files with 13 additions and 35 deletions

View file

@ -11,6 +11,7 @@ from kodi_six import xbmc
import downloader as server
import helper.xmls as xmls
from objects import Movies, TVShows, MusicVideos, Music
from database import Database, get_sync, save_sync, jellyfin_db
from helper import translate, settings, window, progress, dialog, LibraryException
from helper.utils import get_screensaver, set_screensaver
@ -261,7 +262,6 @@ class FullSync(object):
''' Process movies from a single library.
'''
Movies = self.library.media['Movies']
processed_ids = []
for items in server.get_items(library['Id'], "Movie", False, self.sync['RestorePoint'].get('params')):
@ -305,7 +305,6 @@ class FullSync(object):
''' Process tvshows and episodes from a single library.
'''
TVShows = self.library.media['TVShows']
processed_ids = []
for items in server.get_items(library['Id'], "Series", False, self.sync['RestorePoint'].get('params')):
@ -358,7 +357,6 @@ class FullSync(object):
''' Process musicvideos from a single library.
'''
MusicVideos = self.library.media['MusicVideos']
processed_ids = []
for items in server.get_items(library['Id'], "MusicVideo", False, self.sync['RestorePoint'].get('params')):
@ -401,8 +399,6 @@ class FullSync(object):
''' Process artists, album, songs from a single library.
'''
Music = self.library.media['Music']
with self.library.music_database_lock:
with Database('music') as musicdb:
with Database('jellyfin') as jellyfindb:
@ -462,8 +458,6 @@ class FullSync(object):
''' Process all boxsets.
'''
Movies = self.library.media['Movies']
for items in server.get_items(library_id, "BoxSet", False, self.sync['RestorePoint'].get('params')):
with self.video_database_locks() as (videodb, jellyfindb):
@ -483,8 +477,6 @@ class FullSync(object):
''' Delete all exisitng boxsets and re-add.
'''
Movies = self.library.media['Movies']
with self.video_database_locks() as (videodb, jellyfindb):
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
obj.boxsets_reset()
@ -496,7 +488,6 @@ class FullSync(object):
''' Remove library by their id from the Kodi database.
'''
MEDIA = self.library.MEDIA
direct_path = self.library.direct_path
with Database('jellyfin') as jellyfindb:
@ -536,16 +527,16 @@ class FullSync(object):
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (translate('addon_name'), library[0]))
count += 1
else:
# from mcarlton: I'm not sure what triggers this.
# I've added and removed every media type except
# for music videos (because i don't have any) and
# can't find it, but I'm not comfortable
# removing it right now
LOG.info('Triggered the mystery function')
LOG.debug('Mystery function item type: {}'.format(items[0][1]))
obj = MEDIA[items[0][1]](self.server, jellyfindb, kodidb, direct_path).remove
default_args = (self.server, jellyfindb, kodidb, direct_path)
for item in items:
if item[1] in ('Series', 'Season', 'Episode'):
obj = TVShows(*default_args).remove
elif item[1] in ('Movie', 'BoxSet'):
obj = Movies(*default_args).remove
elif item[1] in ('MusicAlbum', 'MusicArtist', 'AlbumArtist', 'Audio'):
obj = Music(*default_args).remove
elif item[1] == 'MusicVideo':
obj = MusicVideos(*default_args).remove
obj(item[0])
dialog.update(int((float(count) / float(len(items)) * 100)), heading="%s: %s" % (translate('addon_name'), library[0]))
@ -560,6 +551,7 @@ class FullSync(object):
self.sync['Whitelist'].remove('Mixed:%s' % library_id)
save_sync(self.sync)
xbmc.executebuiltin('ReloadSkin()')
def __exit__(self, exc_type, exc_val, exc_tb):

View file

@ -25,18 +25,6 @@ from jellyfin import Jellyfin
LOG = logging.getLogger("JELLYFIN." + __name__)
LIMIT = int(settings('limitIndex') or 15)
DTHREADS = int(settings('limitThreads') or 3)
MEDIA = {
'Movie': Movies,
'BoxSet': Movies,
'MusicVideo': MusicVideos,
'Series': TVShows,
'Season': TVShows,
'Episode': TVShows,
'MusicAlbum': Music,
'MusicArtist': Music,
'AlbumArtist': Music,
'Audio': Music
}
##################################################################################################
@ -53,9 +41,6 @@ class Library(threading.Thread):
def __init__(self, monitor):
self.media = {'Movies': Movies, 'TVShows': TVShows, 'MusicVideos': MusicVideos, 'Music': Music}
self.MEDIA = MEDIA
self.direct_path = settings('useDirectPaths') == "1"
self.progress_display = int(settings('syncProgress') or 50)
self.monitor = monitor
@ -633,7 +618,7 @@ class UpdateWorker(threading.Thread):
elif item['Type'] == 'MusicArtist':
obj = Music(*default_args).artist
elif item['Type'] == 'AlbumArtist':
obj = Music(*default_args).albumartist
obj = Music(s*default_args).albumartist
elif item['Type'] == 'Audio':
obj = Music(*default_args).song

View file

@ -46,6 +46,7 @@ class Monitor(xbmc.Monitor):
LOG.info("-->[ kodi scan/%s ]", library)
def onScanFinished(self, library):
xbmc.executebuiltin("ReloadSkin()")
LOG.info("--<[ kodi scan/%s ]", library)
def onNotification(self, sender, method, data):