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

ValueError: year 30828 is out of range

gusace 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

When performing a sync, process drops out with the error listed in title.
I am unable to find any tracelog to identify the item causing the issue.

Error trace / logs

2023-11-09 07:40:04,178 ERROR[PlexTraktSync]:year 30828 is out of range
Traceback (most recent call last):
  File "/app/plextraktsync/cli.py", line 26, in wrap
    cmd(*args, **kwargs)
  File "/app/plextraktsync/commands/sync.py", line 68, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "/app/plextraktsync/sync.py", line 79, in sync
    for episode in walker.find_episodes():
  File "/app/plextraktsync/walker.py", line 303, in find_episodes
    yield from self.episode_from_show(show)
  File "/app/plextraktsync/walker.py", line 342, in episode_from_show
    for pe in show.plex.episodes():
  File "/app/plextraktsync/plex/PlexLibraryItem.py", line 281, in episodes
    for ep in self._get_episodes():
              ^^^^^^^^^^^^^^^^^^^^
  File "/app/plextraktsync/decorators/retry.py", line 26, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/app/plextraktsync/plex/PlexLibraryItem.py", line 286, in _get_episodes
    return self.library.search(libtype='episode', filters={'show.id': self.item.ratingKey})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/plextraktsync/plex/PlexLibrarySection.py", line 56, in search
    return self.section.search(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plexapi/library.py", line 1517, in search
    return self.fetchItems(
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plexapi/base.py", line 256, in fetchItems
    subresults = self.findItems(data, cls, ekey, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plexapi/base.py", line 329, in findItems
    item = self._buildItemOrNone(elem, cls, initpath)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plexapi/base.py", line 109, in _buildItemOrNone
    return self._buildItem(elem, cls, initpath)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plexapi/base.py", line 101, in _buildItem
    return ecls(self._server, elem, initpath)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plexapi/base.py", line 62, in __init__
    self._loadData(data)
  File "/usr/local/lib/python3.12/site-packages/plexapi/video.py", line 887, in _loadData
    Video._loadData(self, data)
  File "/usr/local/lib/python3.12/site-packages/plexapi/video.py", line 51, in _loadData
    self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plexapi/utils.py", line 331, in toDatetime
    return datetime.fromtimestamp(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: year 30828 is out of range

Expected behavior

Complete sync of all shows

Steps to reproduce the behavior

docker compose run --rm plextraktsync sync --sync=shows

Inspect of problematic items

No response

Workarounds

No response

Install method

docker-compose

Config file contents

cache:
  path: /app/config/trakt_cache
excluded-libraries:
- Private
- Family Holidays
config:
  dotenv_override: true
plex:
  timeout: 30
logging:
  append: true
  console_time: false
  debug: false
  filename: plextraktsync.log
  filter_loggers: null
  filter: null
sync:
  plex_to_trakt:
    collection: true
    clear_collected: false
    ratings: true
    watched_status: true
    watchlist: true
  trakt_to_plex:
    liked_lists: true
    ratings: true
    watched_status: true
    watchlist: true
    watchlist_as_playlist: false
  rating_priority: plex
watch:
  add_collection: false
  remove_collection: false
  scrobble_threshold: 80
  username_filter: true
  media_progressbar: true
xbmc-providers:
  movies: imdb
  shows: tvdb

Version

0.27.11

Python Version

3.12.0

Operating System and Version

Linux-6.1.21-v8+-aarch64-with

Perhaps you can find the item from plex web, filter with year=30828.

in your trace, there's line:

    return self.library.search(libtype='episode', filters={'show.id': self.item.ratingKey})

this should appear in logs as fetching from plex server with show.id=something. you need to enable debugging logging to see those requests.

No user feedback

I am also getting the exact same error message. I noted that it stopped after synchronising the first 60 movies it found on trakt. This corresponds to exactly one page on trakt when listing the movies. It is like it can't find the movies on the "next page"

You're not alone : pkkid/python-plexapi#1262 (comment)

Are you sure this is related to the PlexAPI and not Trakt that is providing the number 30828 instead of a year due to all movies in page 1 has been parsed. The number migh be som rubbish it is scraping and trying to put it into the function where it expects a year.

I have checked both in plex and in Trakt neither place has a movie with this year.

Show your logs and settings.
Use the same template as first post.

Here is the log:

2023-12-30 01:22:51,555 INFO[PlexTraktSync]:Marking as watched in Plex: Birdman or (The Unexpected Virtue of Ignorance) (2014)
2023-12-30 01:22:52,695 ERROR[PlexTraktSync]:year 30828 is out of range
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/cli.py", line 26, in wrap
    cmd(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/commands/sync.py", line 68, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/sync.py", line 65, in sync
    for movie in walker.find_movies():
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/walker.py", line 279, in find_movies
    for plex in self.get_plex_movies():
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/walker.py", line 276, in get_plex_movies
    yield from movies
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/walker.py", line 334, in media_from_sections
    yield from it
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/walker.py", line 354, in progressbar
    yield from it
  File "/usr/local/lib/python3.9/dist-packages/tqdm/std.py", line 1182, in __iter__
    for obj in iterable:
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/plex/PlexLibrarySection.py", line 86, in items
    for item in self.all(max_items):
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/plex/PlexLibrarySection.py", line 71, in all
    items = self.fetch_items(key, size, start)
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/decorators/retry.py", line 26, in wrapper
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/plextraktsync/plex/PlexLibrarySection.py", line 83, in fetch_items
    return self.section.fetchItems(key, container_start=start, container_size=size, maxresults=size)
  File "/usr/local/lib/python3.9/dist-packages/plexapi/base.py", line 256, in fetchItems
    subresults = self.findItems(data, cls, ekey, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/plexapi/base.py", line 329, in findItems
    item = self._buildItemOrNone(elem, cls, initpath)
  File "/usr/local/lib/python3.9/dist-packages/plexapi/base.py", line 109, in _buildItemOrNone
    return self._buildItem(elem, cls, initpath)
  File "/usr/local/lib/python3.9/dist-packages/plexapi/base.py", line 101, in _buildItem
    return ecls(self._server, elem, initpath)
  File "/usr/local/lib/python3.9/dist-packages/plexapi/base.py", line 62, in __init__
    self._loadData(data)
  File "/usr/local/lib/python3.9/dist-packages/plexapi/video.py", line 387, in _loadData
    Video._loadData(self, data)
  File "/usr/local/lib/python3.9/dist-packages/plexapi/video.py", line 51, in _loadData
    self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
  File "/usr/local/lib/python3.9/dist-packages/plexapi/utils.py", line 331, in toDatetime
    return datetime.fromtimestamp(value)
ValueError: year 30828 is out of  #range
Config
config:
  dotenv_override: true
plex:
  timeout: 30
logging:
  append: true
  console_time: false
  debug: true
  filename: plextraktsync.log
  filter_loggers: null
  filter: null
sync:
  plex_to_trakt:
    collection: true
    clear_collected: false
    ratings: true
    watched_status: true
    watchlist: true
  trakt_to_plex:
    liked_lists: true
    ratings: true
    watched_status: true
    watchlist: true
    watchlist_as_playlist: false
  rating_priority: plex
watch:
  add_collection: false
  remove_collection: false
  scrobble_threshold: 80
  username_filter: true
  media_progressbar: true
xbmc-providers:
  movies: imdb
  shows: tvdb

you need to edit python plexapi code to figure out the id of the problematic item, and then you can inspect the id

#  File "/usr/local/lib/python3.9/dist-packages/plexapi/video.py", line 51, in _loadData
    self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
	try:
	    self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
	except ValueError as e:
		import json
		print("faulty addedAt: ", data.attrib.get('addedAt'))
		print("faulty item dump: ", json.dumps(data.attrib))

Re-open if you have new information, and update version information