diff --git a/README.md b/README.md index 4f062fa..a1f066c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ A basic account management system for [Jellyfin](https://github.com/jellyfin/jel * requests * itsdangerous * passlib -* configparser * pyOpenSSL * waitress * pytz diff --git a/jellyfin_accounts/jf_api.py b/jellyfin_accounts/jf_api.py index 99278a1..8a59e73 100644 --- a/jellyfin_accounts/jf_api.py +++ b/jellyfin_accounts/jf_api.py @@ -79,6 +79,7 @@ class Jellyfin: "User-Agent": self.useragent, "X-Emby-Authorization": self.auth, } + self.info = requests.get(self.server + "/System/Info/Public").json() def getUsers(self, username: str = "all", userId: str = "all", public: bool = True): """ @@ -114,16 +115,16 @@ class Jellyfin: else: try: self.authenticate(self.username, self.password) - return self.getUsers(username, id, public) + return self.getUsers(username, userId, public) except self.AuthenticationError: raise self.AuthenticationRequiredError else: response = self.userCache else: raise self.AuthenticationRequiredError - if username == "all" and id == "all": + if username == "all" and userId == "all": return response - elif id == "all": + elif userId == "all": match = False for user in response: if user["Name"] == username: @@ -134,7 +135,7 @@ class Jellyfin: else: match = False for user in response: - if user["Id"] == id: + if user["Id"] == userId: match = True return user if not match: @@ -165,6 +166,9 @@ class Jellyfin: self.auth += f"Version={self.version}" self.auth += f", Token={self.accessToken}" self.header["X-Emby-Authorization"] = self.auth + self.info = requests.get( + self.server + "/System/Info", headers=self.header + ).json() return True else: raise self.AuthenticationError diff --git a/jellyfin_accounts/validate_password.py b/jellyfin_accounts/validate_password.py index 11152c6..8837d2a 100644 --- a/jellyfin_accounts/validate_password.py +++ b/jellyfin_accounts/validate_password.py @@ -1,6 +1,7 @@ specials = ['[', '@', '_', '!', '#', '$', '%', '^', '&', '*', '(', ')', '<', '>', '?', '/', '\\', '|', '}', '{', '~', ':', ']'] + class PasswordValidator: def __init__(self, min_length, upper, lower, number, special): self.criteria = { diff --git a/jellyfin_accounts/web_api.py b/jellyfin_accounts/web_api.py index 38a16c5..1d064fc 100644 --- a/jellyfin_accounts/web_api.py +++ b/jellyfin_accounts/web_api.py @@ -66,6 +66,8 @@ if not success: log.error("Could not authenticate after 3 tries.") exit() +# Temporary fixes below. + def switchToIds(): try: @@ -101,6 +103,22 @@ def switchToIds(): # Temporary, switches emails.json over from using Usernames to User IDs. switchToIds() + +from packaging import version + +if ( + version.parse(jf.info["Version"]) >= version.parse("10.6.0") + and bool(data_store.user_template) is not False +): + log.info("Updating user_template for Jellyfin >= 10.6.0") + data_store.user_template[ + "AuthenticationProviderId" + ] = "Jellyfin.Server.Implementations.Users.DefaultAuthenticationProvider" + data_store.user_template[ + "PasswordResetProviderId" + ] = "Jellyfin.Server.Implementations.Users.DefaultPasswordResetProvider" + + if config.getboolean("password_validation", "enabled"): validator = PasswordValidator( config["password_validation"]["min_length"],