Skip to content

Commit

Permalink
feat: 🎊 ✨ Emby and Jellyfin now update username/email on an updated scan
Browse files Browse the repository at this point in the history
  • Loading branch information
JamsRepos committed Apr 22, 2024
1 parent 46d6f22 commit 7c158ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/wizarr-backend/wizarr_backend/helpers/emby.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ def sync_emby_users(server_api_key: Optional[str] = None, server_url: Optional[s
create_user(username=emby_user["Name"], token=emby_user["Id"], email=email)
info(f"User {emby_user['Name']} successfully imported to database.")

# If the user does exist then update their username and email
else:
user = get_user_by_token(emby_user["Id"], verify=False)
user.username = emby_user["Name"]
user.email = emby_user["ConnectUserName"] if "ConnectUserName" in emby_user else None
user.save()
info(f"User {emby_user['Name']} successfully updated in database.")

# If database_users.token not in emby_users.id, delete from database
for database_user in database_users:
if str(database_user.token) not in [str(emby_user["Id"]) for emby_user in emby_users]:
Expand Down
7 changes: 7 additions & 0 deletions apps/wizarr-backend/wizarr_backend/helpers/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@ def sync_jellyfin_users(server_api_key: Optional[str] = None, server_url: Option
create_user(username=jellyfin_user["Name"], token=jellyfin_user["Id"])
info(f"User {jellyfin_user['Name']} successfully imported to database.")

# If the user does exist then update their username
else:
user = get_user_by_token(jellyfin_user["Id"], verify=False)
user.username = jellyfin_user["Name"]
user.save()
info(f"User {jellyfin_user['Name']} successfully updated in database.")

# If database_users.token not in jellyfin_users.id, delete from database
for database_user in database_users:
if str(database_user.token) not in [str(jellyfin_user["Id"]) for jellyfin_user in jellyfin_users]:
Expand Down

0 comments on commit 7c158ca

Please sign in to comment.