fix org_diff function

This commit is contained in:
Blacktwin 2018-10-07 23:59:33 -04:00
parent 19e85e6dbb
commit 02cc9878a6

View File

@ -121,7 +121,7 @@ def get_meta(meta):
return meta_dict return meta_dict
def org_diff(media_type, lst_dicts, main_server): def org_diff(lst_dicts, media_type, main_server):
"""Organizing the items from each server """Organizing the items from each server
Parameters Parameters
@ -157,6 +157,7 @@ def org_diff(media_type, lst_dicts, main_server):
dupes = [] dupes = []
missing = [] missing = []
unique = [] unique = []
# todo-me pull posters from connected servers
for mtype in media_type: for mtype in media_type:
meta_lst = [] meta_lst = []
@ -167,6 +168,7 @@ def org_diff(media_type, lst_dicts, main_server):
title = u'{} ({})'.format(item.title, item.year) title = u'{} ({})'.format(item.title, item.year)
else: else:
title = item.title title = item.title
# Look for duplicate titles # Look for duplicate titles
if title not in seen: if title not in seen:
seen[title] = 1 seen[title] = 1
@ -174,7 +176,7 @@ def org_diff(media_type, lst_dicts, main_server):
else: else:
# Duplicate found # Duplicate found
if seen[title] >= 1: if seen[title] >= 1:
dupes.append([title,item._server.friendlyName]) dupes.append([title, item._server.friendlyName])
# Go back through list to find original # Go back through list to find original
for meta in meta_lst: for meta in meta_lst:
if meta['title'] == title: if meta['title'] == title:
@ -183,8 +185,7 @@ def org_diff(media_type, lst_dicts, main_server):
seen[title] += 1 seen[title] += 1
# Sort item list by Plex rating # Sort item list by Plex rating
# Duplicates will use originals rating # Duplicates will use originals rating
meta_lst = sorted(meta_lst, key=lambda d: d['rating'], meta_lst = sorted(meta_lst, key=lambda d: d['rating'], reverse=True)
reverse=True)
diff_dict[mtype] = {'combined': {'count': len(meta_lst), diff_dict[mtype] = {'combined': {'count': len(meta_lst),
'list': meta_lst}} 'list': meta_lst}}