Add check to see if serverTo and serverFrom are the same. If same, then

use ratingKey instead of searching by name.
This commit is contained in:
Blacktwin 2019-06-04 09:02:21 -04:00
parent a7a6a9381d
commit 5179aa7175

View File

@ -348,21 +348,29 @@ def check_users_access(access, user, server_name, libraries=None):
exit() exit()
def sync_watch_status(watched, section, accountTo, userTo): def sync_watch_status(watched, section, accountTo, userTo, same_server=False):
""" """
Parameters Parameters
---------- ----------
watched: list watched: list
List of watched items either from Tautulli or Plex List of watched items either from Tautulli or Plex
section: class section: str
Section class of sync from server Section title of sync from server
accountTo: class
User's account that will be synced to
userTo: str userTo: str
User's server class of sync to user User's server class of sync to user
same_server: bool
Are serverFrom and serverTo the same
""" """
print('Marking watched...') print('Marking watched...')
sectionTo = accountTo.library.section(section) sectionTo = accountTo.library.section(section)
for item in watched: for item in watched:
print(item)
try: try:
if same_server:
fetch_check = sectionTo.fetchItem(item.ratingKey)
else:
if item.type == 'episode': if item.type == 'episode':
show_name = item.grandparentTitle show_name = item.grandparentTitle
show = sectionTo.get(show_name) show = sectionTo.get(show_name)
@ -407,6 +415,7 @@ if __name__ == '__main__':
libraries = [] libraries = []
all_sections = {} all_sections = {}
watchedFrom = '' watchedFrom = ''
same_server = False
count = 25 count = 25
start = 0 start = 0
plex_admin = Plex(PLEX_TOKEN) plex_admin = Plex(PLEX_TOKEN)
@ -486,7 +495,9 @@ if __name__ == '__main__':
for user in plexTo: for user in plexTo:
username, server = user username, server = user
sync_watch_status(watched_lst, _library.title, server, username) if server == serverFrom:
same_server = True
sync_watch_status(watched_lst, _library.title, server, username, same_server)
elif opts.ratingKey and serverFrom == "Tautulli": elif opts.ratingKey and serverFrom == "Tautulli":
plexTo = [] plexTo = []