README Examples Incorrect/Don't Work
william-dafriend opened this issue · 2 comments
The line in the README is not correct, as it contains no closing curly bracket
client.authenticate({"Servers": [credentials], discover=False)
This should likely be
client.authenticate({"Servers": [credentials]}, discover=False)
However, the authentication does not seem to work as noted. I can run the initial portion where you connect with a username/password, and I receive data that can be encoded to JSON.
This portion
json.loads(data)
client.authenticate({"Servers": [data]}, discover=False)
fails with this error
jellyfin_apiclient_python\connection_manager.py", line 88, in get_available_servers
servers.sort(key=itemgetter('DateLastAccessed'), reverse=True)
TypeError: string indices must be integers, not 'str'
Presumably one is meant to decode the data into a new object and pass that to the authenticate()
method. However
creds = json.loads(data)
client.authenticate({"Servers": [creds]}, discover=False)
results in the following
jellyfin_apiclient_python\api.py", line 512, in get_default_headers
auth += "Client=%s, " % self.config.data['app.name']
~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'app.name'
Failing server connection. ERROR msg: 'app.name'
I have looked at the resulting JSON and there are no keys that might correspond to app.name
.
Ahh, that is my error, since I wrote that part of the documentation. :-(
app.name
must be provided by the configuring the client before authenticating:
client.config.app("<app name>", "<app version>", "<client name, I use platform.node() here>", "<a UUID to identify the client, such as uuid.uuid4()>")
I meant to circle back to the documentation in the README, but haven't had time.
I see the docs already include app configuration there -- that bit is not optional, and you need to do it every time. I've pushed up a PR to fix the missing curly bracket.