fix(lib/lycoris&lulu) Repair decode json and work LuluStream #810
2 changed files with 14 additions and 11 deletions
|
@ -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
```suggestion
.add("Referer", "https://luluvdo.com/")
```
![]()
cuong-tran
commented
```suggestion
val quality = getResolution(fixedUrl)
```
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
![]() It's exact the same as the old headers, why need a new 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.
![]() 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. 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 :(
![]() Just change the 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() }
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue