fix(lib/lycoris): small changes v2
This commit is contained in:
parent
f2f3e26f5e
commit
47c3eb1972
1 changed files with 16 additions and 15 deletions
|
@ -4,6 +4,7 @@ import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
|
import eu.kanade.tachiyomi.util.parseAs
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
|
@ -35,24 +36,24 @@ class LycorisCafeExtractor(private val client: OkHttpClient) {
|
||||||
|
|
||||||
val script = document.select("script[type='application/json']").first()?.data().toString()
|
val script = document.select("script[type='application/json']").first()?.data().toString()
|
||||||
|
|
||||||
val scriptData = json.decodeFromString<ScriptBody>(script)
|
val scriptData = script.parseAs<ScriptBody>()
|
||||||
|
|
||||||
val data = json.decodeFromString<ScriptEpisode>(scriptData.body)
|
val data = scriptData.body.parseAs<ScriptEpisode>()
|
||||||
|
|
||||||
var linkList: String? = fetchAndDecodeVideo(client, data.episodeInfo.id.toString(), isSecondary = false).toString()
|
val linkList: String? = fetchAndDecodeVideo(client, data.episodeInfo.id.toString(), isSecondary = false)
|
||||||
|
|
||||||
val fhdLink = fetchAndDecodeVideo(client, data.episodeInfo.FHD.toString(), isSecondary = true).toString()
|
val fhdLink = fetchAndDecodeVideo(client, data.episodeInfo.FHD.toString(), isSecondary = true)
|
||||||
val sdLink = fetchAndDecodeVideo(client, data.episodeInfo.SD.toString(), isSecondary = true).toString()
|
val sdLink = fetchAndDecodeVideo(client, data.episodeInfo.SD.toString(), isSecondary = true)
|
||||||
val hdLink = fetchAndDecodeVideo(client, data.episodeInfo.HD.toString(), isSecondary = true).toString()
|
val hdLink = fetchAndDecodeVideo(client, data.episodeInfo.HD.toString(), isSecondary = true)
|
||||||
|
|
||||||
if (linkList.isNullOrBlank() || linkList == "{}") {
|
if (linkList.isNullOrBlank() || linkList == "{}") {
|
||||||
if (fhdLink.isNotEmpty()) {
|
if (!fhdLink.isNullOrBlank()) {
|
||||||
videos.add(Video(fhdLink, "${prefix}lycoris.cafe - 1080p", fhdLink))
|
videos.add(Video(fhdLink, "${prefix}lycoris.cafe - 1080p", fhdLink))
|
||||||
}
|
}
|
||||||
if (hdLink.isNotEmpty()) {
|
if (!hdLink.isNullOrBlank()) {
|
||||||
videos.add(Video(hdLink, "${prefix}lycoris.cafe - 720p", hdLink))
|
videos.add(Video(hdLink, "${prefix}lycoris.cafe - 720p", hdLink))
|
||||||
}
|
}
|
||||||
if (sdLink.isNotEmpty()) {
|
if (!sdLink.isNullOrBlank()) {
|
||||||
videos.add(Video(sdLink, "${prefix}lycoris.cafe - 480p", sdLink))
|
videos.add(Video(sdLink, "${prefix}lycoris.cafe - 480p", sdLink))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,19 +62,19 @@ class LycorisCafeExtractor(private val client: OkHttpClient) {
|
||||||
|
|
||||||
videoLinks.FHD?.takeIf { checkLinks(client, it) }?.let {
|
videoLinks.FHD?.takeIf { checkLinks(client, it) }?.let {
|
||||||
videos.add(Video(it, "${prefix}lycoris.cafe - 1080p", it))
|
videos.add(Video(it, "${prefix}lycoris.cafe - 1080p", it))
|
||||||
}?: fhdLink.takeIf { it.contains("https://") }?.let {
|
}?: fhdLink?.takeIf { it.contains("https://") }?.let {
|
||||||
videos.add(Video(it, "${prefix}lycoris.cafe - 1080p", it))
|
videos.add(Video(it, "${prefix}lycoris.cafe - 1080p", it))
|
||||||
}
|
}
|
||||||
|
|
||||||
videoLinks.HD?.takeIf { checkLinks(client, it) }?.let {
|
videoLinks.HD?.takeIf { checkLinks(client, it) }?.let {
|
||||||
videos.add(Video(it, "${prefix}lycoris.cafe - 720p", it))
|
videos.add(Video(it, "${prefix}lycoris.cafe - 720p", it))
|
||||||
}?: hdLink.takeIf { it.contains("https://") }?.let {
|
}?: hdLink?.takeIf { it.contains("https://") }?.let {
|
||||||
videos.add(Video(it, "${prefix}lycoris.cafe - 720p", it))
|
videos.add(Video(it, "${prefix}lycoris.cafe - 720p", it))
|
||||||
}
|
}
|
||||||
|
|
||||||
videoLinks.SD?.takeIf { checkLinks(client, it) }?.let {
|
videoLinks.SD?.takeIf { checkLinks(client, it) }?.let {
|
||||||
videos.add(Video(it, "${prefix}lycoris.cafe - 480p", it))
|
videos.add(Video(it, "${prefix}lycoris.cafe - 480p", it))
|
||||||
}?: sdLink.takeIf { it.contains("https://") }?.let {
|
}?: sdLink?.takeIf { it.contains("https://") }?.let {
|
||||||
videos.add(Video(it, "${prefix}lycoris.cafe - 480p", it))
|
videos.add(Video(it, "${prefix}lycoris.cafe - 480p", it))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ class LycorisCafeExtractor(private val client: OkHttpClient) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun decodeVideoLinks(encodedUrl: String?): Any? {
|
private fun decodeVideoLinks(encodedUrl: String?): String? {
|
||||||
if (encodedUrl.isNullOrEmpty()) {
|
if (encodedUrl.isNullOrEmpty()) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -106,7 +107,7 @@ class LycorisCafeExtractor(private val client: OkHttpClient) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchAndDecodeVideo(client: OkHttpClient, episodeId: String, isSecondary: Boolean = false): Any? {
|
private fun fetchAndDecodeVideo(client: OkHttpClient, episodeId: String, isSecondary: Boolean = false): String? {
|
||||||
val url: HttpUrl
|
val url: HttpUrl
|
||||||
|
|
||||||
if (isSecondary) {
|
if (isSecondary) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue