fix(lib/voe-extractor): Fix regex (#3183)
This commit is contained in:
parent
a4f9576f6b
commit
3bdc3f9e3a
@ -16,6 +16,10 @@ class VoeExtractor(private val client: OkHttpClient) {
|
|||||||
|
|
||||||
private val playlistUtils by lazy { PlaylistUtils(client) }
|
private val playlistUtils by lazy { PlaylistUtils(client) }
|
||||||
|
|
||||||
|
private val linkRegex = "(http|https)://([\\w_-]+(?:\\.[\\w_-]+)+)([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])".toRegex()
|
||||||
|
|
||||||
|
private val base64Regex = Regex("'.*'")
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class VideoLinkDTO(val file: String)
|
data class VideoLinkDTO(val file: String)
|
||||||
|
|
||||||
@ -27,11 +31,12 @@ class VoeExtractor(private val client: OkHttpClient) {
|
|||||||
val playlistUrl = when {
|
val playlistUrl = when {
|
||||||
// Layout 1
|
// Layout 1
|
||||||
script.contains("sources") -> {
|
script.contains("sources") -> {
|
||||||
script.substringAfter("hls': '").substringBefore("'")
|
val link = script.substringAfter("hls': '").substringBefore("'")
|
||||||
|
if (linkRegex.matches(link)) link else String(Base64.decode(link, Base64.DEFAULT))
|
||||||
}
|
}
|
||||||
// Layout 2
|
// Layout 2
|
||||||
script.contains("wc0") -> {
|
script.contains("wc0") -> {
|
||||||
val base64 = Regex("'.*'").find(script)!!.value
|
val base64 = base64Regex.find(script)!!.value
|
||||||
val decoded = Base64.decode(base64, Base64.DEFAULT).let(::String)
|
val decoded = Base64.decode(base64, Base64.DEFAULT).let(::String)
|
||||||
json.decodeFromString<VideoLinkDTO>(decoded).file
|
json.decodeFromString<VideoLinkDTO>(decoded).file
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user