Taxel / PlexTraktSync

A python script that syncs the movies, shows and ratings between trakt and Plex (without needing a PlexPass or Trakt VIP subscription)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scrobbling no longer pauses when media is paused in Plex.

JBeresford opened this issue · comments

Confirmation

  • I have read the README.md on the project homepage
  • I have checked if identical issue already exists
  • I have tried downgrading to find version that can be used as a workaround

The problem

Following the changes in #1757 pausing/stopping a media item in Plex doesn't stop the scrobble Trakt accordingly.

The issue seems to be stemming from the definition of the scrobble_pause method in plextraktsync/queue/TraktScrobbleWorker.py

     @rate_limit()
     @time_limit()
     @retry()
     def scrobble_pause(self, scrobbler: Scrobbler, progress: float):
         return scrobbler.update(progress)

The previous implementation called scrobbler.pause(progress) and did used to stop a scrobble when you stop media in Plex and it's below the watched threshold.

However, completed watches in Plex do correctly fire the watched event. I'm assuming this is because the playback % is above the 90% I have defined in my config, so it fires scrobble_stop rather than scrobble_pause

Steps to reproduce the behavior

  1. Run PlexTraktSync in watch mode
  2. Start playing an item in Plex
  3. Observe scrobbling starts in Trakt
  4. Pause/Stop playing the item in Plex
  5. Observe that the scrobble in Trakt isn't cancelled, the scrobble will expire on Trakt once it reaches the episode run time

Error trace / logs

No response

Expected behavior

When pausing/stopping media in Plex that are below the "watched" threshold a scrobble pause event should be sent to Trakt.

Inspect of problematic items

No response

Workarounds

Downgrade to 0.28.12, which I've currently done for the container I run the watch command in as I don't like the 2nd workaround I found (which does seem to work)

Manually change the function definition in 0.28.15 using the files tabs on docker to:

     @rate_limit()
     @time_limit()
     @retry()
     def scrobble_pause(self, scrobbler: Scrobbler, progress: float):
         return scrobbler.pause(progress)

Install method

docker-compose

Config file contents

cache:
  path: $PTS_CACHE_DIR/trakt_cache

excluded-libraries:
  - Private

config:
  dotenv_override: true

plex:
  timeout: 30

logging:
  append: false
  # Whether to show timestamps in console messages
  console_time: false
  debug: true
  filename: watch.log
  # Additional logger names to apply filtering
  filter_loggers:
#    - plexapi
#    - requests_cache.backends
#    - requests_cache.backends.base
#    - requests_cache.backends.sqlite
#    - requests_cache.policy.actions
#    - requests_cache.session
#    - trakt.core
#    - urllib3.connectionpool
  filter:
#    # Filter out all messages with level WARNING
#    - level: WARNING
#    # Filter out message with level WARNING and containing a text
#    - level: WARNING
#      message: "not found on Trakt"
#    - message: "because provider local has no external Id"
#    - message: "because provider none has no external Id"
#    - message: "Retry using search for specific Plex Episode"
#    # Filter out messages by requests_cache
#    - name: requests_cache.backends
#    - name: requests_cache.backends.base
#    - name: requests_cache.backends.sqlite
#    - name: requests_cache.policy.actions
#    - name: requests_cache.session

# settings for 'sync' command (default)
sync:
  plex_to_trakt:
    collection: true
    # Clear collected state of items not present in Plex
    clear_collected: true
    ratings: false
    watched_status: true
    # If plex_to_trakt watchlist=false and trakt_to_plex watchlist=true
    # the Plex watchlist will be overwritten by Trakt watchlist
    watchlist: false
  trakt_to_plex:
    liked_lists: true
    # If two-way rating sync, Plex rating takes precedence over Trakt rating
    ratings: false
    watched_status: true
    # If trakt_to_plex watchlist=false and plex_to_trakt watchlist=true
    # the Trakt watchlist will be overwritten by Plex watchlist
    watchlist: true
    # If you prefer to fetch trakt watchlist as a playlist instead of
    # plex watchlist, toggle this to true (is read only if watchlist=true)
    watchlist_as_playlist: false

# settings for 'watch' command
watch:
  add_collection: true
  remove_collection: true
  # what video watched percentage (0 to 100) triggers the watched status
  scrobble_threshold: 90
  # true to scrobble only what's watched by you, false for all your PMS users
  username_filter: false
  # Show the progress bar of played media in terminal
  media_progressbar: true

xbmc-providers:
  movies: imdb
  shows: tvdb

##### Advanced settings below this line, don't edit unless you know what you're doing #####
#http_cache:
  # https://requests-cache.readthedocs.io/en/main/user_guide/expiration.html#url-patterns
  # https://requests-cache.readthedocs.io/en/main/user_guide/expiration.html#expiration-values
  #
  # The value is seconds to cache.
  # Or one of the following special values:
  # - DO_NOT_CACHE: Skip both reading from and writing to the cache
  # - EXPIRE_IMMEDIATELY: Consider the response already expired, but potentially usable
  # - NEVER_EXPIRE: Store responses indefinitely
  #
  # The value can be also suffixed with a time unit:
  # - 5m, 1h, 3d
  # See full documentation at:
  # - https://github.com/wroberts/pytimeparse#pytimeparse-time-expression-parser
  #
  # NOTE: If there is more than one match, the first match will be used in the order they are defined
#  policy:
#    "*.trakt.tv/users/me": 1d
#    "*.trakt.tv/users/likes/lists": DO_NOT_CACHE

# vim:ts=2:sw=2:et

Version

0.28.15

Python Version

3.12.1

Plex Server Version

1.32.8.7639-fb6452ebf

Operating System and Version

Windows 10

I asked a user to test and report it, but they disappeared (went silent):

it seemed to work for me, so merged.

If you have a working fix, why not submit a pull request?

#1757 was merged into 0.28.14, so downgrade to 0.28.13 should also work.

Main reason for no PR was I away from my main machine over the weekend and GitHub mobile is awful for trying to do all the PR admin