FembedExtractor: Prevent cloudflare problems (#969)
Vizer: Remove unnecessary runCatching block
This commit is contained in:
@ -9,8 +9,9 @@ import okhttp3.OkHttpClient
|
||||
class FembedExtractor(private val client: OkHttpClient) {
|
||||
fun videosFromUrl(url: String, prefix: String = ""): List<Video> {
|
||||
val videoApi = url.replace("/v/", "/api/source/")
|
||||
val body = client.newCall(POST(videoApi)).execute()
|
||||
.body?.string().orEmpty()
|
||||
val body = runCatching {
|
||||
client.newCall(POST(videoApi)).execute().body?.string().orEmpty()
|
||||
}.getOrNull() ?: return emptyList<Video>()
|
||||
|
||||
val jsonResponse = Json { ignoreUnknownKeys = true }
|
||||
.decodeFromString<FembedResponse>(body)
|
||||
|
Reference in New Issue
Block a user