Skip to content

Commit b7e3d37

Browse files
committed
feat[embyupdate]: add handling for private users
Adds a `userid` config option for the `embyupdate` plugin. When the `userid` is provided, the Emby user lookup is bypassed. This avoids a failure to get the user ID for private users. Closes: beetbox#4402
1 parent 62859f4 commit b7e3d37

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

beetsplug/embyupdate.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,26 @@ def update(self, lib):
167167
port = config['emby']['port'].get()
168168
username = config['emby']['username'].get()
169169
password = config['emby']['password'].get()
170+
userid = config['emby']['userid'].get()
170171
token = config['emby']['apikey'].get()
171172

172173
# Check if at least a apikey or password is given.
173174
if not any([password, token]):
174175
self._log.warning('Provide at least Emby password or apikey.')
175176
return
176177

177-
# Get user information from the Emby API.
178-
user = get_user(host, port, username)
179-
if not user:
180-
self._log.warning(f'User {username} could not be found.')
181-
return
178+
if not userid:
179+
# Get user information from the Emby API.
180+
user = get_user(host, port, username)
181+
if not user:
182+
self._log.warning(f'User {username} could not be found.')
183+
return
184+
userid = user[0]['Id']
182185

183186
if not token:
184187
# Create Authentication data and headers.
185188
auth_data = password_data(username, password)
186-
headers = create_headers(user[0]['Id'])
189+
headers = create_headers(userid)
187190

188191
# Get authentication token.
189192
token = get_token(host, port, headers, auth_data)
@@ -194,7 +197,7 @@ def update(self, lib):
194197
return
195198

196199
# Recreate headers with a token.
197-
headers = create_headers(user[0]['Id'], token=token)
200+
headers = create_headers(userid, token=token)
198201

199202
# Trigger the Update.
200203
url = api_url(host, port, '/Library/Refresh')

0 commit comments

Comments
 (0)