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

"TypeError was raised" continuous error - no media is tracked anymore

timothe 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

PTS is throwing an error while on watch, no tracking is done anymore

Error trace / logs

INFO     Listening for events!                                                  
�]0;PlexTraktSync: watch: REDACTED (1.32.6.7557-1cf77d501)�INFO     Starting AlertListener:                                                
         wss://192-168-4-77.REDACTED.plex.direct:32400/:
         /websockets/notifications?X-Plex-Token=<hidden>                        
INFO     Websocket connected    
TypeError was raised: argument of type 'NoneType' is not iterable
TypeError was raised: argument of type 'NoneType' is not iterable
TypeError was raised: argument of type 'NoneType' is not iterable
...

Expected behavior

Detect the watched media and track it as intended

Steps to reproduce the behavior

  1. Start PTS
  2. Start watching a TV show or movie

Inspect of problematic items

No response

Workarounds

Didn't try to downgrade 😬 I have an automatic update system using watchtower

Install method

docker-compose

Config file contents

cache:
  path: $PTS_CACHE_DIR/trakt_cache

excluded-libraries:

config:
  dotenv_override: true

plex:
  timeout: 30

logging:
  append: false
  # Whether to show timestamps in console messages
  console_time: false
  debug: false
  filename: plextraktsync.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: false
    ratings: true
    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: true
  trakt_to_plex:
    liked_lists: true
    # If two-way rating sync, Plex rating takes precedence over Trakt rating
    ratings: true
    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: false
  remove_collection: false
  # what video watched percentage (0 to 100) triggers the watched status
  scrobble_threshold: 80
  # true to scrobble only what's watched by you, false for all your PMS users
  username_filter: true
  # Show the progress bar of played media in terminal
  media_progressbar: false

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.27.11

Python Version

embedded

Operating System and Version

DSM 7

Enable debug, check logs!

Changed the config file to debug: true, I get the exact same repeating messages in the container log

well then, what is the last request to plex? should be id of your problematic item. based on so few information you give here we can't help you. put yourself in our context, what can we do with so few information?

My sincere apologies, me is dumb, me is looking at Docker logs and not the log file. In the latter, I see a repetition of:

2023-11-22 21:38:07,883 DEBUG[plexapi]:Alert: type size PlaySessionStateNotification
2023-11-22 21:38:07,883 DEBUG[PlexTraktSync.EventDispatcher]:{'type': 'playing', 'size': 1, 'PlaySessionStateNotification': [{'sessionKey': '211', 'clientIdentifier': '112abbdc55e5596c-com-plexapp-android', 'guid': 'com.plexapp.agents.thetvdb://81797/26/572?lang=en', 'ratingKey': '1969', 'url': '', 'key': '/library/metadata/1969', 'viewOffset': 1446396, 'playQueueItemID': 12327, 'playQueueID': 843, 'state': 'paused'}]}
2023-11-22 21:38:07,883 DEBUG[plexapi]:GET https://REDACTED.plex.direct:32400/library/sections
2023-11-22 21:38:07,885 DEBUG[requests_cache.policy.actions]:Cache directives from request headers: CacheDirectives()
2023-11-22 21:38:07,885 DEBUG[requests_cache.policy.expiration]:URL https://REDACTED.plex.direct:32400/library/sections matched pattern "*/library/sections": 3674576450094852
2023-11-22 21:38:07,885 DEBUG[requests_cache.policy.actions]:Pre-read cache checks: disabled by expiration
2023-11-22 21:38:07,885 DEBUG[requests_cache.policy.actions]:Post-read cache actions: CacheActions(expire_after=3674576450094852, send_request=True, skip_read=True)
2023-11-22 21:38:07,889 DEBUG[urllib3.connectionpool]:https://REDACTED.plex.direct:32400 "GET /library/sections HTTP/1.1" 200 520
2023-11-22 21:38:07,890 DEBUG[requests_cache.policy.actions]:Cache directives from response headers: CacheDirectives(no_cache=True)
2023-11-22 21:38:07,890 DEBUG[requests_cache.policy.actions]:Pre-write cache checks: disabled by expiration
2023-11-22 21:38:07,890 DEBUG[requests_cache.session]:Skipping cache write for URL: https://REDACTED.plex.direct:32400/library/sections
2023-11-22 21:38:07,891 ERROR[PlexTraktSync.EventDispatcher]:TypeError was raised: argument of type 'NoneType' is not iterable
2023-11-22 21:38:07,893 DEBUG[PlexTraktSync.EventDispatcher]:['  File "/app/plextraktsync/watch/EventDispatcher.py", line 37, in dispatch\n    listener["listener"](event)\n', '  File "/app/plextraktsync/watch/WatchStateUpdater.py", line 140, in on_play\n    m = self.find_by_key(event.key)\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/app/plextraktsync/watch/WatchStateUpdater.py", line 76, in find_by_key\n    if pm.library is None:\n       ^^^^^^^^^^\n', '  File "/usr/local/lib/python3.12/functools.py", line 995, in __get__\n    val = self.func(instance)\n          ^^^^^^^^^^^^^^^^^^^\n', '  File "/app/plextraktsync/plex/PlexLibraryItem.py", line 92, in library\n    if self.item.librarySectionID not in self.plex.library_sections:\n                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/usr/local/lib/python3.12/functools.py", line 995, in __get__\n    val = self.func(instance)\n          ^^^^^^^^^^^^^^^^^^^\n', '  File "/app/plextraktsync/decorators/flatten.py", line 15, in inner\n    return dict(method(*args, **kwargs))\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/app/plextraktsync/plex/PlexApi.py", line 120, in library_sections\n    if section.title in excluded_libraries:\n       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n']
2023-11-22 21:38:17,897 DEBUG[plexapi]:Alert: type size PlaySessionStateNotification
2023-11-22 21:38:17,897 DEBUG[PlexTraktSync.EventDispatcher]:{'type': 'playing', 'size': 1, 'PlaySessionStateNotification': [{'sessionKey': '211', 'clientIdentifier': '112abbdc55e5596c-com-plexapp-android', 'guid': 'com.plexapp.agents.thetvdb://81797/26/572?lang=en', 'ratingKey': '1969', 'url': '', 'key': '/library/metadata/1969', 'viewOffset': 1446396, 'playQueueItemID': 12327, 'playQueueID': 843, 'state': 'paused'}]}
2023-11-22 21:38:17,897 DEBUG[plexapi]:GET https://REDACTED.plex.direct:32400/library/sections
2023-11-22 21:38:17,899 DEBUG[requests_cache.policy.actions]:Cache directives from request headers: CacheDirectives()
2023-11-22 21:38:17,899 DEBUG[requests_cache.policy.expiration]:URL https://REDACTED.plex.direct:32400/library/sections matched pattern "*/library/sections": 3674576450094852
2023-11-22 21:38:17,899 DEBUG[requests_cache.policy.actions]:Pre-read cache checks: disabled by expiration
2023-11-22 21:38:17,899 DEBUG[requests_cache.policy.actions]:Post-read cache actions: CacheActions(expire_after=3674576450094852, send_request=True, skip_read=True)
2023-11-22 21:38:17,904 DEBUG[urllib3.connectionpool]:https://REDACTED.plex.direct:32400 "GET /library/sections HTTP/1.1" 200 520
2023-11-22 21:38:17,905 DEBUG[requests_cache.policy.actions]:Cache directives from response headers: CacheDirectives(no_cache=True)
2023-11-22 21:38:17,905 DEBUG[requests_cache.policy.actions]:Pre-write cache checks: disabled by expiration
2023-11-22 21:38:17,905 DEBUG[requests_cache.session]:Skipping cache write for URL: https://REDACTED.plex.direct:32400/library/sections
2023-11-22 21:38:17,906 ERROR[PlexTraktSync.EventDispatcher]:TypeError was raised: argument of type 'NoneType' is not iterable
2023-11-22 21:38:17,908 DEBUG[PlexTraktSync.EventDispatcher]:['  File "/app/plextraktsync/watch/EventDispatcher.py", line 37, in dispatch\n    listener["listener"](event)\n', '  File "/app/plextraktsync/watch/WatchStateUpdater.py", line 140, in on_play\n    m = self.find_by_key(event.key)\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/app/plextraktsync/watch/WatchStateUpdater.py", line 76, in find_by_key\n    if pm.library is None:\n       ^^^^^^^^^^\n', '  File "/usr/local/lib/python3.12/functools.py", line 995, in __get__\n    val = self.func(instance)\n          ^^^^^^^^^^^^^^^^^^^\n', '  File "/app/plextraktsync/plex/PlexLibraryItem.py", line 92, in library\n    if self.item.librarySectionID not in self.plex.library_sections:\n                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/usr/local/lib/python3.12/functools.py", line 995, in __get__\n    val = self.func(instance)\n          ^^^^^^^^^^^^^^^^^^^\n', '  File "/app/plextraktsync/decorators/flatten.py", line 15, in inner\n    return dict(method(*args, **kwargs))\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/app/plextraktsync/plex/PlexApi.py", line 120, in library_sections\n    if section.title in excluded_libraries:\n       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n']

PTS is throwing an error while on watch, no tracking is done anymore

"anymore" -> that means it worked before you changed something 😐

I see you removed all default excluded libraries in config.yml, you shouldn't.
Keep at least one excluded library :

excluded-libraries:
  - Private

Then the script will work as expected.

I could not remember doing any change, but you might be right 😕

This solved the issue! Tried with 3 different files with the result below.
(HAMA support is lacking but didn't have any hope there)

INFO     Listening for events!                                                  
         wss://REDACTED.plex.direct:32400/:
INFO     OAuth token has expired, refreshing now...                             
�]0;PlexTraktSync: watch: REDACTED (1.32.6.7557-1cf77d501)�INFO     Starting AlertListener:                                                
         /websockets/notifications?X-Plex-Token=<hidden>                        
INFO     Websocket connected                                                    
         09:30:12+00:00                                                         
INFO     OAuth token successfully refreshed, valid until 2024-02-22             
INFO     on_activity: <tmdb:122906:Movie:2352:About-Time>: Collected: False,    
         Watched: [Plex: False, Trakt: False]                                   
INFO     on_play: <Episode:2586:The-Walking-Dead:-Da-s01e06>: 0.000000%, State: 
         playing, Watched: False, LastViewed: None                              
�]0;PlexTraktSync: Watching The Walking Dead: Daryl Dixon/s01e06/Coming Home (2023)�INFO     on_play: <Episode:2586:The-Walking-Dead:-Da-s01e06>: 0.000000%, State: 
�]0;PlexTraktSync: Watching The Walking Dead: Daryl Dixon/s01e06/Coming Home (2023)�INFO     on_play: <Episode:2586:The-Walking-Dead:-Da-s01e06>: 0.276995%, State: 
�]0;PlexTraktSync: Watching The Walking Dead: Daryl Dixon/s01e06/Coming Home (2023)�INFO     on_play: <Episode:2586:The-Walking-Dead:-Da-s01e06>: 0.338550%, State: 
         paused, Watched: False, LastViewed: None                               
�]0;PlexTraktSync: watch: Nasputin (1.32.6.7557-1cf77d501)�INFO     on_play: <Episode:2586:The-Walking-Dead:-Da-s01e06>: 0.338550%, State: 
         stopped, Watched: False, LastViewed: None                              
�]0;PlexTraktSync: watch: Nasputin (1.32.6.7557-1cf77d501)�WARNING  <Episode:2052:One-Piece-s27e588>: Skipping guid                        
         <PlexGuid:com.plexapp.agents.thetvdb://81797/27/588?lang=en> not found 
WARNING  <Episode:2052:One-Piece-s27e588>: Skipping guid                        
         on Trakt                                                               
INFO     on_play: <Movie:2352:About-Time>: 44.703458%, State: playing, Watched: 
         False, LastViewed: 2023-11-24 09:30:12                                 
�]0;PlexTraktSync: Watching About Time (2013)�INFO     on_play: <Movie:2352:About-Time>: 44.771006%, State: paused, Watched:  
�]0;PlexTraktSync: watch: Nasputin (1.32.6.7557-1cf77d501)�INFO     on_play: <Movie:2352:About-Time>: 44.771006%, State: stopped, Watched: 

Thank you so much!