From 02629fe090a3585011f7cffae3071ec4151f09af Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 28 Jul 2023 15:51:33 +0700 Subject: [PATCH] wait for refresh to complete --- app/src/series.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/series.py b/app/src/series.py index 7fdc42c..1491053 100644 --- a/app/src/series.py +++ b/app/src/series.py @@ -30,6 +30,8 @@ class Library: def validate_series(self) -> None: """validate all series""" + collection_id: str = self._get_collection() + self.refresh_collection(collection_id) all_shows: list[JFShow] = self._get_all_series()["Items"] for show in all_shows: show_handler = Show(show) @@ -38,7 +40,6 @@ class Library: if folders: show_handler.delete_folders(folders) - collection_id: str = self._get_collection() self.set_collection_art(collection_id) self.refresh_collection(collection_id) @@ -71,6 +72,18 @@ class Library: path: str = f"Items/{collection_id}/Refresh?Recursive=true&ImageRefreshMode=Default&MetadataRefreshMode=Default" # noqa: E501 Jellyfin().post(path, False) + for _ in range(12): + response = Jellyfin().get("Library/VirtualFolders") + for folder in response: + if not folder["ItemId"] == collection_id: + continue + + if folder["RefreshStatus"] == "Idle": + return + + print("waiting for library refresh") + sleep(5) + class Show: """interact with a single show"""