fix(lib/lycoris&lulu&docchi): small change v4
This commit is contained in:
parent
4289c079c5
commit
9f910735b2
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.animesource.model.Video
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class LuluExtractor(private val client: OkHttpClient, headers: Headers) {
|
class LuluExtractor(private val client: OkHttpClient, headers: Headers) {
|
||||||
|
|
||||||
private val headers = headers.newBuilder()
|
private val headers = headers.newBuilder()
|
||||||
.add("Referer", "https://luluvdo.com")
|
.add("Referer", "https://luluvdo.com/")
|
||||||
.add("Origin", "https://luluvdo.com")
|
.add("Origin", "https://luluvdo.com/")
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
//Credit: https://github.com/skoruppa/docchi-stremio-addon/blob/main/app/players/lulustream.py
|
//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 html = client.newCall(GET(url, headers)).execute().use { it.body.string() }
|
||||||
val m3u8Url = extractM3u8Url(html) ?: return emptyList()
|
val m3u8Url = extractM3u8Url(html) ?: return emptyList()
|
||||||
val fixedUrl = fixM3u8Link(m3u8Url)
|
val fixedUrl = fixM3u8Link(m3u8Url)
|
||||||
val quality = getResolution(fixedUrl, headers)
|
val quality = getResolution(fixedUrl)
|
||||||
|
|
||||||
videos.add(Video(fixedUrl, "${prefix}Lulu - $quality", fixedUrl, headers))
|
videos.add(Video(fixedUrl, "${prefix}Lulu - $quality", fixedUrl, headers))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -77,16 +78,18 @@ class LuluExtractor(private val client: OkHttpClient, headers: Headers) {
|
||||||
|
|
||||||
val baseUrl = link.split("?")[0]
|
val baseUrl = link.split("?")[0]
|
||||||
|
|
||||||
val fixedLink = StringBuilder(baseUrl)
|
val fixedLink = baseUrl.toHttpUrl().newBuilder()
|
||||||
val orderedParams = paramOrder.filter { paramDict.containsKey(it) }.map { "$it=${paramDict[it]}" }
|
paramOrder.filter { paramDict.containsKey(it) }.forEach { key ->
|
||||||
|
fixedLink.addQueryParameter(key, paramDict[key])
|
||||||
fixedLink.append("?").append(orderedParams.joinToString("&"))
|
}
|
||||||
fixedLink.append("&").append(extraParams.entries.joinToString("&") { "${it.key}=${it.value}" })
|
extraParams.forEach { (key, value) ->
|
||||||
|
fixedLink.addQueryParameter(key, value)
|
||||||
return fixedLink.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getResolution(m3u8Url: String, headers: Headers): String {
|
return fixedLink.build().toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getResolution(m3u8Url: String): String {
|
||||||
return try {
|
return try {
|
||||||
val content = client.newCall(GET(m3u8Url, headers)).execute()
|
val content = client.newCall(GET(m3u8Url, headers)).execute()
|
||||||
.use { it.body.string() }
|
.use { it.body.string() }
|
||||||
|
|
|
@ -278,7 +278,7 @@ class Docchi : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||||
val genres: List<String>,
|
val genres: List<String>,
|
||||||
val broadcast_day: String?,
|
val broadcast_day: String?,
|
||||||
val aired_from: String?,
|
val aired_from: String?,
|
||||||
val episodes: Int,
|
val episodes: Int?,
|
||||||
val season: String,
|
val season: String,
|
||||||
val season_year: Int,
|
val season_year: Int,
|
||||||
val series_type: String,
|
val series_type: String,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue