Skip to content

Commit

Permalink
Fix(lib/ChillxExtractor): fix REGEX_SUBS
Browse files Browse the repository at this point in the history
  • Loading branch information
Dark25 committed Oct 6, 2024
1 parent 1f64f8d commit 9cf8e61
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.lib.chillxextractor

import android.util.Log
import eu.kanade.tachiyomi.animesource.model.Track
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.lib.cryptoaes.CryptoAES
Expand All @@ -23,13 +24,14 @@ class ChillxExtractor(private val client: OkHttpClient, private val headers: Hea
private val REGEX_SOURCES = Regex("""sources:\s*\[\{"file":"([^"]+)""")
private val REGEX_FILE = Regex("""file: ?"([^"]+)"""")
private val REGEX_SOURCE = Regex("""source = ?"([^"]+)"""")
private val REGEX_SUBS = Regex("""\[(.*?)\](https?://[^\s,]+)""")
private val REGEX_SUBS = Regex("""\{"file":"([^"]+)","label":"([^"]+)","kind":"captions","default":\w+\}""")
private const val KEY_SOURCE = "https://raw.githubusercontent.com/Rowdy-Avocado/multi-keys/keys/index.html"
}

fun videoFromUrl(url: String, referer: String, prefix: String = "Chillx - "): List<Video> {
val newHeaders = headers.newBuilder()
.set("Referer", "$referer/")
.set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
.set("Accept-Language", "en-US,en;q=0.5")
.build()

Expand All @@ -50,7 +52,8 @@ class ChillxExtractor(private val client: OkHttpClient, private val headers: Hea
val subtitleList = buildList {
val subtitles = REGEX_SUBS.findAll(decryptedScript)
subtitles.forEach {
add(Track(it.groupValues[2], decodeUnicodeEscape(it.groupValues[1])))
Log.d("ChillxExtractor", "Found subtitle: ${it.groupValues}")
add(Track(it.groupValues[1], decodeUnicodeEscape(it.groupValues[2])))
}
}

Expand Down Expand Up @@ -85,5 +88,4 @@ class ChillxExtractor(private val client: OkHttpClient, private val headers: Hea
@SerialName("chillx") val keys: List<String>
)
}

class ErrorLoadingException(message: String) : Exception(message)

0 comments on commit 9cf8e61

Please sign in to comment.