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