fix(fetchers): Add backward compatibility for custom_config argument

This commit is contained in:
Karim shoair
2025-11-26 02:23:17 +02:00
parent 9b3309f825
commit 0e1f3b9b05
2 changed files with 12 additions and 12 deletions
+6 -6
View File
@@ -52,12 +52,12 @@ class DynamicFetcher(BaseFetcher):
- additional_args: Additional arguments to be passed to Playwright's context as additional settings.
:return: A `Response` object.
"""
# Get selector_config from kwargs if provided, otherwise use empty dict
selector_config = kwargs.get("selector_config", {})
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
"custom_config", {}
) # Checking `custom_config` for backward compatibility
if not isinstance(selector_config, dict):
raise TypeError("Argument `selector_config` must be a dictionary.")
# Merge selector_config with class defaults
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
with DynamicSession(**kwargs) as session:
@@ -95,12 +95,12 @@ class DynamicFetcher(BaseFetcher):
- additional_args: Additional arguments to be passed to Playwright's context as additional settings.
:return: A `Response` object.
"""
# Get selector_config from kwargs if provided, otherwise use empty dict
selector_config = kwargs.get("selector_config", {})
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
"custom_config", {}
) # Checking `custom_config` for backward compatibility
if not isinstance(selector_config, dict):
raise TypeError("Argument `selector_config` must be a dictionary.")
# Merge selector_config with class defaults
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
async with AsyncDynamicSession(**kwargs) as session:
+6 -6
View File
@@ -45,12 +45,12 @@ class StealthyFetcher(BaseFetcher):
- additional_args: Additional arguments to be passed to Camoufox as additional settings.
:return: A `Response` object.
"""
# Get selector_config from kwargs if provided, otherwise use empty dict
selector_config = kwargs.get("selector_config", {})
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
"custom_config", {}
) # Checking `custom_config` for backward compatibility
if not isinstance(selector_config, dict):
raise TypeError("Argument `selector_config` must be a dictionary.")
# Merge selector_config with class defaults
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
with StealthySession(**kwargs) as engine:
@@ -90,12 +90,12 @@ class StealthyFetcher(BaseFetcher):
- additional_args: Additional arguments to be passed to Camoufox as additional settings.
:return: A `Response` object.
"""
# Get selector_config from kwargs if provided, otherwise use empty dict
selector_config = kwargs.get("selector_config", {})
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
"custom_config", {}
) # Checking `custom_config` for backward compatibility
if not isinstance(selector_config, dict):
raise TypeError("Argument `selector_config` must be a dictionary.")
# Merge selector_config with class defaults
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
async with AsyncStealthySession(**kwargs) as engine: