diff options
author | Parker <contact@pkrm.dev> | 2024-06-19 11:08:37 -0500 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-06-19 11:08:37 -0500 |
commit | 00d217f4539747171be4d865f9c277eb0c77b705 (patch) | |
tree | 9055c3f7f701ca9f47eebe3c251b49e953e946b9 /code/bot.py | |
parent | d447126db1196f7d55a982a2c23f795db8cf321b (diff) |
Delete Jellyfin accounts when needed
Jellyfin accounts never actually got deleted from Jellyfin, I forgot to write that part. So now the accounts are properly deleted from both Jellyfin and the DB.
Diffstat (limited to 'code/bot.py')
-rw-r--r-- | code/bot.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/code/bot.py b/code/bot.py index 4b3d96d..e8dc418 100644 --- a/code/bot.py +++ b/code/bot.py @@ -6,6 +6,7 @@ import sqlite3 import os from validate_config import create_config +from func.jellyfin import delete_jellyfin_account from global_variables import LOG, BOT_TOKEN @@ -35,16 +36,15 @@ async def on_ready(): @tasks.loop(seconds=60) async def delete_old_temp_accounts(): - # Delete all of the temporary Jellyfin accounts that have passed - # their expiration time + # Get all jellyfin user IDs that have passed their deletion time db = sqlite3.connect("cordarr.db") cursor = db.cursor() - cursor.execute( - "DELETE FROM jellyfin_accounts WHERE deletion_time < ?", - (datetime.datetime.now(),), - ) - db.commit() - db.close() + cursor.execute("SELECT jellyfin_user_id FROM jellyfin_accounts WHERE deletion_time < ?", (datetime.datetime.now(),)) + jellyfin_user_ids = cursor.fetchall() + + # Delete the Jellyfin accounts + for jellyfin_user_id in jellyfin_user_ids: + delete_jellyfin_account(jellyfin_user_id[0]) if __name__ == "__main__": |