luigi311 / JellyPlex-Watched

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

[Need Help] Attempt to decode JSON with unexpected mimetype: text/html', url=URL('....') #46

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hey!

I'm getting this error when using your lovely software:

Output from the log.log: https://paste.ec/paste/jmH-GoOH#qetLghapEmczdLcCZ1uFzeSBaAQ8T7xaa7yHzjxjfFT

I'm running it in docker.

My docker-compose.yml setup:

version: "3.9"

services:
  jellyplexwatched:
    container_name: jellyplexwatched
    image: luigi311/jellyplex-watched:latest
    labels:
     - "org.hotio.pullio.notify=true"
     - "org.hotio.pullio.update=true"
     - "org.hotio.pullio.generic.webhook=https://notifiarr.com/api/v1/notification/pullio/xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx"
     - "autoheal=true"
    volumes:
      - /opt/docker-all/jellyplexwatched/config.env:/app/.env
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

My config.env (with URLs etc redacted): https://paste.ec/paste/V0p7h0Fa#4QWxivibZG60U8eM1EDRLyn8j5QEC7KC17+j44upsfi

My NGINX file for my jellyfin.domain.com, if that matters at all. I'm just using the official nginx reverse proxy from the jellyfin docs: https://paste.ec/paste/mLYMPSIM#vUgW46tgSt59ACOIffnI9arMq8OjKoGZ7TTnXHxje9k

ghost commented 1 year ago

This also appears in the log, if the docker container just stays open:

2023-03-04T22:44:47.022380542Z [ERROR]: Jellyfin: Query failed 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://jellyfin.nzc.su/Users/b488f6fb18c8426dbb621ee35972cdb7/Items?ParentId=767bffe4f11c93ef34b805451a696a4e&isPlaceHolder=false&IncludeItemTypes=Series&Recursive=True&Fields=ProviderIds,Path,RecursiveItemCount')
2023-03-04T22:44:47.022562685Z [ERROR]: Jellyfin: Failed to get watched for baht in library TV Shows, Error: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://jellyfin.nzc.su/Users/b488f6fb18c8426dbb621ee35972cdb7/Items?ParentId=767bffe4f11c93ef34b805451a696a4e&isPlaceHolder=false&IncludeItemTypes=Series&Recursive=True&Fields=ProviderIds,Path,RecursiveItemCount')
2023-03-04T22:44:47.023048401Z [ERROR]: Traceback (most recent call last):
2023-03-04T22:44:47.023057198Z   File "/app/src/jellyfin.py", line 41, in query
2023-03-04T22:44:47.023061786Z     results = await response.json()
2023-03-04T22:44:47.023064001Z               ^^^^^^^^^^^^^^^^^^^^^
2023-03-04T22:44:47.023066014Z   File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json
2023-03-04T22:44:47.023068138Z     raise ContentTypeError(
2023-03-04T22:44:47.023070393Z aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://jellyfin.nzc.su/Users/b488f6fb18c8426dbb621ee35972cdb7/Items?ParentId=767bffe4f11c93ef34b805451a696a4e&isPlaceHolder=false&IncludeItemTypes=Series&Recursive=True&Fields=ProviderIds,Path,RecursiveItemCount')
2023-03-04T22:44:47.023073128Z
2023-03-04T22:44:47.023075633Z During handling of the above exception, another exception occurred:
2023-03-04T22:44:47.023077777Z
2023-03-04T22:44:47.023079740Z Traceback (most recent call last):
2023-03-04T22:44:47.023092134Z   File "/app/src/jellyfin.py", line 161, in get_user_library_watched
2023-03-04T22:44:47.023094949Z     watched_shows = await self.query(
2023-03-04T22:44:47.023096993Z                     ^^^^^^^^^^^^^^^^^
2023-03-04T22:44:47.023099037Z   File "/app/src/jellyfin.py", line 61, in query
2023-03-04T22:44:47.023101141Z     raise Exception(e)
2023-03-04T22:44:47.023103325Z Exception: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://jellyfin.nzc.su/Users/b488f6fb18c8426dbb621ee35972cdb7/Items?ParentId=767bffe4f11c93ef34b805451a696a4e&isPlaceHolder=false&IncludeItemTypes=Series&Recursive=True&Fields=ProviderIds,Path,RecursiveItemCount')
2023-03-04T22:44:47.023105990Z
2023-03-04T22:44:47.243345676Z [ERROR]: Jellyfin: Query failed 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://jellyfin.nzc.su/Users/71bee84681c04598bd1981bd02b0ec9b/Items?ParentId=767bffe4f11c93ef34b805451a696a4e&isPlaceHolder=false&IncludeItemTypes=Series&Recursive=True&Fields=ProviderIds,Path,RecursiveItemCount')
2023-03-04T22:44:47.243603583Z [ERROR]: Jellyfin: Failed to get watched for fuckingsignup in library TV Shows, Error: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://jellyfin.nzc.su/Users/71bee84681c04598bd1981bd02b0ec9b/Items?ParentId=767bffe4f11c93ef34b805451a696a4e&isPlaceHolder=false&IncludeItemTypes=Series&Recursive=True&Fields=ProviderIds,Path,RecursiveItemCount')
2023-03-04T22:44:47.244257195Z [ERROR]: Traceback (most recent call last):
2023-03-04T22:44:47.244266021Z   File "/app/src/jellyfin.py", line 41, in query
2023-03-04T22:44:47.244270189Z     results = await response.json()
2023-03-04T22:44:47.244273836Z               ^^^^^^^^^^^^^^^^^^^^^
2023-03-04T22:44:47.244277383Z   File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json
2023-03-04T22:44:47.244281491Z     raise ContentTypeError(
2023-03-04T22:44:47.244285087Z aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://jellyfin.nzc.su/Users/71bee84681c04598bd1981bd02b0ec9b/Items?ParentId=767bffe4f11c93ef34b805451a696a4e&isPlaceHolder=false&IncludeItemTypes=Series&Recursive=True&Fields=ProviderIds,Path,RecursiveItemCount')
2023-03-04T22:44:47.244290638Z

Just FYI, I can connect and use Jellyfin just fine.

The entire log, from letting it run a few hours: https://paste.ec/paste/ggW+0ndX#9ny0csbX6OwE4En6V+EOusWxeNYfsYuFKHNSdMrtWl5

luigi311 commented 1 year ago

Can you try the dev branch and see what it says. I add in a check for response status of 200 and if not it will output what the server responded for the status code and reason. It should give you some more information on whats going wrong.

ghost commented 1 year ago

Thank you!

I think I solved it. It was a 504 Timeout Error.

So I increased the timeout in the jellyfin.domain.com.conf file in my NGINX sites-available folder. Added this in all the /location blocks:

  proxy_connect_timeout       600;
  proxy_send_timeout          600;
  proxy_read_timeout          600;

This didn't seem to have much of an effect.

I tried changing my server's DNS Nameserver as well, which seemingly did the trick. Before it was using Hetzner's DNS Nameservers. I changed them to the 1.1.1.1 DNS Nameservers, and now it seems to work.

So thanks for adding a "response" the error, so that I could do some troubleshooting.