luigi311 / JellyPlex-Watched

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

[bug] Can't dry run sync, `Unexpected mimetype: text/html` #32

Closed lightmaster closed 1 year ago

lightmaster commented 1 year ago

Trying to test syncing with a dry run first, but the docker container keeps throwing python errors about not being able to connect to the Jellyfin Server. The server running Docker is not the same server as the one running Plex and Jellyfin, but it can connect using other docker containers without issue. Below is my sanitized .env file and the error.

.env ``` ## Do not mark any shows/movies as played and instead just output to log if they would of been marked. DRYRUN = "True" ## Additional logging information DEBUG = "True" ## Debugging level, "info" is default, "debug" is more verbose DEBUG_LEVEL = "debug" ## How often to run the script in seconds SLEEP_DURATION = "3600" ## Log file where all output will be written to LOGFILE = "log.log" ## Map usernames between plex and jellyfin in the event that they are different, order does not matter #USER_MAPPING = { "testuser2": "testuser3" } ## Map libraries between plex and jellyfin in the even that they are different, order does not matter #LIBRARY_MAPPING = { "Shows": "TV Shows" } ## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly ## Comma seperated list for multiple servers PLEX_BASEURL = "http://10.0.0.11:32400" ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ PLEX_TOKEN = "*****" ## If not using plex token then use username and password of the server admin along with the servername #PLEX_USERNAME = "" #PLEX_PASSWORD = "" #PLEX_SERVERNAME = "Plex Server" ## Skip hostname validation for ssl certificates. SSL_BYPASS = "True" ## Jellyfin server URL, use hostname or IP address if the hostname is not resolving correctly ## Comma seperated list for multiple servers JELLYFIN_BASEURL = "http://10.0.0.11:8096/" ## Jellyfin api token, created manually by logging in to the jellyfin server admin dashboard and creating an api key JELLYFIN_TOKEN = "*****" ## Blacklisting/Whitelisting libraries, library types such as Movies/TV Shows, and users. Mappings apply so if the mapping for the user or library exist then both will be excluded. #BLACKLIST_LIBRARY = "" #WHITELIST_LIBRARY = "" #BLACKLIST_LIBRARY_TYPE = "" #WHITELIST_LIBRARY_TYPE = "" #BLACKLIST_USERS = "" #WHITELIST_USERS = "testuser1,testuser2" ```
log.log ``` [INFO]: Dryrun: True [INFO]: User Mapping: {'user test': 'user test2'} [INFO]: Library Mapping: {'Shows Test': 'TV Shows Test'} [INFO]: Creating (black/white)lists [INFO]: Blacklist Library: [] [INFO]: Whitelist Library: [] [INFO]: Blacklist Library Type: [] [INFO]: Whitelist Library Type: [] [INFO]: Blacklist Users: [] [INFO]: Whitelist Users: [] [INFO]: Creating server connections [ERROR]: Jellyfin: Query failed 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://10.0.0.11:8096/jellyfin/web/index.html') [ERROR]: Jellyfin: Get users failed 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://10.0.0.11:8096/jellyfin/web/index.html') [ERROR]: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://10.0.0.11:8096/jellyfin/web/index.html') [ERROR]: Traceback (most recent call last): File "/app/src/jellyfin.py", line 41, in query results = await response.json() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1104, in json raise ContentTypeError( aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://10.0.0.11:8096/jellyfin/web/index.html') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/src/jellyfin.py", line 64, in get_users response = await self.query(query_string, "get", session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/jellyfin.py", line 56, in query raise Exception(e) Exception: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://10.0.0.11:8096/jellyfin/web/index.html') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/src/main.py", line 639, in main main_loop() File "/app/src/main.py", line 561, in main_loop servers = generate_server_connections() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/main.py", line 506, in generate_server_connections Jellyfin(baseurl=baseurl.strip(), token=jellyfin_token[i].strip()), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/src/jellyfin.py", line 22, 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 650, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/app/src/jellyfin.py", line 74, in get_users raise Exception(e) Exception: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://10.0.0.11:8096/jellyfin/web/index.html') Retrying in 3600.0 ```
luigi311 commented 1 year ago

Looks like this happens when you have a / at the end of the urls. Removing it from your .env should solve it but i will also implement a fix for it so you this doesnt happen.

luigi311 commented 1 year ago

This should be fixed now. I merged in the fix to main and also created a new release so go ahead and do another docker pull and give it a try again.