Taxel / PlexTraktSync

A python script that syncs the movies, shows and ratings between trakt and Plex (without needing a PlexPass or Trakt VIP subscription)
MIT License
1.64k stars 106 forks source link

sync fails for movies that were released in the 1950s, 1960s, or 1970s #1873

Closed NotoriousKlein closed 8 months ago

NotoriousKlein commented 8 months ago

Confirmation

The problem

When Running plextraktsync sync, it always fails on my movie collection when it hits an old movie.

For example, it just failed trying to sync "A Charlie Brown Christmas (1965)". I can't remember the last version that worked successfully

Steps to reproduce the behavior

Sync my movie collection, and wait until it hits an older movie from the 50s, 60s, or 70s

Error trace / logs

2024-03-22 13:47:59,673 DEBUG[trakt.core]:RESPONSE [get] (https://api.trakt.tv/search/tmdb/13187?type=movie): <CachedResponse [200]: created: 2024-03-22 13:36:08 Eastern Daylight Time, expires: 2024-03-22 21:36:08 Eastern Daylight Time (fresh), size: 182 bytes, request: GET https://api.trakt.tv/search/tmdb/13187?type=movie>
2024-03-22 13:47:59,673 DEBUG[plextraktsync.media.MediaFactory]:Resolved <PlexGuid:tmdb://13187> of <tmdb:13187:Movie:111745:A-Charlie-Brown-Chri> to <tmdb:13187:Movie:111745:A-Charlie-Brown-Chri>
2024-03-22 13:47:59,673 INFO[plextraktsync.sync.Sync]:Adding to collection: A Charlie Brown Christmas (1965)
2024-03-22 13:47:59,689 ERROR[plextraktsync.cli]:[Errno 22] Invalid argument
Traceback (most recent call last):
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\cli.py", line 26, in wrap
    cmd(*args, **kwargs)
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\commands\sync.py", line 70, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\sync\Sync.py", line 67, in sync
    self.sync_collection(movie, dry_run=dry_run)
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\sync\Sync.py", line 121, in sync_collection
    m.add_to_collection()
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\media\Media.py", line 141, in add_to_collection
    self.trakt_api.add_to_collection(self.trakt, self.plex)
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\trakt\TraktApi.py", line 189, in add_to_collection
    **pm.to_json(),
      ^^^^^^^^^^^^
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\plex\PlexLibraryItem.py", line 384, in to_json
    collected_at = None if not self.collected_at else timestamp(self.collected_at)
                               ^^^^^^^^^^^^^^^^^
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\plex\PlexLibraryItem.py", line 167, in collected_at
    return self.date_value(self.item.addedAt)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\chris\.local\pipx\venvs\plextraktsync\Lib\site-packages\plextraktsync\plex\PlexLibraryItem.py", line 355, in date_value
    return date.astimezone(datetime.timezone.utc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument

Expected behavior

sync my collection without an issue

Inspect of problematic items

No response

Workarounds

can't sync my collection without removing old movies

Config file contents

cache:
  path: $PTS_CACHE_DIR/trakt_cache

excluded-libraries:
  - GrowWithJo Exercise Videos

config:
  dotenv_override: true

plex:
  timeout: 30

logging:
  append: true
  # Whether to show timestamps in console messages
  console_time: false
  debug: true
  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: false
  trakt_to_plex:
    liked_lists: false
    ratings: false
    watched_status: false
    # 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: true
  # Setting for whether ratings from one platform should have priority.
  # Valid values are trakt, plex or none. (default: plex)
  # none - No rating priority. Existing ratings are not overwritten.
  # trakt - Trakt ratings have priority. Existing Plex ratings are overwritten.
  # plex - Plex ratings have priority. Existing Trakt ratings are overwritten.
  rating_priority: plex

# settings for 'watch' command
watch:
  add_collection: false
  remove_collection: false
  # what video watched percentage (0 to 100) triggers the watched status
  scrobble_threshold: 25
  # 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

Install method

pipx

Version

0.29.8

Python Version

3.11.8

Plex Server Version

1.40.1.8227

Operating System and Version

Win11 23H2

NotoriousKlein commented 8 months ago

plextraktsync.log Logfile for Today only

NotoriousKlein commented 8 months ago

0.28.12 log.txt

version 28.12 appears to be the last version that could sync successfully

glensc commented 8 months ago

if the information given is correct then it's breakage in plexapi 4.15.7..4.15.10

➜ g diff 0.28.12 requirements.txt|grep plex
-plexapi==4.15.7; python_version >= '3.8'
+plexapi==4.15.10; python_version >= '3.8'

app itself doesn't seem to have anything interesting changed:

and same for pytrakt:

glensc commented 8 months ago

Inspect of problematic items would be inspect 111745

glensc commented 8 months ago

You can skip the item with this pr for now:

simonc56 commented 8 months ago

It's a specific Windows issue. Fix is #1875