Fix incremental sync, cleanup more getitem shenanigans

This commit is contained in:
Matt 2019-09-27 22:38:37 -04:00
parent f9335ad566
commit 3835811d33
2 changed files with 41 additions and 5 deletions

View file

@ -519,7 +519,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 = MEDIA['Movie'](self.server, jellyfindb, kodidb, direct_path)['Remove']
obj = Movies(self.server, jellyfindb, kodidb, direct_path).remove
for item in movies:
@ -527,7 +527,7 @@ class FullSync(object):
dialog.update(int((float(count) / float(len(items))*100)), heading="%s: %s" % (_('addon_name'), library[0]))
count += 1
obj = MEDIA['Series'](self.server, jellyfindb, kodidb, direct_path)['Remove']
obj = TVShows(self.server, jellyfindb, kodidb, direct_path).remove
for item in tvshows:
@ -535,6 +535,13 @@ class FullSync(object):
dialog.update(int((float(count) / float(len(items))*100)), heading="%s: %s" % (_('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
for item in items:

View file

@ -616,7 +616,26 @@ class UpdatedWorker(threading.Thread):
except Queue.Empty:
break
obj = MEDIA[item['Type']](self.args[0], jellyfindb, kodidb, self.args[1])[item['Type']]
if item['Type'] == 'Movie':
obj = Movies(self.args[0], jellyfindb, kodidb, self.args[1]).movie
elif item['Type'] == 'Boxset':
obj = Movies(self.args[0], jellyfindb, kodidb, self.args[1]).boxset
elif item['Type'] == 'Series':
obj = TVShows(self.args[0], jellyfindb, kodidb, self.args[1]).tvshow
elif item['Type'] == 'Season':
obj = TVShows(self.args[0], jellyfindb, kodidb, self.args[1]).season
elif item['Type'] == 'Episode':
obj = TVShows(self.args[0], jellyfindb, kodidb, self.args[1]).episode
elif item['Type'] == 'MusicVideo':
obj = MusicVideos(self.args[0], jellyfindb, kodidb, self.args[1]).musicvideo
elif item['Type'] == 'MusicAlbum':
obj = Music(self.args[0], jellyfindb, kodidb, self.args[1]).album
elif item['Type'] == 'MusicArtist':
obj = Music(self.args[0], jellyfindb, kodidb, self.args[1]).artist
elif item['Type'] == 'AlbumArtist':
obj = Music(self.args[0], jellyfindb, kodidb, self.args[1]).albumartist
elif item['Type'] == 'Audio':
obj = Music(self.args[0], jellyfindb, kodidb, self.args[1]).song
try:
if obj(item) and self.notify:
@ -657,7 +676,10 @@ class UserDataWorker(threading.Thread):
except Queue.Empty:
break
obj = MEDIA[item['Type']](self.args[0], jellyfindb, kodidb, self.args[1]).userdata
if item['Type'] == 'Movie':
obj = Movies(self.args[0], jellyfindb, kodidb, self.args[1]).userdata(item)
elif item['Type'] in ['Series', 'Season', 'Episode']:
obj = TVShows(self.args[0], jellyfindb, kodidb, self.args[1]).userdata(item)
try:
obj(item)
@ -742,7 +764,14 @@ class RemovedWorker(threading.Thread):
except Queue.Empty:
break
obj = MEDIA[item['Type']](self.args[0], jellyfindb, kodidb, self.args[1]).remove
if item['Type'] == 'Movie':
obj = Movies(self.args[0], jellyfindb, kodidb, self.args[1]).remove
elif item['Type'] in ['Series', 'Season', 'Episode']:
obj = TVShows(self.args[0], jellyfindb, kodidb, self.args[1]).remove
elif item['Type'] in ['MusicAlbum', 'MusicArtist', 'AlbumArtist', 'Audio']:
obj = Music(self.args[0], jellyfindb, kodidb, self.args[1]).remove
elif item['Type'] == 'MusicVideo':
obj = MusicVideos(self.args[0], jellyfindb, kodidb, self.args[1]).remove
try:
obj(item['Id'])