Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR:root:Error getting streams from Plex: 'device' #14

Closed
ArbiterGR opened this issue Apr 3, 2023 · 9 comments · Fixed by #15
Closed

ERROR:root:Error getting streams from Plex: 'device' #14

ArbiterGR opened this issue Apr 3, 2023 · 9 comments · Fixed by #15

Comments

@ArbiterGR
Copy link

ArbiterGR commented Apr 3, 2023

Hello, i'm getting the following error when someone streams on my plex server"
ERROR:root:Error getting streams from Plex: 'device'

If i access the status url directly on my web browser eg http://url:32400/status/sessions?X-Plex-Token=PLEXTOKEN i can correctly see the xml file getting populated with session data.

My plex token is correct and the container connects to my plex instance. What could be wrong here ?

@AndrewPaglusch
Copy link
Owner

Can you please post the full traceback of the error?

@ArbiterGR
Copy link
Author

Can you please post the full traceback of the error?

The logs do not output the full traceback, all i get is this:
image

Is there any way to get the full traceback?

@AndrewPaglusch
Copy link
Owner

AndrewPaglusch commented Apr 3, 2023

This is very strange. As you can see here, the err variable should be printed out. I'm not sure why 'device' is being printed.

Please try the following:

  1. docker exec -it dupstreamkiller sed -i 's|logging.error(f"Error getting|logging.exception(f"Error getting|g' run.py
  2. docker restart dupstreamkiller
  3. docker logs --tail 50 -f dupstreamkiller

This should cause a full traceback to be printed, along with the error. Please post that to this issue.

@ArbiterGR
Copy link
Author

Thank you for the response, this is what i get:

ERROR:root:Error getting streams from Plex: 'device'
Traceback (most recent call last):
  File "/app/run.py", line 21, in get_streams
    return _parse_streams(jstreams)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/run.py", line 79, in _parse_streams
    'device': stream['Player']['device'],
              ~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'device'

@ArbiterGR
Copy link
Author

What is weirder, is that it seems i can get it to work only if i use plex via app.plex.tv . If i view media using its apps (i tried windows client and android client) i get the above error.

To prove that, i sucessfully banned myself by using app.plex.tv from my pc and from my mobile phone (using mobile data)

@AndrewPaglusch
Copy link
Owner

Interesting. You have someone streaming, but Plex isn't returning what kind of device they're using. It's completely omitted from the JSON response. I haven't seen this until now.

Please do the following and see if it fixes the issue:

  1. docker exec -it dupstreamkiller sed -i "s|stream\['Player'\]\['device'\]|stream\['Player'\].get('device', 'Unknown')|g" run.py
  2. docker restart dupstreamkiller
  3. docker logs --tail 50 -f dupstreamkiller

@ArbiterGR
Copy link
Author

ArbiterGR commented Apr 3, 2023

That worked!

Trying to ban myself got this:
INFO:root:(Stream 0) DEVICE: "SM-S908B" IPADDR: "_xxx.xxx.xxx..xx_" MEDIA: "A Stolen Truck and Going on the Lam" INFO:root:(Stream 1) DEVICE: "Unknown" IPADDR: "10.10.1.2" MEDIA: "Chapter 1: The Mandalorian"

I don't know why the plex windows client gets reported as "unknown" (should output my pc's hostname) edit: that's because of the edit on the run.py, it now returns unknown if the device name does not get returned:P, but it works now.

Thank you

@AndrewPaglusch
Copy link
Owner

Great! I'm glad that worked. The fix is not permanent at this point, and will be reverted if you re-create the container.

I will go ahead and make the changes and cut a new release so they will be permanent.

@ArbiterGR
Copy link
Author

That's great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants