Skip to content

Commit

Permalink
### refactor(g4f/Provider/Blackbox.py): Optimize fetch_validated method
Browse files Browse the repository at this point in the history
  • Loading branch information
kqlio67 committed Nov 13, 2024
1 parent df08275 commit 054eef1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions g4f/Provider/Blackbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):

@classmethod
async def fetch_validated(cls):
# Якщо ключ вже збережений в пам'яті, повертаємо його
# If the key is already stored in memory, return it
if cls._last_validated_value:
return cls._last_validated_value

# Якщо ключ не знайдено, виконуємо пошук
# If the key is not found, perform a search
async with aiohttp.ClientSession() as session:
try:
async with session.get(cls.url) as response:
Expand All @@ -111,7 +111,7 @@ async def fetch_validated(cls):
match = key_pattern.search(js_content)
if match:
validated_value = match.group(1)
cls._last_validated_value = validated_value # Зберігаємо в пам'яті
cls._last_validated_value = validated_value # Keep in mind
return validated_value
except Exception as e:
print(f"Error fetching validated value: {e}")
Expand Down

0 comments on commit 054eef1

Please sign in to comment.