snowfield/packages/flaresolverr/chromedriver_path.patch

54 lines
2.2 KiB
Diff

diff --git a/src/utils.py b/src/utils.py
index 79cf6f6..fef4a68 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -154,47 +154,8 @@ def get_webdriver(proxy: dict = None) -> WebDriver:
else:
start_xvfb_display()
- # if we are inside the Docker container, we avoid downloading the driver
- driver_exe_path = None
- version_main = None
- if os.path.exists("/app/chromedriver"):
- # running inside Docker
- driver_exe_path = "/app/chromedriver"
- else:
- version_main = get_chrome_major_version()
- # Fix for Chrome 115
- # https://github.com/seleniumbase/SeleniumBase/pull/1967
- if int(version_main) > 114:
- version_main = 114
- if PATCHED_DRIVER_PATH is not None:
- driver_exe_path = PATCHED_DRIVER_PATH
-
- # detect chrome path
- browser_executable_path = get_chrome_exe_path()
-
- # downloads and patches the chromedriver
- # if we don't set driver_executable_path it downloads, patches, and deletes the driver each time
- driver = uc.Chrome(options=options, browser_executable_path=browser_executable_path,
- driver_executable_path=driver_exe_path, version_main=version_main,
- windows_headless=windows_headless, headless=windows_headless)
-
- # save the patched driver to avoid re-downloads
- if driver_exe_path is None:
- PATCHED_DRIVER_PATH = os.path.join(driver.patcher.data_path, driver.patcher.exe_name)
- if PATCHED_DRIVER_PATH != driver.patcher.executable_path:
- shutil.copy(driver.patcher.executable_path, PATCHED_DRIVER_PATH)
-
- # clean up proxy extension directory
- if proxy_extension_dir is not None:
- shutil.rmtree(proxy_extension_dir)
-
- # selenium vanilla
- # options = webdriver.ChromeOptions()
- # options.add_argument('--no-sandbox')
- # options.add_argument('--window-size=1920,1080')
- # options.add_argument('--disable-setuid-sandbox')
- # options.add_argument('--disable-dev-shm-usage')
- # driver = webdriver.Chrome(options=options)
+ driver = uc.Chrome(options=options, driver_executable_path="@chromedriver_path@",
+ windows_headless=windows_headless)
return driver