RemiRigal / Plex-Auto-Languages

Automated language selection for Plex TV Shows !
MIT License
428 stars 16 forks source link

[ERROR] cannot decode #48

Closed Metuant closed 1 year ago

Metuant commented 2 years ago

Seeing this error with notifications enabled

2022-06-17 22:57:11,305 [ERROR] cannot decode: b'{"NotificationContainer":{"type":"progress","size":1,"ProgressNotification":
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/websocket/_app.py", line 383, in run_forever
    dispatcher.read(self.sock.sock, read, check)
  File "/usr/local/lib/python3.8/site-packages/websocket/_app.py", line 48, in read
    if not read_callback():
  File "/usr/local/lib/python3.8/site-packages/websocket/_app.py", line 349, in read
    op_code, frame = self.sock.recv_data_frame(True)
  File "/usr/local/lib/python3.8/site-packages/websocket/_core.py", line 415, in recv_data_frame
    return self.cont_frame.extract(frame)
  File "/usr/local/lib/python3.8/site-packages/websocket/_abnf.py", line 421, in extract
    raise WebSocketPayloadException(
websocket._exceptions.WebSocketPayloadException: cannot decode: b'{"NotificationContainer":{"type":"progress","size":1,"ProgressNotification":

Running master

RemiRigal commented 2 years ago

Can you give me your Python version as well as the websocket-client version ? Thank you.

Metuant commented 2 years ago

Python 3.8.13 Name: websocket-client Version: 1.3.2 Summary: WebSocket client for Python with low level API options Home-page: https://github.com/websocket-client/websocket-client.git Author: liris Author-email: liris.pp@gmail.com License: Apache-2.0 Location: /usr/local/lib/python3.8/site-packages

To clarify - running PAL in docker.

Metuant commented 2 years ago

@RemiRigal was this info helpful? I continue to see this periodically in the logs.

P.S. This tool is amazing - really appreciate your work!

RemiRigal commented 2 years ago

Hi @Metuant, I've tried to reproduce the issue but since you are using docker it's unlikely that it's coming from Python or its packages. It looks like the websocket is not receiving messages properly so I'm leaning toward a network issue or a Plex issue. Are you running an oudated version of Plex ? Anyway, I think that this is related to the other issue you opened (#49).

P.S. This tool is amazing - really appreciate your work!

Thank you, I really appreciate it :)

Metuant commented 2 years ago

Sorry for delay in response - i'm running plex 1.27.2.5929 - any other things I should review to help troubleshoot?

Metuant commented 2 years ago

@RemiRigal - I think i figured this out. It seems PAL produces this error on Audiobook titles. Is it possible to enhance the configuration file with a library exceptions list?

Metuant commented 2 years ago

@RemiRigal - bumping this. I think an exclusion list would resolve this message as it seems localized only to Music library

RemiRigal commented 2 years ago

@Metuant The issue is that the exception occurs within the websocket-client package, not in PAL. The WebSocketPayloadException raised means that either the websocket frames are corrupted (see issue https://github.com/websocket-client/websocket-client/issues/216) or the websocket frames contains non-utf8 characters (see snippet).

If the issue comes from corrupted frames I can't do anything in PAL that can solve this, it needs valid frames in order to filter out messages. By the way, PAL will ignore any media that is not a TV Show episode so the exclusion list is there already.

However, if it's an encoding issue, I can disable utf8 validation in the websocket connection. By any chance, do you have any audiobook with non-utf8 characters in them ? (Title, author, etc...)

Metuant commented 2 years ago

@RemiRigal Oh, interesting! Thank you for providing clarity, I think we're on to it. Re: Audiobooks with non-utf8 characters, yes, many.

Further log data that contains some titles in question:

Author- Aimée Carter

2022-08-09 01:01:04,345 [ERROR] cannot decode: b'{"NotificationContainer":{"type":"progress","size":1,"ProgressNotification":[{"message":"Scanning Aim\xe9e Carter"}]}}'
Traceback (most recent call last):

Author - Zoraida Córdova

2022-08-08 12:00:06,280 [ERROR] cannot decode: b'{"NotificationContainer":{"type":"progress","size":1,"ProgressNotification":[{"message":"Scanning Zoraida C\xf3rdova"}]}}'

However, if PAL ignores any media that is not a TV Show, these should be ignored as they are scanned in as "Music" not "TV Show" - correct?

RemiRigal commented 2 years ago

However, if PAL ignores any media that is not a TV Show, these should be ignored as they are scanned in as "Music" not "TV Show" - correct?

PAL cannot chose the messages sent by the Plex server, it instead filters out the messages that are not related to TV Shows. But in order to do that the message must be decoded first, and the error you are getting is happening at an earlier stage.

Can you try the newest version available (remirigal/plex-auto-languages:master docker image) and let me know if you are still getting this error ?

Metuant commented 2 years ago
2022-08-09 09:03:24,347 [ERROR] Alert listener had an unexpected error
2022-08-09 09:03:24,347 [ERROR] 'utf-8' codec can't decode byte 0xe9 in position 101: invalid continuation byte
Traceback (most recent call last):

Error with must recent pull - I think we'll solve both my open issues if this gets closed.

RemiRigal commented 2 years ago

We are getting there !

Can you try the latest version ?

Metuant commented 2 years ago

Indeed we are! ^_^

Latest pull looks pretty clean. Only thing I see are the following...are they related?

2022-08-10 08:43:14,240 [INFO] [Timeline] Processing newly added episode 'Have You Been Paying Attention? (NZ)' (S03E11)
2022-08-10 08:43:19,319 [ERROR] Unable to process timeline
Traceback (most recent call last):
  File "/app/plex_auto_languages/plex_alert_handler.py", line 61, in _process_alerts
    alert.process(self._plex)
  File "/app/plex_auto_languages/alerts/timeline.py", line 65, in process
    logger.info(f"[Timeline] Processing newly added episode {plex.get_episode_short_name(item)}")
  File "/app/plex_auto_languages/plex_server.py", line 93, in get_episode_short_name
    return f"'{episode.show().title}' (S{episode.seasonNumber:02}E{episode.episodeNumber:02})"
TypeError: unsupported format string passed to NoneType.__format__
RemiRigal commented 2 years ago

Sorry for the delay, can you try the latest version ? The decoding errors should now be silent.

Metuant commented 2 years ago

All good - yes, messages are silent in recent pull.

Ty!