fix(src): Multiple updates (#157)

* fix(src): Multiple updates

Closes #93
Closes #1
Closes #133
Closes #142 (Yeah, this extension had a bug but someone closed it before fixing it.)

* Fix(lib/ChillxExtractor)

Closes #153
This commit is contained in:
imper1aldev 2024-08-19 11:12:51 -06:00 committed by GitHub
parent 9fbe135358
commit 112961d8de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
87 changed files with 682 additions and 78 deletions

View file

@ -22,6 +22,8 @@ class VoeExtractor(private val client: OkHttpClient) {
private val base64Regex = Regex("'.*'")
private val scriptBase64Regex = "(let|var)\\s+\\w+\\s*=\\s*'(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)';".toRegex()
@Serializable
data class VideoLinkDTO(val file: String)
@ -36,8 +38,9 @@ class VoeExtractor(private val client: OkHttpClient) {
document = clientDdos.newCall(GET(originalUrl)).execute().asJsoup()
}
val script = document.selectFirst("script:containsData(const sources), script:containsData(var sources), script:containsData(wc0)")
?.data()
val alternativeScript = document.select("script").find { scriptBase64Regex.containsMatchIn(it.data()) }?.data()
val script = document.selectFirst("script:containsData(const sources), script:containsData(var sources), script:containsData(wc0)")?.data()
?: alternativeScript
?: return emptyList()
val playlistUrl = when {
// Layout 1
@ -46,10 +49,11 @@ class VoeExtractor(private val client: OkHttpClient) {
if (linkRegex.matches(link)) link else String(Base64.decode(link, Base64.DEFAULT))
}
// Layout 2
script.contains("wc0") -> {
script.contains("wc0") || alternativeScript != null -> {
val base64 = base64Regex.find(script)!!.value
val decoded = Base64.decode(base64, Base64.DEFAULT).let(::String)
json.decodeFromString<VideoLinkDTO>(decoded).file
json.decodeFromString<VideoLinkDTO>(if (alternativeScript != null) decoded.reversed() else decoded).file
}
else -> return emptyList()
}