fix(pt/pobreflix): Fix corner case in extractor (#2134)

This commit is contained in:
Claudemirovsky
2023-09-03 07:46:10 -03:00
committed by GitHub
parent 4dcb0ec9da
commit 5c90af8709
2 changed files with 46 additions and 17 deletions

View File

@ -11,30 +11,59 @@ import okhttp3.OkHttpClient
class PainelfxExtractor(private val client: OkHttpClient) { class PainelfxExtractor(private val client: OkHttpClient) {
fun videosFromUrl(url: String, headers: Headers): List<Video> { fun videosFromUrl(url: String, headers: Headers): List<Video> {
val doc = client.newCall(GET(url)).execute().asJsoup() val docHeaders = headers.newBuilder().set("Referer", "https://gastronomiabrasileira.net/").build()
val doc = client.newCall(GET(url, docHeaders)).execute().use { it.asJsoup() }
val lang = when (url.substringAfterLast("/")) { val lang = when (url.substringAfterLast("/")) {
"leg" -> "Legendado" "leg" -> "Legendado"
else -> "Dublado" else -> "Dublado"
} }
return doc.select("div.panel-body > button").flatMap { elem ->
val host = url.toHttpUrl().host
val videoHeaders = headers.newBuilder().set("Referer", "https://$host/").build()
val buttons = doc.select("div.panel-body > button")
val encodedHexList = when {
buttons.isNotEmpty() -> {
buttons.map { elem ->
val form = FormBody.Builder() val form = FormBody.Builder()
.add("idS", elem.attr("idS")) .add("idS", elem.attr("idS"))
.build() .build()
val host = url.toHttpUrl().host client.newCall(POST("https://$host/CallEpi", body = form)).execute()
val newHeaders = headers.newBuilder().set("Referer", "https://$host/").build() .use { it.body.string() }
val req = client.newCall(POST("https://$host/CallEpi", body = form)).execute() }
val decoded = req.body.string().decodeHex().let(::String).replace("\\", "") }
if (decoded.contains("video\"")) { else -> {
val script = doc.selectFirst("script:containsData(idS:)")?.data() ?: return emptyList()
val idList = script.split("idS:").drop(1).map { it.substringAfter('"').substringBefore('"') }
idList.map { idS ->
val form = FormBody.Builder()
.add("id", idS)
.build()
client.newCall(POST("https://$host/CallPlayer", body = form)).execute()
.use { it.body.string() }
}
}
}
return encodedHexList.flatMap {
videosFromHex(it, lang, videoHeaders)
}
}
private fun videosFromHex(hex: String, lang: String, videoHeaders: Headers): List<Video> {
val decoded = hex.decodeHex().let(::String).replace("\\", "")
return if (decoded.contains("video\"")) {
decoded.substringAfter("video").split("{").drop(1).map { decoded.substringAfter("video").split("{").drop(1).map {
val videoUrl = it.substringAfter("file\":\"").substringBefore('"') val videoUrl = it.substringAfter("file\":\"").substringBefore('"')
val quality = it.substringAfter("label\":\"").substringBefore('"') val quality = it.substringAfter("label\":\"").substringBefore('"')
Video(videoUrl, "$lang - $quality", videoUrl, newHeaders) Video(videoUrl, "$lang - $quality", videoUrl, videoHeaders)
} }
} else { } else {
emptyList() emptyList()
} }
} }
}
// Stolen from AnimixPlay(EN) / GogoCdnExtractor // Stolen from AnimixPlay(EN) / GogoCdnExtractor
private fun String.decodeHex(): ByteArray { private fun String.decodeHex(): ByteArray {

View File

@ -27,7 +27,7 @@ class DooPlayGenerator : ThemeSourceGenerator {
SingleLang("Multimovies", "https://multimovies.shop", "en", isNsfw = false, overrideVersionCode = 9), SingleLang("Multimovies", "https://multimovies.shop", "en", isNsfw = false, overrideVersionCode = 9),
SingleLang("pactedanime", "https://pactedanime.com", "en", isNsfw = false, className = "PactedAnime", overrideVersionCode = 4), SingleLang("pactedanime", "https://pactedanime.com", "en", isNsfw = false, className = "PactedAnime", overrideVersionCode = 4),
SingleLang("Pi Fansubs", "https://pifansubs.org", "pt-BR", isNsfw = true, overrideVersionCode = 17), SingleLang("Pi Fansubs", "https://pifansubs.org", "pt-BR", isNsfw = true, overrideVersionCode = 17),
SingleLang("Pobreflix", "https://pobreflix.biz", "pt-BR", isNsfw = true), SingleLang("Pobreflix", "https://pobreflix.biz", "pt-BR", isNsfw = true, overrideVersionCode = 1),
SingleLang("UniqueStream", "https://uniquestream.net", "en", isNsfw = false, overrideVersionCode = 2), SingleLang("UniqueStream", "https://uniquestream.net", "en", isNsfw = false, overrideVersionCode = 2),
) )