fix(lib/lycoris): small changes
This commit is contained in:
parent
eb6728a83b
commit
f2f3e26f5e
1 changed files with 7 additions and 6 deletions
|
@ -10,6 +10,7 @@ import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
class LycorisCafeExtractor(private val client: OkHttpClient) {
|
class LycorisCafeExtractor(private val client: OkHttpClient) {
|
||||||
|
@ -18,7 +19,7 @@ class LycorisCafeExtractor(private val client: OkHttpClient) {
|
||||||
|
|
||||||
private val GETLNKURL = "https://www.lycoris.cafe/api/watch/getLink"
|
private val GETLNKURL = "https://www.lycoris.cafe/api/watch/getLink"
|
||||||
|
|
||||||
private val json = Json { ignoreUnknownKeys = true }
|
private val json: Json by injectLazy()
|
||||||
|
|
||||||
// Credit: https://github.com/skoruppa/docchi-stremio-addon/blob/main/app/players/lycoris.py
|
// Credit: https://github.com/skoruppa/docchi-stremio-addon/blob/main/app/players/lycoris.py
|
||||||
fun getVideosFromUrl(url: String, headers: Headers, prefix: String): List<Video> {
|
fun getVideosFromUrl(url: String, headers: Headers, prefix: String): List<Video> {
|
||||||
|
@ -114,12 +115,12 @@ class LycorisCafeExtractor(private val client: OkHttpClient) {
|
||||||
val finalText = unicodeEscape.toByteArray(Charsets.ISO_8859_1).toString(Charsets.UTF_8)
|
val finalText = unicodeEscape.toByteArray(Charsets.ISO_8859_1).toString(Charsets.UTF_8)
|
||||||
|
|
||||||
url = GETLNKURL.toHttpUrl().newBuilder()
|
url = GETLNKURL.toHttpUrl().newBuilder()
|
||||||
?.addQueryParameter("link", finalText)
|
.addQueryParameter("link", finalText)
|
||||||
?.build() ?: throw IllegalStateException("Invalid URL")
|
.build()
|
||||||
} else {
|
} else {
|
||||||
url = GETSECONDARYURL.toHttpUrl().newBuilder()
|
url = GETSECONDARYURL.toHttpUrl().newBuilder()
|
||||||
?.addQueryParameter("id", episodeId)
|
.addQueryParameter("id", episodeId)
|
||||||
?.build() ?: throw IllegalStateException("Invalid URL")
|
.build()
|
||||||
}
|
}
|
||||||
client.newCall(GET(url))
|
client.newCall(GET(url))
|
||||||
.execute()
|
.execute()
|
||||||
|
@ -147,7 +148,7 @@ class LycorisCafeExtractor(private val client: OkHttpClient) {
|
||||||
"""\\u([0-9a-fA-F]{4})|""" + // \uXXXX
|
"""\\u([0-9a-fA-F]{4})|""" + // \uXXXX
|
||||||
"""\\x([0-9a-fA-F]{2})|""" + // \xHH
|
"""\\x([0-9a-fA-F]{2})|""" + // \xHH
|
||||||
"""\\([0-7]{1,3})|""" + // \OOO (octal)
|
"""\\([0-7]{1,3})|""" + // \OOO (octal)
|
||||||
"""\\([btnfr"'$\\\\])""" // \n, \t, itd.
|
"""\\([btnfr"'$\\])""" // \n, \t, itd.
|
||||||
)
|
)
|
||||||
|
|
||||||
return regex.replace(withoutLineContinuation) { match ->
|
return regex.replace(withoutLineContinuation) { match ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue