luigi311 / JellyPlex-Watched

Sync watched between jellyfin and plex locally
GNU General Public License v3.0
392 stars 19 forks source link

[BUG] Cannot decode JSON on Jellyfin Users #97

Closed tquizzle closed 8 months ago

tquizzle commented 11 months ago

Cannot decode JSON Unable to use the tool, as it fails in opening the URI to Jellyfin.

To Reproduce Steps to reproduce the behavior:

  1. Configure .env or docker runtime vars
  2. Start container
  3. See error

Expected behavior I expect it to sync the way it's described (and the way I've used it before)

Logs

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/src/main.py", line 382, in main
    main_loop()
  File "/app/src/main.py", line 298, in main_loop
    servers = generate_server_connections()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/main.py", line 146, in generate_server_connections
    Jellyfin(baseurl=baseurl, token=jellyfin_token[i].strip()),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/jellyfin.py", line 80, in __init__
    self.users = asyncio.run(self.get_users())
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/app/src/jellyfin.py", line 144, in get_users
    raise Exception(e)
Exception: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('http://10.0.1.150:8096/Users')

Type:

angrycuban13 commented 11 months ago

I am having the same issue. Here's my docker compose

  jellyplexwatched:
    container_name: jellyplexwatched
    environment:
      - BLACKLIST_LIBRARY_TYPE=
      - BLACKLIST_LIBRARY=
      - BLACKLIST_USERS=
      - DEBUG_LEVEL=debug
      - DEBUG=True
      - DRYRUN=True
      - 'JELLYFIN_BASEURL=http://jellyfin:8096'
      - JELLYFIN_TOKEN=myAPIKey
      - LIBRARY_MAPPING=
      - LOGFILE=/tmp/log.log
      - 'PLEX_BASEURL=http://plex:32400'
      - PLEX_TOKEN=myPlexTOKEN
      - RUN_ONLY_ONCE=False
      - SLEEP_DURATION=3600
      - SSL_BYPASS=True
      - SYNC_FROM_JELLYFIN_TO_JELLYFIN=True
      - SYNC_FROM_JELLYFIN_TO_PLEX=False
      - SYNC_FROM_PLEX_TO_JELLYFIN=True
      - SYNC_FROM_PLEX_TO_PLEX=True
      - USER_MAPPING=
      - WHITELIST_LIBRARY_TYPE=
      - WHITELIST_LIBRARY=
      - WHITELIST_USERS=
    hostname: ${DOCKERHOSTNAME}
    image: luigi311/jellyplex-watched
    labels: *ref_0
    logging: *ref_1
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${DOCKERWASTEDATA}/logs/jellyplexwatched:/tmp

I added the single quotes around those vars in case it was having issues escaping some characters but nothing has changed.

I also verified my API key has valid access by running http://myHost:8096/Users?api_key=myAPIKey and seeing the JSON response

I think this might be a Jellyfin issue because even Autoscan is throwing errors for me. I am on version 10.8.10 of Jellyfin if that helps

tquizzle commented 11 months ago

I am having the same issue. Here's my docker compose

  jellyplexwatched:
    container_name: jellyplexwatched
    environment:
      - BLACKLIST_LIBRARY_TYPE=
      - BLACKLIST_LIBRARY=
      - BLACKLIST_USERS=
      - DEBUG_LEVEL=debug
      - DEBUG=True
      - DRYRUN=True
      - 'JELLYFIN_BASEURL=http://jellyfin:8096'
      - JELLYFIN_TOKEN=myAPIKey
      - LIBRARY_MAPPING=
      - LOGFILE=/tmp/log.log
      - 'PLEX_BASEURL=http://plex:32400'
      - PLEX_TOKEN=myPlexTOKEN
      - RUN_ONLY_ONCE=False
      - SLEEP_DURATION=3600
      - SSL_BYPASS=True
      - SYNC_FROM_JELLYFIN_TO_JELLYFIN=True
      - SYNC_FROM_JELLYFIN_TO_PLEX=False
      - SYNC_FROM_PLEX_TO_JELLYFIN=True
      - SYNC_FROM_PLEX_TO_PLEX=True
      - USER_MAPPING=
      - WHITELIST_LIBRARY_TYPE=
      - WHITELIST_LIBRARY=
      - WHITELIST_USERS=
    hostname: ${DOCKERHOSTNAME}
    image: luigi311/jellyplex-watched
    labels: *ref_0
    logging: *ref_1
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${DOCKERWASTEDATA}/logs/jellyplexwatched:/tmp

I added the single quotes around those vars in case it was having issues escaping some characters but nothing has changed.

I also verified my API key has valid access by running http://myHost:8096/Users?api_key=myAPIKey and seeing the JSON response

I think this might be a Jellyfin issue because even Autoscan is throwing errors for me. I am on version 10.8.10 of Jellyfin if that helps

Thanks @angrycuban13 I do think it's Jellyfin as another tool tried produces similar errors while Plex's endpoint works fine.

luigi311 commented 11 months ago

I don’t think this is related to a jellyfin update since im also running 10.8.10 and it’s running fine on my side. I’m assuming you guys are using server api keys and not user api keys right?

mean you guys try running it via docker directly or native to see if it works that way. It will rule out any issues with the docker compose setup since i dont use docker compose for this.

angrycuban13 commented 11 months ago

It definitely seems to be a docker-compose issue. Running it from a virtual python environment works.

angrycuban13 commented 11 months ago

FWIW, I can curl from jellyplexwatched to jellyfin (container to container) just fine

image

luigi311 commented 9 months ago

Im testing docker compose and it seems to be working on my side I did it without any quotes anywhere for the baseurl and tokens and it seems to be working with the dev tag for me so it makes it hard for me to debug an issue like this.

luigi311 commented 9 months ago

@angrycuban13 can you try doing your baseurl and token without any quotes at all and see if it works and recreate your container with the dev branch or just point to luigi311/jellyplex-watched:dev

angrycuban13 commented 9 months ago

@luigi311 ill give it a try on the dev branch

angrycuban13 commented 9 months ago

For some reason, on the dev tag, I get file permission errors for the log file but it seems to work fine on master. When I remove the LOGFILE environment variable, the container starts up but I get the same error

ageisen2000 commented 9 months ago

This is also not working for me via the docker run commands or docker compose

ageisen2000 commented 9 months ago

I changed my internal subnet settings on jellyfin and added the docker subnet as internal ip addresses. Now the tool is running correctly.

Could this be the issue? Or is this just randomly working now because I saved settings in jellyfin or something?

image

luigi311 commented 9 months ago

Ohh thats interesting yeah thats probably it then. I disabled the remote access setting and set the lan network and i now get the exact same error

angrycuban13 commented 9 months ago

I do have remote access disabled and I didn't even think to enable it.

luigi311 commented 9 months ago

just locked myself out of my jellyfin instance, guess its time to figure out how to reverse what i changed lol.

ageisen2000 commented 9 months ago

I did the same. Edit the xml file and turn that option back off.

On Wed, Dec 6, 2023, 6:55 PM Luigi311 @.***> wrote:

just locked myself out of my jellyfin instance, guess its time to figure out how to reverse what i changed lol.

— Reply to this email directly, view it on GitHub https://github.com/luigi311/JellyPlex-Watched/issues/97#issuecomment-1843957893, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDPMWCSDWXFPGFV3E2BJ2LYIEHZLAVCNFSM6AAAAAA42L6GEGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBTHE2TOOBZGM . You are receiving this because you commented.Message ID: @.***>

luigi311 commented 9 months ago

ayy im back in lol thanks looks like i just had to edit the network.xml

luigi311 commented 8 months ago

I think we can go ahead and close it since both of you seem to have resolved the issue

angrycuban13 commented 8 months ago

Was there a code commit to fix it? Is the fix to enable remote access?

ageisen2000 commented 8 months ago

I think we can go ahead and close it since both of you seem to have resolved the issue

Do you think you could update the documentation to outline the fix for this issue? Would probably save more tickets down the line