allow to choose a list by UUID

This commit is contained in:
Lysann Tranvouez 2025-07-21 21:15:28 +00:00
parent 4a6d2ff96d
commit 1838e35b78
4 changed files with 81 additions and 4 deletions

12
main.py
View file

@ -47,6 +47,7 @@ class BringPlugin:
def __init__(self):
self.email = os.getenv("EMAIL")
self.password = os.getenv("PASSWORD")
self.list_uuid = os.getenv("LIST_UUID")
self.webhook_url = os.getenv("WEBHOOK_URL")
self.bring = None
self.existing_list = None
@ -95,7 +96,16 @@ class BringPlugin:
if self.existing_list:
new_list = copy.deepcopy(self.existing_list)
else:
bring_api_list = (await self.bring.load_lists()).lists[0]
all_api_lists = (await self.bring.load_lists()).lists
if self.list_uuid is None:
if len(all_api_lists) > 1:
print(f"LIST_UUID not specified, will use first list.")
bring_api_list = all_api_lists[0]
else:
bring_api_list = next((l for l in all_api_lists if l.listUuid == self.list_uuid), None)
if bring_api_list is None:
print(f"No list with UUID \"{self.list_uuid}\" found, will use first list instead.")
bring_api_list = all_api_lists[0]
new_list = BringList(name=bring_api_list.name, uuid=bring_api_list.listUuid)
await self.grab_items(new_list)