iamkroot / trakt-scrobbler

Scrobbler for trakt.tv that supports VLC, Plex, MPC-HC, and MPV.
https://github.com/iamkroot/trakt-scrobbler/wiki
GNU General Public License v2.0
466 stars 30 forks source link

Handle `int` declared as `str` for `match.episode` on remaps #295

Closed BrutuZ closed 5 months ago

BrutuZ commented 6 months ago

What Happens

trakt-scrobbler silently crashes with the following entry to remap_rules.toml:

[[rules]]
match.title = "Doctor Who"
match.year = 2005
match.episode = "168"
match.season = 0
id.trakt_slug = "doctor-who-2024"
type = "episode"
episode_delta = -164

What Should Happen

Parser should gracefully handle a single episode declared as a string.

What changed

Added TypeError to the caught exceptions as groups contained in a part of the expression that don't match (m["end"]) return a NoneType (docs) which causes the int() operation fail instead of the mapping.

BrutuZ commented 6 months ago

Added a commit to handle (ignore) the odd anonymous Plex sessions. Sometimes when streaming the session won't have a user name, it will look empty even on the server dashboard. Not sure if it's a side-effect of streaming via PlexKodiConnect but regardless, this is the expected behavior instead of raising an exception every few seconds

2024-05-18 01:42:41,239 - ERROR - plex - plex - Weird key error in plex. Resetting status.
Traceback (most recent call last):
  File "...\trakt_scrobbler\player_monitors\plex.py", line 120, in update_status
    return self._update_status()
           ^^^^^^^^^^^^^^^^^^^^^
  File "...\trakt_scrobbler\player_monitors\plex.py", line 109, in _update_status
    status_data = self.get_data(self.session_url)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\trakt_scrobbler\player_monitors\plex.py", line 105, in get_data
    if metadata["User"]["title"] == self.config["scrobble_user"]:
       ~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'title'