python-plexapi icon indicating copy to clipboard operation
python-plexapi copied to clipboard

IPv6 Not properly support in settings.py (too many values to unpack)

Open engelde opened this issue 6 years ago • 1 comments

Hello!

First off, thank you for the great project. I’ve been using it to randomly mix trailers and set them as preroll videos in Plex. Until recently, it has worked absolutely perfectly.

Unfortunately I’m now seeing the following error with plexapi.settings. Has something changed with Plex’s API that might cause this? I’m using python 3.7 and, for reference and just in case it helps, the code I am running can be found here: https://github.com/airship-david/Plex-Apple-Preroll-Trailers/blob/master/mix.py.

Let me know if I need to provide any additional info. I would definitely appreciate any ideas you might have. Thanks!

Traceback (most recent call last):
  File "mix.py", line 77, in <module>
    main()
  File "mix.py", line 67, in main
    plex_settings = plex.settings.get('CinemaTrailersPrerollID')
  File "/usr/local/lib/python3.7/site-packages/plexapi/server.py", line 178, in settings
    self._settings = Settings(self, data)
  File "/usr/local/lib/python3.7/site-packages/plexapi/settings.py", line 20, in __init__
    super(Settings, self).__init__(server, data, initpath)
  File "/usr/local/lib/python3.7/site-packages/plexapi/base.py", line 48, in __init__
    self._loadData(data)
  File "/usr/local/lib/python3.7/site-packages/plexapi/settings.py", line 40, in _loadData
    self._settings[id] = Setting(self._server, elem, self._initpath)
  File "/usr/local/lib/python3.7/site-packages/plexapi/base.py", line 48, in __init__
    self._loadData(data)
  File "/usr/local/lib/python3.7/site-packages/plexapi/settings.py", line 124, in _loadData
    self.enumValues = self._getEnumValues(data)
  File "/usr/local/lib/python3.7/site-packages/plexapi/settings.py", line 138, in _getEnumValues
    return {self._cast(k): v for k, v in [kv.split(':') for kv in enumstr.split('|')]}
  File "/usr/local/lib/python3.7/site-packages/plexapi/settings.py", line 138, in <dictcomp>
    return {self._cast(k): v for k, v in [kv.split(':') for kv in enumstr.split('|')]}
ValueError: too many values to unpack (expected 2)

engelde avatar Jul 18 '19 19:07 engelde

Just to follow up on this, the issue is related to the following line in settings.py (line 137) when you have “Enable server support for IPv6” checked in Plex. Unchecking that setting fixes the problem.

return {self._cast(k): v for k, v in [kv.split(':') for kv in enumstr.split('|')]}

I’m guessing that this is related to the extra colons in those addresses. I’ll see if I can figure out a workaround and submit a pull request.

engelde avatar Jul 19 '19 19:07 engelde