blacktwin / JBOPS

Just a Bunch Of Plex Scripts
1.67k stars 307 forks source link

sync_watch_status.py fails on Plex->Plex sync #308

Closed robdplatt closed 3 years ago

robdplatt commented 3 years ago

Describe the bug

Trying to sync the watch status from one Plex server to another fails. (It does work from Tautulli to Plex)

Provide logs

python3 newsync.py --userFrom robplatt="Rob's Server # 1 (Primary)" --userTo robplatt="Rob's Server # 2 (Backup)" --ratingKey=262601
Connecting to admin server(s) for access info...
Request manually triggered to update watch status
Connecting robplatt to Rob's Server #1 (Primary)...
Connecting robplatt to Rob's Server #2 (Backup)...
Traceback (most recent call last):
  File "C:\Users\platt\Desktop\plex-sync\newsync.py", line 487, in <module>
    library = server.library.sectionByID(watched_item.librarySectionID)
  File "C:\Users\platt\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\plexapi\library.py", line 69, in sectionByID
    return self._sectionsByID[sectionID]
KeyError: 3

Link to script with bug/issue https://github.com/blacktwin/JBOPS/blob/master/utility/sync_watch_status.py

To Reproduce

Steps to reproduce the behavior:

  1. python3 newsync.py --userFrom robplatt="Rob's Server # 1 (Primary)" --userTo robplatt="Rob's Server # 2 (Backup)" --ratingKey=262601

Expected behavior Expect the output to say Marked Watch as it does when ran from Tautulli to "Rob's Server # 2 (Backup)"

Desktop (please complete the following information):

Additional context

I happen to know my "TV Shows" library ID on "Rob's Server # 1 (Primary)" is 2 and on "Rob's Server # 2 (Backup)" is 3. Seems like this might be the issue?

blacktwin commented 3 years ago

That line doesn't match up. Have you modified the script or using an older version? If not, it would be that the value for watched_item.librarySectionID is a str and not an int.

Go to that line and edit it to:

library = server.library.sectionByID(int(watched_item.librarySectionID))
robdplatt commented 3 years ago

@blacktwin, When I initially downloaded the script I guess I didn't grab the header comments. I grabbed a full copy of the script, here is the current error with the correct line number.

python3 newsync.py --userFrom robplatt="Rob's Server # 1 (Primary)" --userTo robplatt="Rob's Server # 2 (Backup)" --ratingKey=262601
Connecting to admin server(s) for access info...
Request manually triggered to update watch status
Connecting robplatt to Rob's Server # 1 (Primary)...
Connecting robplatt to Rob's Server # 2 (Backup)...
Traceback (most recent call last):
  File "C:\Users\platt\Desktop\plex-sync\newsync.py", line 559, in <module>
    library = server.library.sectionByID(watched_item.librarySectionID)
  File "C:\Users\platt\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\plexapi\library.py", line 69, in sectionByID
    return self._sectionsByID[sectionID]
KeyError: 3

Even the current version of the script is missing the int(). I added the int() and still have the error...

Request manually triggered to update watch status
Connecting robplatt to Rob's Server # 1 (Primary)...
Connecting robplatt to Rob's Server # 2 (Backup)...
Traceback (most recent call last):
  File "C:\Users\platt\Desktop\plex-sync\newsync.py", line 559, in <module>
    library = server.library.sectionByID(int(watched_item.librarySectionID))
  File "C:\Users\platt\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\plexapi\library.py", line 69, in sectionByID
    return self._sectionsByID[sectionID]
KeyError: 3
blacktwin commented 3 years ago

It should be --ratingKey 1234 not --ratingKey=1234. Can you try that?

robdplatt commented 3 years ago

@blacktwin, that seems to have done it. Apologies for the oversight. Thank you for helping me out!

blacktwin commented 3 years ago

np, I missed it initially too.