Update captcha configuration
(
self,
captcha_method: str = None,
yescaptcha_api_key: str = None,
yescaptcha_base_url: str = None,
yescaptcha_task_type: str = None,
capmonster_api_key: str = None,
capmonster_base_url: str = None,
ezcaptcha_api_key: str = None,
ezcaptcha_base_url: str = None,
capsolver_api_key: str = None,
capsolver_base_url: str = None,
remote_browser_base_url: str = None,
remote_browser_api_key: str = None,
remote_browser_timeout: int = None,
browser_proxy_enabled: bool = None,
browser_proxy_url: str = None,
browser_count: int = None,
personal_project_pool_size: int = None,
personal_max_resident_tabs: int = None,
browser_personal_fresh_restart_every_n_solves: int = None,
personal_idle_tab_ttl_seconds: int = None
)
| 1849 | return CaptchaConfig() |
| 1850 | |
| 1851 | async def update_captcha_config( |
| 1852 | self, |
| 1853 | captcha_method: str = None, |
| 1854 | yescaptcha_api_key: str = None, |
| 1855 | yescaptcha_base_url: str = None, |
| 1856 | yescaptcha_task_type: str = None, |
| 1857 | capmonster_api_key: str = None, |
| 1858 | capmonster_base_url: str = None, |
| 1859 | ezcaptcha_api_key: str = None, |
| 1860 | ezcaptcha_base_url: str = None, |
| 1861 | capsolver_api_key: str = None, |
| 1862 | capsolver_base_url: str = None, |
| 1863 | remote_browser_base_url: str = None, |
| 1864 | remote_browser_api_key: str = None, |
| 1865 | remote_browser_timeout: int = None, |
| 1866 | browser_proxy_enabled: bool = None, |
| 1867 | browser_proxy_url: str = None, |
| 1868 | browser_count: int = None, |
| 1869 | personal_project_pool_size: int = None, |
| 1870 | personal_max_resident_tabs: int = None, |
| 1871 | browser_personal_fresh_restart_every_n_solves: int = None, |
| 1872 | personal_idle_tab_ttl_seconds: int = None |
| 1873 | ): |
| 1874 | """Update captcha configuration""" |
| 1875 | async with self._connect(write=True) as db: |
| 1876 | db.row_factory = aiosqlite.Row |
| 1877 | cursor = await db.execute("SELECT * FROM captcha_config WHERE id = 1") |
| 1878 | row = await cursor.fetchone() |
| 1879 | |
| 1880 | if row: |
| 1881 | current = dict(row) |
| 1882 | new_method = captcha_method if captcha_method is not None else current.get("captcha_method", "yescaptcha") |
| 1883 | new_yes_key = yescaptcha_api_key if yescaptcha_api_key is not None else current.get("yescaptcha_api_key", "") |
| 1884 | new_yes_url = yescaptcha_base_url if yescaptcha_base_url is not None else current.get("yescaptcha_base_url", "https://api.yescaptcha.com") |
| 1885 | new_yes_task_type = normalize_yescaptcha_task_type( |
| 1886 | yescaptcha_task_type if yescaptcha_task_type is not None else current.get("yescaptcha_task_type") |
| 1887 | ) |
| 1888 | new_cap_key = capmonster_api_key if capmonster_api_key is not None else current.get("capmonster_api_key", "") |
| 1889 | new_cap_url = capmonster_base_url if capmonster_base_url is not None else current.get("capmonster_base_url", "https://api.capmonster.cloud") |
| 1890 | new_ez_key = ezcaptcha_api_key if ezcaptcha_api_key is not None else current.get("ezcaptcha_api_key", "") |
| 1891 | new_ez_url = ezcaptcha_base_url if ezcaptcha_base_url is not None else current.get("ezcaptcha_base_url", "https://api.ez-captcha.com") |
| 1892 | new_cs_key = capsolver_api_key if capsolver_api_key is not None else current.get("capsolver_api_key", "") |
| 1893 | new_cs_url = capsolver_base_url if capsolver_base_url is not None else current.get("capsolver_base_url", "https://api.capsolver.com") |
| 1894 | new_remote_base_url = remote_browser_base_url if remote_browser_base_url is not None else current.get("remote_browser_base_url", "") |
| 1895 | new_remote_api_key = remote_browser_api_key if remote_browser_api_key is not None else current.get("remote_browser_api_key", "") |
| 1896 | new_remote_timeout = remote_browser_timeout if remote_browser_timeout is not None else current.get("remote_browser_timeout", 60) |
| 1897 | new_proxy_enabled = browser_proxy_enabled if browser_proxy_enabled is not None else current.get("browser_proxy_enabled", False) |
| 1898 | new_proxy_url = browser_proxy_url if browser_proxy_url is not None else current.get("browser_proxy_url") |
| 1899 | new_browser_count = browser_count if browser_count is not None else current.get("browser_count", 1) |
| 1900 | new_personal_project_pool_size = personal_project_pool_size if personal_project_pool_size is not None else current.get("personal_project_pool_size", 4) |
| 1901 | new_personal_max_tabs = personal_max_resident_tabs if personal_max_resident_tabs is not None else current.get("personal_max_resident_tabs", 5) |
| 1902 | new_personal_fresh_restart_every = ( |
| 1903 | browser_personal_fresh_restart_every_n_solves |
| 1904 | if browser_personal_fresh_restart_every_n_solves is not None |
| 1905 | else current.get("browser_personal_fresh_restart_every_n_solves", 10) |
| 1906 | ) |
| 1907 | new_personal_idle_ttl = personal_idle_tab_ttl_seconds if personal_idle_tab_ttl_seconds is not None else current.get("personal_idle_tab_ttl_seconds", 600) |
| 1908 | new_remote_timeout = max(5, int(new_remote_timeout)) if new_remote_timeout is not None else 60 |
no test coverage detected