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 13 additions and 12 deletions
Showing only changes of commit 4289c079c5 - Show all commits

View file

@ -6,23 +6,24 @@ import okhttp3.Headers
import okhttp3.OkHttpClient
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 java.util.regex.Pattern
class LuluExtractor(private val client: OkHttpClient) {
//Credit: https://github.com/skoruppa/docchi-stremio-addon/blob/main/app/players/lulustream.py
fun videosFromUrl(url: String, prefix: String, headers: Headers): List<Video> {
val luluHeaders = headers.newBuilder()
.add("Referer", "https://luluvdo.com")
.add("Origin", "https://luluvdo.com")
.build()
class LuluExtractor(private val client: OkHttpClient, headers: Headers) {
private val headers = headers.newBuilder()
.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
fun videosFromUrl(url: String, prefix: String): List<Video> {
val videos = mutableListOf<Video>()
try {
val html = client.newCall(GET(url, luluHeaders)).execute().use { it.body.string() }
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, luluHeaders)
val quality = getResolution(fixedUrl, headers)
videos.add(Video(fixedUrl, "${prefix}Lulu - $quality", fixedUrl, luluHeaders))
videos.add(Video(fixedUrl, "${prefix}Lulu - $quality", fixedUrl, headers))
} catch (e: Exception) {
e.printStackTrace()
}

View file

@ -137,7 +137,7 @@ class Docchi : ConfigurableAnimeSource, AnimeHttpSource() {
private val sibnetExtractor by lazy { SibnetExtractor(client) }
private val doodExtractor by lazy { DoodExtractor(client) }
private val lycorisExtractor by lazy { LycorisCafeExtractor(client) }
private val luluExtractor by lazy { LuluExtractor(client) }
private val luluExtractor by lazy { LuluExtractor(client, headers) }
private val googledriveExtractor by lazy { GoogleDriveExtractor(client, headers) }
override fun videoListParse(response: Response): List<Video> {
@ -203,7 +203,7 @@ class Docchi : ConfigurableAnimeSource, AnimeHttpSource() {
}
serverUrl.contains("luluvdo.com") -> {
luluExtractor.videosFromUrl(serverUrl, prefix, headers)
luluExtractor.videosFromUrl(serverUrl, prefix)
}
serverUrl.contains("drive.google.com") -> {