mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -05:00
fix when playwright fails on providing a UA
This commit is contained in:
@@ -4,6 +4,7 @@ import com.microsoft.playwright.Browser
|
|||||||
import com.microsoft.playwright.BrowserType.LaunchOptions
|
import com.microsoft.playwright.BrowserType.LaunchOptions
|
||||||
import com.microsoft.playwright.Page
|
import com.microsoft.playwright.Page
|
||||||
import com.microsoft.playwright.Playwright
|
import com.microsoft.playwright.Playwright
|
||||||
|
import com.microsoft.playwright.PlaywrightException
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.network.interceptor.CFClearance.resolveWithWebView
|
import eu.kanade.tachiyomi.network.interceptor.CFClearance.resolveWithWebView
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
@@ -135,6 +136,7 @@ object CFClearance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getWebViewUserAgent(): String {
|
fun getWebViewUserAgent(): String {
|
||||||
|
return try {
|
||||||
Playwright.create().use { playwright ->
|
Playwright.create().use { playwright ->
|
||||||
playwright.chromium().launch(
|
playwright.chromium().launch(
|
||||||
LaunchOptions()
|
LaunchOptions()
|
||||||
@@ -147,6 +149,10 @@ object CFClearance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: PlaywrightException) {
|
||||||
|
// Playwright might fail on headless environments like docker
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCookies(page: Page, url: String): List<Cookie> {
|
private fun getCookies(page: Page, url: String): List<Cookie> {
|
||||||
|
|||||||
Reference in New Issue
Block a user