Added user email modification to admin page

Pressing the user settings button brings up a list of all jellyfin
users, and allows you to add or change their stored email addresses.
Additionally, changed emails.json to use user ID instead of username.
The program automatically converts the file to the new format at start.
This commit is contained in:
2020-04-20 20:37:39 +01:00
parent e8ad3f98d6
commit 200ad24f96
6 changed files with 230 additions and 26 deletions

View File

@@ -35,11 +35,21 @@ class Jellyfin:
"User-Agent": self.useragent,
"X-Emby-Authorization": self.auth
}
def getUsers(self, username="all"):
response = requests.get(self.server+"/emby/Users/Public").json()
if username == "all":
return response
def getUsers(self, username="all", id="all", public=True):
if public:
response = requests.get(self.server+"/emby/Users/Public").json()
else:
response = requests.get(self.server+"/emby/Users",
headers=self.header,
params={'Username': self.username,
'Pw': self.password})
if response.status_code == 200:
response = response.json()
else:
raise self.AuthenticationRequiredError
if username == "all" and id == "all":
return response
elif id == "all":
match = False
for user in response:
if user['Name'] == username:
@@ -47,6 +57,14 @@ class Jellyfin:
return user
if not match:
raise self.UserNotFoundError
else:
match = False
for user in response:
if user['Id'] == id:
match = True
return user
if not match:
raise self.UserNotFoundError
def authenticate(self, username, password):
self.username = username
self.password = password