FembedExtractor: Prevent cloudflare problems (#969)

Vizer: Remove unnecessary runCatching block
This commit is contained in:
Claudemirovsky
2022-10-23 03:42:11 -03:00
committed by GitHub
parent 2d3190e174
commit df3d1a0e5b
2 changed files with 5 additions and 6 deletions

View File

@ -9,8 +9,9 @@ import okhttp3.OkHttpClient
class FembedExtractor(private val client: OkHttpClient) { class FembedExtractor(private val client: OkHttpClient) {
fun videosFromUrl(url: String, prefix: String = ""): List<Video> { fun videosFromUrl(url: String, prefix: String = ""): List<Video> {
val videoApi = url.replace("/v/", "/api/source/") val videoApi = url.replace("/v/", "/api/source/")
val body = client.newCall(POST(videoApi)).execute() val body = runCatching {
.body?.string().orEmpty() client.newCall(POST(videoApi)).execute().body?.string().orEmpty()
}.getOrNull() ?: return emptyList<Video>()
val jsonResponse = Json { ignoreUnknownKeys = true } val jsonResponse = Json { ignoreUnknownKeys = true }
.decodeFromString<FembedResponse>(body) .decodeFromString<FembedResponse>(body)

View File

@ -170,10 +170,8 @@ class Vizer : ConfigurableAnimeSource, AnimeHttpSource() {
StreamTapeExtractor(client) StreamTapeExtractor(client)
.videoFromUrl(url, "StreamTape($langPrefix)")?.let(::listOf) .videoFromUrl(url, "StreamTape($langPrefix)")?.let(::listOf)
name == "fembed" -> name == "fembed" ->
runCatching { FembedExtractor(client)
FembedExtractor(client) .videosFromUrl(url, langPrefix)
.videosFromUrl(url, langPrefix)
}.getOrNull()
else -> null else -> null
} }
}.flatten() }.flatten()