Skip to content

Commit

Permalink
Add username resolution for session connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwalton3 committed Mar 24, 2021
1 parent f4bc05f commit 5f0d508
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jellyfin_mpv_shim/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self):
self.callback = lambda client, event_name, data: None
self.credentials = []
self.clients = {}
self.usernames = {}
self.is_stopping = False

def cli_connect(self):
Expand Down Expand Up @@ -192,6 +193,8 @@ def connect_client(self, server):
is_logged_in = True
self.clients[server["uuid"]] = client
self.setup_client(client, server)
if server.get("username"):
self.usernames[server["uuid"]] = server["username"]

return is_logged_in

Expand Down Expand Up @@ -229,6 +232,8 @@ def get_username_from_client(self, client):
# was added before we started saving usernames.
for uuid, client2 in self.clients.items():
if client2 is client:
if uuid in self.usernames:
return self.usernames[uuid]
for server in self.credentials:
if server["uuid"] == uuid:
return server.get("username", "Unknown")
Expand Down

0 comments on commit 5f0d508

Please sign in to comment.