zSeriesGuy / Tautulli

A Python based monitoring and tracking tool for Plex Media Server.
http://tautulli.com
GNU General Public License v3.0
27 stars 9 forks source link

Buggy server selection logic #4

Closed ddurdle closed 5 years ago

ddurdle commented 5 years ago

Seems there is some server selection buggy logic.

Out of 3 tested plex accounts, only works with 1. On another, it seems to get hung up parsing the server list with this error: 2019-03-04 13:51:27 - INFO :: MainThread : Tautulli WebStart :: Starting Tautulli web server on http://0.0.0.0:8181/ 2019-03-04 13:51:29 - ERROR :: Thread-3 : Uncaught exception: Traceback (most recent call last): File "/opt/Tautulli.2/plexpy/logger.py", line 341, in new_run old_run(*args, *kwargs) File "/usr/lib/python2.7/threading.py", line 754, in run self.__target(self.args, **self.kwargs) File "/opt/Tautulli.2/plexpy/servers.py", line 149, in refresh_users result = users.refresh_users() File "/opt/Tautulli.2/plexpy/users.py", line 54, in refresh_users shared_libraries = user.pop('shared_libraries') KeyError: 'shared_libraries'

Traceback (most recent call last): File "/opt/Tautulli.2/plexpy/logger.py", line 341, in new_run old_run(*args, *kwargs) File "/usr/lib/python2.7/threading.py", line 754, in run self.__target(self.args, **self.kwargs) File "/opt/Tautulli.2/plexpy/servers.py", line 149, in refresh_users result = users.refresh_users() File "/opt/Tautulli.2/plexpy/users.py", line 54, in refresh_users shared_libraries = user.pop('shared_libraries') KeyError: 'shared_libraries'

Then on the third, it gets past this but it is using the wrong API token against the wrong server so it is not able to retrieve the user list. The code is thinking it is talking to server 3 but it is talking to server 2 and vice-versa.

2019-03-04 13:51:56 - INFO :: WebSocket-ad : Tautulli Users :: Requesting users list refresh... 2019-03-04 13:52:01 - WARNING :: WebSocket-ad : Failed to access uriendpoint /api/servers/XXXX/shared_servers. Status code 404 2019-03-04 13:52:01 - WARNING :: WebSocket-ad : Tautulli PlexTV :: Local: Unable to parse shared server list XML for get_full_users_list:'NoneType' object has no attribute 'getElementsByTagName'. 2019-03-04 13:52:01 - WARNING :: WebSocket-ad : Tautulli Users :: Unable to refresh users list.

The official documentation from Tautulli indicates that error will occur if the identify number is wrong. I checked in the Settings and the numbers line up, so it must be using the wrong numbers for the API calls.

Version: latest Branch: v3.00

Commit hash:

Operating system: Linux Debian Python version: 2.7

What you did? Tried to What happened?

What you expected?

How can we reproduce your issue?

What are your (relevant) settings?

Link to logs:

ddurdle commented 5 years ago

Found the issue. Apparently on some accounts, certain variables are not defined ('') and by casting to an int in the parameter fetching, this causes an issue and prevents the server list from populating properly.

I have made these return an appropriate value if not defined so that the server list will correctly populate.

See https://github.com/zSeriesGuy/Tautulli/pull/5

zSeriesGuy commented 5 years ago

Thanks a bunch for catching and correcting this.