[skip ci] refactor(lib): Refactor some libraries (#2454)
This commit is contained in:
@ -15,19 +15,23 @@ class BurstCloudExtractor(private val client: OkHttpClient) {
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
fun videoFromUrl(url: String, headers: Headers, name: String = "BurstCloud", prefix: String = ""): List<Video> {
|
||||
|
||||
val newHeaders = headers.newBuilder().add("referer", "https://www.burstcloud.co/").build()
|
||||
val newHeaders = headers.newBuilder().set("referer", BURSTCLOUD_URL).build()
|
||||
return runCatching {
|
||||
val response = client.newCall(GET(url, headers = newHeaders)).execute()
|
||||
val document = response.asJsoup()
|
||||
val response = client.newCall(GET(url, newHeaders)).execute()
|
||||
val document = response.use { it.asJsoup() }
|
||||
val videoId = document.selectFirst("div#player")!!.attr("data-file-id")
|
||||
|
||||
val formBody = FormBody.Builder()
|
||||
.add("fileId", videoId)
|
||||
.build()
|
||||
val jsonHeaders = headers.newBuilder().add("referer", document.location()).build()
|
||||
val jsonString = client.newCall(POST("https://www.burstcloud.co/file/play-request/", jsonHeaders, formBody)).execute().body.string()
|
||||
|
||||
val jsonHeaders = headers.newBuilder().set("referer", document.location()).build()
|
||||
val request = POST("$BURSTCLOUD_URL/file/play-request/", jsonHeaders, formBody)
|
||||
val jsonString = client.newCall(request).execute().use { it.body.string() }
|
||||
|
||||
val jsonObj = json.decodeFromString<BurstCloudDto>(jsonString)
|
||||
val videoUrl = jsonObj.purchase.cdnUrl
|
||||
|
||||
if (videoUrl.isNotEmpty()) {
|
||||
val quality = prefix + name
|
||||
listOf(Video(videoUrl, quality, videoUrl, newHeaders))
|
||||
@ -35,6 +39,8 @@ class BurstCloudExtractor(private val client: OkHttpClient) {
|
||||
null
|
||||
}
|
||||
|
||||
}.getOrNull() ?: emptyList<Video>()
|
||||
}.getOrNull().orEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
private const val BURSTCLOUD_URL = "https://www.burstcloud.co"
|
||||
|
@ -3,11 +3,7 @@ package eu.kanade.tachiyomi.lib.burstcloudextractor
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class BurstCloudDto(
|
||||
val purchase: Purchase,
|
||||
)
|
||||
data class BurstCloudDto(val purchase: Purchase)
|
||||
|
||||
@Serializable
|
||||
data class Purchase(
|
||||
val cdnUrl: String,
|
||||
)
|
||||
data class Purchase(val cdnUrl: String)
|
||||
|
Reference in New Issue
Block a user