pkkid / python-plexapi

Python bindings for the Plex API.
BSD 3-Clause "New" or "Revised" License
1.15k stars 199 forks source link

'updateProgress' returns 401 Unauthorized error #1467

Closed JanKhstll closed 1 month ago

JanKhstll commented 1 month ago

Describe the Bug

When trying to set progress for video or audio tracks the server returns a 401 error code. I confirmed that the connection to the server works and that the steps before updating progress are working fine.

Error message: *** plexapi.exceptions.Unauthorized: (401) unauthorized; https://46-142-15-XX.127d7899...652a5bd9.plex.direct:3659/:/progress?key=54769&identifier=com.plexapp.plugins.library&time=50&state=stopped <html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>

Thank you in advance.

Code Snippets

from plexapi.myplex import MyPlexAccount
account = MyPlexAccount('<USERNAME>', '<PASSWORD>')
plex = account.resource('<SERVERNAME>').connect()  # returns a PlexServer instance

# Test with a movie
tenet = plex.search('tenet')[0]
tenet.updateProgress(time=50, state="stopped")

# Test with an audio track
album = plex.search('<Audiobook>')[0]
fifth_track = album.get(5)
fifth_track.updateProgress(time=50, state="stopped")

Expected Behavior

Expected outcome should be status code 200.

Additional Context

No response

Operating System and Version

Windows 11

Plex Media Server Version

4.136.1

Python Version

3.10.2

PlexAPI Version

4.15.16

JonnyWong16 commented 1 month ago

updateProgress() works fine. That is some issue with your account token.

JanKhstll commented 1 month ago

Thank you very much, I confirmed that it indeed is not a library but a user issue. For development purpose I have created an additional user account with whom I shared the libraries and for this account the progress synchronization is not working. Do you know which additional permissions I need to give this account in order for the endpoint to work?

JonnyWong16 commented 1 month ago

Try using updateTimeline(time=60001) instead. Note that Plex only starts saving progress after 1 minute, hence anything less than 60001 milliseconds won't work.

JanKhstll commented 1 month ago

Thank you, I confirm that updateTimeline works independent of the user account type and is a good alternative for updateProgresss if the account has not full server access.