fix(lib/lycoris&lulu) Repair decode json and work LuluStream #810

Merged
Hayanek merged 14 commits from fix-lycoris into main 2025-04-06 13:41:23 -05:00
2 changed files with 14 additions and 11 deletions
Showing only changes of commit 9f910735b2 - Show all commits

View file

@ -3,14 +3,15 @@ package eu.kanade.tachiyomi.lib.luluextractor
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.network.GET
import okhttp3.Headers
cuong-tran commented 2025-04-02 11:49:07 -05:00 (Migrated from github.com)
        .add("Referer", "https://luluvdo.com/")
```suggestion .add("Referer", "https://luluvdo.com/") ```
cuong-tran commented 2025-04-02 11:50:18 -05:00 (Migrated from github.com)
            val quality = getResolution(fixedUrl)
```suggestion val quality = getResolution(fixedUrl) ```
import okhttp3.HttpUrl.Companion.toHttpUrl
cuong-tran commented 2025-03-25 21:55:14 -05:00 (Migrated from github.com)

It's exact the same as the old headers, why need a new one?
Also, where it was, outside, is better. Same as the Regex one.

It's exact the same as the old headers, why need a new one? Also, where it was, outside, is better. Same as the Regex one.
Hayanek commented 2025-03-25 22:36:05 -05:00 (Migrated from github.com)

Well, not entirely the same if the current one has a user-agent from the application and the previous form relied solely on these 2 headers.
I don't understand which Regex you mean :(

Well, not entirely the same if the current one has a user-agent from the application and the previous form relied solely on these 2 headers. I don't understand which Regex you mean :(
cuong-tran commented 2025-03-26 03:35:20 -05:00 (Migrated from github.com)

Just change the Headers.Builder() to headers.Builder() then. Keep it outside like you did with the wordRegex previously.
if you meant creating a header based on parameter headers passed in to the function, find where the actual function called and restructure it so the original caller should pass the existed lulu one.

Just change the `Headers.Builder()` to `headers.Builder()` then. Keep it outside like you did with the wordRegex previously. if you meant creating a header based on parameter `headers` passed in to the function, find where the actual function called and restructure it so the original caller should pass the existed lulu one.
import okhttp3.OkHttpClient
import java.util.regex.Pattern
class LuluExtractor(private val client: OkHttpClient, headers: Headers) {
private val headers = headers.newBuilder()
.add("Referer", "https://luluvdo.com")
.add("Origin", "https://luluvdo.com")
.add("Referer", "https://luluvdo.com/")
.add("Origin", "https://luluvdo.com/")
.build()
//Credit: https://github.com/skoruppa/docchi-stremio-addon/blob/main/app/players/lulustream.py
@ -21,7 +22,7 @@ class LuluExtractor(private val client: OkHttpClient, headers: Headers) {
val html = client.newCall(GET(url, headers)).execute().use { it.body.string() }
val m3u8Url = extractM3u8Url(html) ?: return emptyList()
val fixedUrl = fixM3u8Link(m3u8Url)
val quality = getResolution(fixedUrl, headers)
val quality = getResolution(fixedUrl)
videos.add(Video(fixedUrl, "${prefix}Lulu - $quality", fixedUrl, headers))
} catch (e: Exception) {
@ -77,16 +78,18 @@ class LuluExtractor(private val client: OkHttpClient, headers: Headers) {
val baseUrl = link.split("?")[0]
val fixedLink = StringBuilder(baseUrl)
val orderedParams = paramOrder.filter { paramDict.containsKey(it) }.map { "$it=${paramDict[it]}" }
val fixedLink = baseUrl.toHttpUrl().newBuilder()
paramOrder.filter { paramDict.containsKey(it) }.forEach { key ->
fixedLink.addQueryParameter(key, paramDict[key])
}
extraParams.forEach { (key, value) ->
fixedLink.addQueryParameter(key, value)
}
fixedLink.append("?").append(orderedParams.joinToString("&"))
fixedLink.append("&").append(extraParams.entries.joinToString("&") { "${it.key}=${it.value}" })
return fixedLink.toString()
return fixedLink.build().toString()
}
private fun getResolution(m3u8Url: String, headers: Headers): String {
private fun getResolution(m3u8Url: String): String {
return try {
val content = client.newCall(GET(m3u8Url, headers)).execute()
.use { it.body.string() }

View file

@ -278,7 +278,7 @@ class Docchi : ConfigurableAnimeSource, AnimeHttpSource() {
val genres: List<String>,
val broadcast_day: String?,
val aired_from: String?,
val episodes: Int,
val episodes: Int?,
val season: String,
val season_year: Int,
val series_type: String,