mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Reduce code movies,boxsets,mvideos
This commit is contained in:
parent
db0e84f786
commit
4958d106ec
2 changed files with 18 additions and 91 deletions
|
@ -83,25 +83,10 @@ class Movies(Items):
|
||||||
if self.pdialog:
|
if self.pdialog:
|
||||||
self.pdialog.update(heading=lang(29999), message="%s %s..." % (lang(33026), view_name))
|
self.pdialog.update(heading=lang(29999), message="%s %s..." % (lang(33026), view_name))
|
||||||
|
|
||||||
movies = dict(self.emby_db.get_checksum_by_view('Movie', view_id))
|
movies = dict(self.emby_db.get_checksum_by_view("Movie", view_id))
|
||||||
emby_movies = self.emby.getMovies(view_id, basic=True, dialog=self.pdialog)
|
emby_movies = self.emby.getMovies(view_id, basic=True, dialog=self.pdialog)
|
||||||
|
|
||||||
update_list = self.compare_checksum(emby_movies['Items'], movies)
|
return self.compare("Movie", emby_movies['Items'], movies, view)
|
||||||
log.info("Movies to update for %s: %s", view_name, update_list)
|
|
||||||
emby_movies = self.emby.getFullItems(update_list)
|
|
||||||
total = len(update_list)
|
|
||||||
|
|
||||||
if self.pdialog:
|
|
||||||
self.pdialog.update(heading="Processing %s / %s items" % (view_name, total))
|
|
||||||
|
|
||||||
# Process additions and updates
|
|
||||||
if emby_movies:
|
|
||||||
self.added(emby_movies, total, view)
|
|
||||||
# Process deletes
|
|
||||||
if movies:
|
|
||||||
self.remove_all("Movie", movies.items())
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def compare_boxsets(self):
|
def compare_boxsets(self):
|
||||||
|
|
||||||
|
@ -111,22 +96,7 @@ class Movies(Items):
|
||||||
boxsets = dict(self.emby_db.get_checksum('BoxSet'))
|
boxsets = dict(self.emby_db.get_checksum('BoxSet'))
|
||||||
emby_boxsets = self.emby.getBoxset(dialog=self.pdialog)
|
emby_boxsets = self.emby.getBoxset(dialog=self.pdialog)
|
||||||
|
|
||||||
update_list = self.compare_checksum(emby_boxsets['Items'], boxsets)
|
return self.compare("BoxSet", emby_boxsets['Items'], boxsets)
|
||||||
log.info("Boxsets to update: %s", update_list)
|
|
||||||
emby_boxsets = self.emby.getFullItems(update_list)
|
|
||||||
total = len(update_list)
|
|
||||||
|
|
||||||
if self.pdialog:
|
|
||||||
self.pdialog.update(heading="Processing Boxsets / %s items" % total)
|
|
||||||
|
|
||||||
# Processing additions and updates
|
|
||||||
if emby_boxsets:
|
|
||||||
self.added_boxset(emby_boxsets, total)
|
|
||||||
# Processing removals
|
|
||||||
if boxsets:
|
|
||||||
self.remove_all("BoxSet", boxsets.items())
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
def added(self, items, total=None, view=None):
|
def added(self, items, total=None, view=None):
|
||||||
|
|
||||||
|
|
|
@ -47,78 +47,35 @@ class MusicVideos(Items):
|
||||||
return actions.get(action)
|
return actions.get(action)
|
||||||
|
|
||||||
def compare_all(self):
|
def compare_all(self):
|
||||||
pdialog = self.pdialog
|
|
||||||
# Pull the list of musicvideos in Kodi
|
# Pull the list of musicvideos in Kodi
|
||||||
views = self.emby_db.getView_byType('musicvideos')
|
views = self.emby_db.getView_byType('musicvideos')
|
||||||
log.info("Media folders: %s", views)
|
log.info("Media folders: %s", views)
|
||||||
|
|
||||||
try:
|
|
||||||
all_kodimvideos = dict(self.emby_db.get_checksum('MusicVideo'))
|
|
||||||
except ValueError:
|
|
||||||
all_kodimvideos = {}
|
|
||||||
|
|
||||||
all_embymvideosIds = set()
|
|
||||||
updatelist = []
|
|
||||||
|
|
||||||
for view in views:
|
for view in views:
|
||||||
|
|
||||||
if self.should_stop():
|
if self.should_stop():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Get items per view
|
if not self.compare_mvideos(view):
|
||||||
viewId = view['id']
|
|
||||||
viewName = view['name']
|
|
||||||
|
|
||||||
if pdialog:
|
|
||||||
pdialog.update(
|
|
||||||
heading=lang(29999),
|
|
||||||
message="%s %s..." % (lang(33028), viewName))
|
|
||||||
|
|
||||||
all_embymvideos = self.emby.getMusicVideos(viewId, basic=True, dialog=pdialog)
|
|
||||||
for embymvideo in all_embymvideos['Items']:
|
|
||||||
|
|
||||||
if self.should_stop():
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
API = api.API(embymvideo)
|
|
||||||
itemid = embymvideo['Id']
|
|
||||||
all_embymvideosIds.add(itemid)
|
|
||||||
|
|
||||||
|
|
||||||
if all_kodimvideos.get(itemid) != API.get_checksum():
|
|
||||||
# Only update if musicvideo is not in Kodi or checksum is different
|
|
||||||
updatelist.append(itemid)
|
|
||||||
|
|
||||||
log.info("MusicVideos to update for %s: %s", viewName, updatelist)
|
|
||||||
embymvideos = self.emby.getFullItems(updatelist)
|
|
||||||
self.total = len(updatelist)
|
|
||||||
del updatelist[:]
|
|
||||||
|
|
||||||
|
|
||||||
if pdialog:
|
|
||||||
pdialog.update(heading="Processing %s / %s items" % (viewName, self.total))
|
|
||||||
|
|
||||||
self.count = 0
|
|
||||||
for embymvideo in embymvideos:
|
|
||||||
# Process individual musicvideo
|
|
||||||
if self.should_stop():
|
|
||||||
return False
|
|
||||||
self.title = embymvideo['Name']
|
|
||||||
self.update_pdialog()
|
|
||||||
self.add_update(embymvideo, view)
|
|
||||||
self.count += 1
|
|
||||||
|
|
||||||
##### PROCESS DELETES #####
|
|
||||||
|
|
||||||
for kodimvideo in all_kodimvideos:
|
|
||||||
if kodimvideo not in all_embymvideosIds:
|
|
||||||
self.remove(kodimvideo)
|
|
||||||
|
|
||||||
log.info("MusicVideos compare finished.")
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def compare_mvideos(self, view):
|
||||||
|
|
||||||
|
view_id = view['id']
|
||||||
|
view_name = view['name']
|
||||||
|
|
||||||
|
if self.pdialog:
|
||||||
|
self.pdialog.update(heading=lang(29999), message="%s %s..." % (lang(33028), view_name))
|
||||||
|
|
||||||
|
mvideos = dict(self.emby_db.get_checksum_by_view('MusicVideo', view_id))
|
||||||
|
emby_mvideos = self.emby.getMusicVideos(view_id, basic=True, dialog=self.pdialog)
|
||||||
|
|
||||||
|
return self.compare("MusicVideo", emby_mvideos['Items'], mvideos, view)
|
||||||
|
|
||||||
def added(self, items, total=None, view=None):
|
def added(self, items, total=None, view=None):
|
||||||
|
|
||||||
for item in super(MusicVideos, self).added(items, total):
|
for item in super(MusicVideos, self).added(items, total):
|
||||||
if self.add_update(item, view):
|
if self.add_update(item, view):
|
||||||
self.content_pop(item.get('Name', "unknown"))
|
self.content_pop(item.get('Name', "unknown"))
|
||||||
|
|
Loading…
Reference in a new issue