From a783515ad4fc5f54a27c97a2955679c6555a5839 Mon Sep 17 00:00:00 2001 From: Vitiko Date: Thu, 5 May 2022 14:16:30 -0400 Subject: [PATCH] Avoid NoneType on providers pool updates --- libs/subliminal_patch/core.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index 01778375d..c5f11f75c 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -105,10 +105,12 @@ class SZProviderPool(ProviderPool): # Check if the pool was initialized enough hours ago self._check_lifetime() + providers = set(providers or []) + # Check if any new provider has been added - updated = set(providers) != self.providers or ban_list != self.ban_list - removed_providers = list(sorted(self.providers - set(providers))) - new_providers = list(sorted(set(providers) - self.providers)) + updated = providers != self.providers or ban_list != self.ban_list + removed_providers = list(sorted(self.providers - providers)) + new_providers = list(sorted(providers - self.providers)) # Terminate and delete removed providers from instance for removed in removed_providers: @@ -128,8 +130,6 @@ class SZProviderPool(ProviderPool): self.providers.difference_update(removed_providers) self.providers.update(list(providers)) - self.blacklist = blacklist - # Restart providers with new configs for key, val in provider_configs.items(): # Don't restart providers that are not enabled @@ -154,6 +154,9 @@ class SZProviderPool(ProviderPool): self.provider_configs = provider_configs + self.blacklist = blacklist or [] + self.ban_list = ban_list or {'must_contain': [], 'must_not_contain': []} + return updated def _check_lifetime(self):