jellyfin / mopidy-jellyfin

Jellyfin Extension for Mopidy
https://jellyfin.org
Apache License 2.0
93 stars 16 forks source link

TypeError: can't concat str to bytes #70

Closed arthurlutz closed 3 years ago

arthurlutz commented 4 years ago
2020-07-06 19:26:01,566 INFO [7641:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 0 with problem: HTTPSConnectionPool(host='192.168.0.26', port=443): Max retries exceeded with 
url: /yunohost/admin (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
2020-07-06 19:26:01,722 INFO [7641:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 1 with problem: HTTPSConnectionPool(host='192.168.0.26', port=443): Max retries exceeded with 
url: /yunohost/admin (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
2020-07-06 19:26:01,864 INFO [7641:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 2 with problem: HTTPSConnectionPool(host='192.168.0.26', port=443): Max retries exceeded with 
url: /yunohost/admin (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
2020-07-06 19:26:02,007 INFO [7641:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 3 with problem: HTTPSConnectionPool(host='192.168.0.26', port=443): Max retries exceeded with 
url: /yunohost/admin (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
2020-07-06 19:26:02,160 INFO [7641:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 4 with problem: HTTPSConnectionPool(host='192.168.0.26', port=443): Max retries exceeded with 
url: /yunohost/admin (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
2020-07-06 19:26:02,302 INFO [7641:MainThread] mopidy_jellyfin.http: Jellyfin connection on tr
y 5 with problem: HTTPSConnectionPool(host='192.168.0.26', port=443): Max retries exceeded with url: /yunohost/admin (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
2020-07-06 19:26:02,311 ERROR [7641:MainThread] mopidy.commands: Got un-handled exception from JellyfinBackend
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/mopidy/commands.py", line 241, in _actor_error_handling
    yield
  File "/usr/local/lib/python3.7/dist-packages/mopidy/commands.py", line 406, in start_backends
    config=config, audio=audio
  File "/usr/local/lib/python3.7/dist-packages/pykka/_actor.py", line 91, in start
    obj = cls(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/backend.py", line 26, in __init__
    self.remote = JellyfinHandler(config)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/remote.py", line 76, in __init__
    self._login()
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/remote.py", line 89, in _login
    url = self.api_url('/Users/AuthenticateByName')
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/remote.py", line 144, in api_url
    path = path + endpoint
TypeError: can't concat str to bytes

This probably leads to #69 which I just reported.

arthurlutz commented 4 years ago

My hostname setting was just the IP of the jellyfin server. I added the port with the IP:port syntax (http port) and I get a different error now :

2020-07-06 19:42:20,398 INFO [9475:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 0 with problem: Expecting value: line 1 column 1 (char 0)
2020-07-06 19:42:20,426 INFO [9475:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 1 with problem: Expecting value: line 1 column 1 (char 0)
2020-07-06 19:42:20,450 INFO [9475:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 2 with problem: Expecting value: line 1 column 1 (char 0)
2020-07-06 19:42:20,474 INFO [9475:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 3 with problem: Expecting value: line 1 column 1 (char 0)
2020-07-06 19:42:20,501 INFO [9475:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 4 with problem: Expecting value: line 1 column 1 (char 0)
2020-07-06 19:42:20,531 INFO [9475:MainThread] mopidy_jellyfin.http: Jellyfin connection on try 5 with problem: Expecting value: line 1 column 1 (char 0)
2020-07-06 19:42:20,532 ERROR [9475:MainThread] mopidy.commands: Got un-handled exception from JellyfinBackend
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/mopidy/commands.py", line 241, in _actor_error_handling
    yield
  File "/usr/local/lib/python3.7/dist-packages/mopidy/commands.py", line 406, in start_backends
    config=config, audio=audio
  File "/usr/local/lib/python3.7/dist-packages/pykka/_actor.py", line 91, in start
    obj = cls(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/backend.py", line 26, in __init__
    self.remote = JellyfinHandler(config)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/remote.py", line 76, in __init__
    self._login()
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/remote.py", line 91, in _login
    url, self.auth_data)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/http.py", line 83, in post
    raise Exception('Cant connect to Jellyfin API')
Exception: Cant connect to Jellyfin API
mcarlton00 commented 4 years ago

This is indeed likely causing the error in #69. It's failing to authenticate, so then it can never write the authentication token for the frontend to read. It seems as though you're trying to use https with an IP address, which doesn't really make sense. The Max retries exceeded with url: /yunohost/admin is particularly confusing, as I've never seen a Jellyfin URL that looks like that before.

arthurlutz commented 4 years ago

For the /yunohost/admin it's because my jellyfin instance is installed using with https://yunohost.org/#/ and https://github.com/YunoHost-Apps/jellyfin_ynh (it redirectes to the SSO of yunohost) this is fixed when switching to IP:PORT

mcarlton00 commented 4 years ago

I'm not sure this is going to work for you in that case. We're expecting to hit Jellyfin directly, and it being redirected to a different location is surely throwing a monkey wrench into the mix here. Are any of the other Jellyfin apps working for you? This doesn't sound like something that's been accounted for

arthurlutz commented 4 years ago

I succesfully used that jellyfin on other clients (android), so I'm not sure the server install is the problem.

Went back to it after the trial'n'error process I had on other clients and got it to work using the following syntax :

hostname = http://192.168.0.26:8096/jellyfin/

Maybe the documentation could be updated ? And as for #69 I would recommend catching those errors and logging some more meaningful messages so that other users can setup this client.

mcarlton00 commented 4 years ago

So you have a baseurl defined on your server and weren't including it before? Just trying to understand the process that lead to the errors

arthurlutz commented 4 years ago

Yes that's right.

mcarlton00 commented 4 years ago

In that case this one basically boils down to user error. There could possibly be a check to verify that it can connect to the server before attempting to authenticate, but it can't really be "fixed", exactly. Bad data causes code to behave in unexpected ways