Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running clear_collections command #2026

Open
3 tasks done
jrcorwin opened this issue Aug 19, 2024 · 1 comment
Open
3 tasks done

Error running clear_collections command #2026

jrcorwin opened this issue Aug 19, 2024 · 1 comment

Comments

@jrcorwin
Copy link

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

Running the clear collections command results in an error of generator raised StopIteration and appears to be hit once it transitions from clearing movies to TV shows.

Steps to reproduce the behavior

Issue plextraktsync clear-collections --confirm command

Error trace / logs

ERROR    generator raised StopIteration                                                                                                                                                                                                                                
         ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
         │ /home/elfie/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/trakt/users.py:498 in show_collection                                                                                                                                              │
         │                                                                                                                                                                                                                                                            │
         │   495 │   │   │   │   for season in seasons:                                                                                                                                                                                                               │
         │   496 │   │   │   │   │   ts = next(s for s in full_show.seasons if s.season ==                                                                                                                                                                            │
         │       season.get('number'))                                                                                                                                                                                                                                │
         │   497 │   │   │   │   │   for ep in season.get('episodes'):                                                                                                                                                                                                │
         │ ❱ 498 │   │   │   │   │   │   te = next(e for e in ts.episodes if e.number ==                                                                                                                                                                              │
         │       ep.get('number'))                                                                                                                                                                                                                                    │
         │   499 │   │   │   │   │   │   ep['title'] = te.title                                                                                                                                                                                                       │
         │   500 │   │   │   │   │   │   ep.update(te.ids)                                                                                                                                                                                                            │
         │   501 │   │   │   │   del te, ts, full_show                                                                                                                                                                                                                │
         ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
         StopIteration                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                       
         The above exception was the direct cause of the following exception:                                                                                                                                                                                          
                                                                                                                                                                                                                                                                       
         ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
         │ /home/elfie/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/cli.py:28 in wrap                                                                                                                                                    │
         │                                                                                                                                                                                                                                                            │
         │    25 │   │   │   cmd = getattr(module, name)                                                                                                                                                                                                              │
         │    26 │   │   │                                                                                                                                                                                                                                            │
         │    27 │   │   │   try:                                                                                                                                                                                                                                     │
         │ ❱  28 │   │   │   │   cmd(*args, **kwargs)                                                                                                                                                                                                                 │
         │    29 │   │   │   except EOFError as e:                                                                                                                                                                                                                    │
         │    30 │   │   │   │   raise ClickException(f"Program requested terminal, No terminal is                                                                                                                                                                    │
         │       connected: {e}")                                                                                                                                                                                                                                     │
         │    31 │   │   │   except ClickException as e:                                                                                                                                                                                                              │
         │                                                                                                                                                                                                                                                            │
         │ /home/elfie/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/commands/clear_collections.py:22 in clear_collections                                                                                                                │
         │                                                                                                                                                                                                                                                            │
         │   19 │   │   if not dry_run:                                                                                                                                                                                                                               │
         │   20 │   │   │   trakt.remove_from_collection(movie)                                                                                                                                                                                                       │
         │   21 │                                                                                                                                                                                                                                                     │
         │ ❱ 22 │   for show in trakt.show_collection if shows else []:                                                                                                                                                                                               │
         │   23 │   │   logger.info(f"Deleting from Trakt: {show}")                                                                                                                                                                                                   │
         │   24 │   │   if not dry_run:                                                                                                                                                                                                                               │
         │   25 │   │   │   trakt.remove_from_collection(show)                                                                                                                                                                                                        │
         │   229 │   │   def fun(*args, **kw):                                                                                                                                                                                                                        │
         │   230 │   │   │   if not kwsyntax:                                                                                                                                                                                                                         │
         │   231 │   │   │   │   args, kw = fix(args, kw, sig)                                                                                                                                                                                                        │
         │ ❱ 232 │   │   │   return caller(func, *(extras + args), **kw)                                                                                                                                                                                              │
         │   233 │   fun.__name__ = func.__name__                                                                                                                                                                                                                     │
         │   234 │   fun.__doc__ = func.__doc__                                                                                                                                                                                                                       │
         │   235 │   fun.__wrapped__ = func                                                                                                                                                                                                                           │
         │                                                                                                                                                                                                                                                            │
         │ /home/elfie/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/decorators/rate_limit.py:20 in rate_limit                                                                                                                            │
         │                                                                                                                                                                                                                                                            │
         │   17 │   retry = 0                                                                                                                                                                                                                                         │
         │   18 │   while True:                                                                                                                                                                                                                                       │
         │   19 │   │   try:                                                                                                                                                                                                                                          │
         │ ❱ 20 │   │   │   return fn(*args, **kwargs)                                                                                                                                                                                                                │
         │   21 │   │   except RateLimitException as e:                                                                                                                                                                                                               │
         │   22 │   │   │   if retry == retries:                                                                                                                                                                                                                      │
         │   23 │   │   │   │   logger.error(f"Trakt Error: {e}")                                                                                                                                                                                                     │
         │                                                                                                                                                                                                                                                            │
         │ /home/elfie/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/decorator.py:232 in fun                                                                                                                                                            │
         │                                                                                                                                                                                                                                                            │
         │   229 │   │   def fun(*args, **kw):                                                                                                                                                                                                                        │
         │   230 │   │   │   if not kwsyntax:                                                                                                                                                                                                                         │
         │   231 │   │   │   │   args, kw = fix(args, kw, sig)                                                                                                                                                                                                        │
         │ ❱ 232 │   │   │   return caller(func, *(extras + args), **kw)                                                                                                                                                                                              │
         │   233 │   fun.__name__ = func.__name__                                                                                                                                                                                                                     │
         │   234 │   fun.__doc__ = func.__doc__                                                                                                                                                                                                                       │
         │   235 │   fun.__wrapped__ = func                                                                                                                                                                                                                           │
         │                                                                                                                                                                                                                                                            │
         │ /home/elfie/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/decorators/retry.py:26 in retry                                                                                                                                      │
         │                                                                                                                                                                                                                                                            │
         │   23 │   count = 0                                                                                                                                                                                                                                         │
         │   24 │   while True:                                                                                                                                                                                                                                       │
         │   25 │   │   try:                                                                                                                                                                                                                                          │
         │ ❱ 26 │   │   │   return fn(*args, **kwargs)                                                                                                                                                                                                                │
         │   27 │   │   except (                                                                                                                                                                                                                                      │
         │   28 │   │   │   BadRequest,                                                                                                                                                                                                                               │
         │   29 │   │   │   BadResponseException,                                                                                                                                                                                                                     │
         │                                                                                                                                                                                                                                                            │
         │ /home/elfie/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/trakt/TraktApi.py:109 in show_collection                                                                                                                             │
         │                                                                                                                                                                                                                                                            │
         │   106 │   @rate_limit()                                                                                                                                                                                                                                    │
         │   107 │   @retry()                                                                                                                                                                                                                                         │
         │   108 │   def show_collection(self):                                                                                                                                                                                                                       │
         │ ❱ 109 │   │   return self.me.show_collection                                                                                                                                                                                                               │
         │   110 │                                                                                                                                                                                                                                                    │
         │   111 │   @cached_property                                                                                                                                                                                                                                 │
         │   112 │   @flatten_list                                                                                                                                                                                                                                    │
         │                                                                                                                                                                                                                                                            │
         │ /home/elfie/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/trakt/core.py:581 in inner                                                                                                                                                         │
         │                                                                                                                                                                                                                                                            │
         │   578 │   │   │   url, generator, _ = resp                                                                                                                                                                                                                 │
         │   579 │   │   │   json_data = self._handle_request('get', url)                                                                                                                                                                                             │
         │   580 │   │   │   try:                                                                                                                                                                                                                                     │
         │ ❱ 581 │   │   │   │   return generator.send(json_data)                                                                                                                                                                                                     │
         │   582 │   │   │   except StopIteration:                                                                                                                                                                                                                    │
         │   583 │   │   │   │   return None                                                                                                                                                                                                                          │
         │   584 │   │   return inner                                                                                                                                                                                                                                 │
         ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
         RuntimeError: generator raised StopIteration                                                                                                                                                                                                                  
Error: Error running clear_collections command: generator raised StopIteration

Expected behavior

That it would also clear the TV shows collection.

Inspect of problematic items

No response

Workarounds

No response

Config file contents

# Config File: /home/elfie/.config/PlexTraktSync/config.yml
cache:
  path: /home/elfie/.cache/PlexTraktSync/trakt_cache
excluded-libraries:
- Private
- Family Holidays
config:
  dotenv_override: true
plex:
  timeout: 300
logging:
  append: true
  console_time: false
  debug: false
  filename: plextraktsync.log
  filter_loggers: null
  filter: null
sync:
  rating_priority: plex
  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
    playback_status: false
liked_lists:
  keep_watched: true
watch:
  add_collection: false
  remove_collection: false
  scrobble_threshold: 80
  username_filter: true
  media_progressbar: true
  ignore_clients: null
xbmc-providers:
  movies: imdb
  shows: tvdb

Install method

docker-compose

Version

0.31.7

Python Version

3.8.10

Plex Server Version

1.40.5.8854-f36c552fd

Operating System and Version

Alpine Linux 3.21.0

@glensc
Copy link
Collaborator

glensc commented Aug 26, 2024

Seems trakt.show_collection gets an error from trakt module:

like the show has no episodes? what is the show with the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants