Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README Examples Incorrect/Don't Work #18

Open
william-dafriend opened this issue Jul 14, 2023 · 2 comments
Open

README Examples Incorrect/Don't Work #18

william-dafriend opened this issue Jul 14, 2023 · 2 comments

Comments

@william-dafriend
Copy link

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.

@s-t-e-v-e-n-k
Copy link
Contributor

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.

@s-t-e-v-e-n-k
Copy link
Contributor

s-t-e-v-e-n-k commented Aug 11, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants