Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incremental sync, cleanup more getitem shenanigans #90

Merged
merged 1 commit into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions resources/lib/full_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,22 +519,29 @@ def remove_library(self, library_id, dialog):
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:

obj(item[0])
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:

obj(item[0])
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:
Expand Down
35 changes: 32 additions & 3 deletions resources/lib/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,26 @@ def run(self):
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:
Expand Down Expand Up @@ -657,7 +676,10 @@ def run(self):
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)
Expand Down Expand Up @@ -742,7 +764,14 @@ def run(self):
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'])
Expand Down