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

Crashing randomly : JSONDecodeError from Trakt #975

Closed
2 tasks done
Spencer-0003 opened this issue Jul 13, 2022 · 6 comments · Fixed by #1123
Closed
2 tasks done

Crashing randomly : JSONDecodeError from Trakt #975

Spencer-0003 opened this issue Jul 13, 2022 · 6 comments · Fixed by #1123
Labels
trakt support Issues that are related to problems with trakt.tv api

Comments

@Spencer-0003
Copy link

Spencer-0003 commented Jul 13, 2022

Confirmation

  • I have read the README.md on the project homepage
  • I have checked if identical issue already exists

The problem

My container crashes every 30 seconds to a minute.

Error trace / logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/app/plextraktsync/__main__.py", line 18, in <module>
    cli()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/app/plextraktsync/cli.py", line 46, in cli
    sync()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/app/plextraktsync/cli.py", line 28, in wrap
    cmd(*args, **kwargs)
  File "/app/plextraktsync/commands/sync.py", line 60, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "/app/plextraktsync/sync.py", line 82, in sync
    walker.trakt.batch.flush(force=True)
  File "/app/plextraktsync/trakt_api.py", line 371, in flush
    self.submit_collection()
  File "/app/plextraktsync/decorators/nocache.py", line 12, in inner
    return method(*args, **kwargs)
  File "/app/plextraktsync/decorators/rate_limit.py", line 22, in wrapper
    return fn(*args, **kwargs)
  File "/app/plextraktsync/decorators/time_limit.py", line 18, in wrapper
    return fn(*args, **kwargs)
  File "/app/plextraktsync/decorators/retry.py", line 25, in wrapper
    return fn(*args, **kwargs)
  File "/app/plextraktsync/trakt_api.py", line 348, in submit_collection
    result = self.trakt_sync_collection(self.collection)
  File "/app/plextraktsync/trakt_api.py", line 385, in trakt_sync_collection
    return trakt.sync.add_to_collection(media_object)
  File "/usr/local/lib/python3.10/site-packages/trakt/core.py", line 587, in inner
    json_data = self._handle_request('post', url, data=args)
  File "/usr/local/lib/python3.10/site-packages/trakt/core.py", line 532, in _handle_request
    json_data = json.loads(response.content.decode('UTF-8', 'ignore'))
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Expected behavior

Not crash.

Steps to reproduce the behavior

Run the initial setup (enter email and enter the code etc....)

Inspect of problematic items

No response

Workarounds

No response

Install method

docker-compose

Version

0.20.4

Python Version

3.10.5 (main, Jun 7 2022, 19:35:00) [GCC 10.3.1 20211027]

Operating System and Version

Synology DSM 7.1-42661 Update 3

@glensc glensc added the trakt support Issues that are related to problems with trakt.tv api label Jul 14, 2022
@glensc
Copy link
Collaborator

glensc commented Jul 14, 2022

I think trakt api has issues.

The fix is available to have better reporting:

but unfortunately, the maintainer has disappeared:

@douginoz
Copy link

douginoz commented Jul 18, 2022

I just ran plextraktsync for the first time in months after updating it, and it got through all my libraries except failed at the start of the TV library. Subsequent running continued past this point.

INFO     Marking as watched in Plex: <tmdb:537648:Episode:244129:Adventure-Time-s02e13>                                                                                              
INFO     Adding to collection: <tmdb:537652:Episode:244130:Adventure-Time-s02e14>                                                                                                    
INFO     Marking as watched in Plex: <tmdb:537652:Episode:244130:Adventure-Time-s02e14>                                                                                              
INFO     Adding to collection: <tmdb:537653:Episode:244131:Adventure-Time-s02e15>                                                                                                    
INFO     Adding to collection: <tmdb:537654:Episode:244132:Adventure-Time-s02e16>                                                                                                    
INFO     Adding to collection: <tmdb:537655:Episode:244134:Adventure-Time-s02e17>                                                                                                    
INFO     Adding to collection: <tmdb:537649:Episode:244133:Adventure-Time-s02e18>                                                                                                    
INFO     Adding to collection: <tmdb:537650:Episode:244135:Adventure-Time-s02e19> 
Processing TV Shows   1% ━━━━━━━━━━━━ 13/1,038  [ 0:03:14 < 0:35:32 , 0 it/s ]
Traceback (most recent call last):
  File "/home/moa/.local/bin/plextraktsync", line 8, in <module>
    sys.exit(cli())
  File "/home/moa/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/moa/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
[etc etc - stack same as previously reported, and finishes as below]
 File "/home/moa/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/plextraktsync/trakt_api.py", line 385, in trakt_sync_collection
    return trakt.sync.add_to_collection(media_object)
  File "/home/moa/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/trakt/core.py", line 587, in inner
    json_data = self._handle_request('post', url, data=args)
  File "/home/moa/.local/pipx/venvs/PlexTraktSync/lib/python3.8/site-packages/trakt/core.py", line 532, in _handle_request
    json_data = json.loads(response.content.decode('UTF-8', 'ignore'))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

$ plextraktsync info
PlexTraktSync Version: 0.20.4
Python Version: 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
Plex API Version: 4.11.2
Trakt API Version: 3.4.0
Cache Dir: /home/moa/.cache/PlexTraktSync
Config Dir: /home/moa/.config/PlexTraktSync
Log Dir: /home/moa/.cache/PlexTraktSync/log
Plex username: xxxxx
Trakt username: xxx
Plex Server version: 1.27.2.5929-a806c5905, updated at: 2022-07-17 22:00:35
Enabled 11 libraries in Plex Server: ['Christmas Movies', 'Christmas TV Shows', 'Concerts', 'Movies', 'Movies - 3D', 'Movies - 4K', 'Opera', 'TV Shows', 'Christmas Music', 'Classical Music', 'Music']

@darylf
Copy link

darylf commented Aug 3, 2022

I'm seeing the JSONDecodeError as well, and it seems to be while adding the same TV episode to collection every time.

INFO Adding to collection: tmdb:941535:Episode:11744:Doctor-Who-(2005)-s06e05

Here's the stack trace:

Traceback (most recent call last):
  File "/home/username/.local/bin/plextraktsync", line 8, in <module>
    sys.exit(cli())
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/cli.py", line 46, in cli
    sync()
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/cli.py", line 28, in wrap
    cmd(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/commands/sync.py", line 60, in sync
    runner.sync(walker=w, dry_run=config.dry_run)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/sync.py", line 75, in sync
    self.sync_collection(episode, dry_run=dry_run)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/sync.py", line 103, in sync_collection
    m.add_to_collection(batch=True)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/media.py", line 90, in add_to_collection
    self.trakt_api.add_to_collection(self.trakt, self.plex, batch=batch)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/trakt_api.py", line 235, in add_to_collection
    self.batch.add_to_collection(m.media_type, item)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/trakt_api.py", line 381, in add_to_collection
    self.flush()
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/trakt_api.py", line 371, in flush
    self.submit_collection()
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/decorators/nocache.py", line 12, in inner
    return method(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/decorators/rate_limit.py", line 22, in wrapper
    return fn(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/decorators/time_limit.py", line 18, in wrapper
    return fn(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/decorators/retry.py", line 25, in wrapper
    return fn(*args, **kwargs)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/trakt_api.py", line 348, in submit_collection
    result = self.trakt_sync_collection(self.collection)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/plextraktsync/trakt_api.py", line 385, in trakt_sync_collection
    return trakt.sync.add_to_collection(media_object)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/trakt/core.py", line 587, in inner
    json_data = self._handle_request('post', url, data=args)
  File "/home/username/.local/pipx/venvs/plextraktsync/lib/python3.10/site-packages/trakt/core.py", line 532, in _handle_request
    json_data = json.loads(response.content.decode('UTF-8', 'ignore'))
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I'm not sure if there's an additional log I could provide with more info.

@glensc
Copy link
Collaborator

glensc commented Aug 3, 2022

JSONDecodeError probably means trakt.tv site errors. should be recovered with a retry at some point.

@darylf
Copy link

darylf commented Aug 3, 2022

Is there any way for the app to eat the error and continue? Or perhaps meet a certain number of errors before it fails?

@glensc
Copy link
Collaborator

glensc commented Aug 4, 2022

it's there waiting for PyTrakt change:

@simonc56 simonc56 changed the title Crashing randomly Crashing randomly : JSONDecodeError from Trakt Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
trakt support Issues that are related to problems with trakt.tv api
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants