Skip to content

Commit

Permalink
Update JkanimeExtractor.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
imper1aldev committed Apr 12, 2024
1 parent a809806 commit cec8a11
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.util.asJsoup
import eu.kanade.tachiyomi.util.parseAs
import kotlinx.serialization.Serializable
import okhttp3.Headers
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject

class JkanimeExtractor(
private val client: OkHttpClient,
Expand All @@ -26,7 +27,7 @@ class JkanimeExtractor(

val nozomiBody = "v=$postKey".toRequestBody("application/x-www-form-urlencoded".toMediaTypeOrNull())
val nozomiResponse = client.newCall(POST("https://jkanime.net/gsplay/api.php", body = nozomiBody)).execute()
val nozomiUrl = JSONObject(nozomiResponse.body.string()).getString("file").ifBlank { return emptyList() }
val nozomiUrl = nozomiResponse.body.string().parseAs<NozomiResponse>().file ?: return emptyList()

return listOf(Video(nozomiUrl, "${prefix}Nozomi", nozomiUrl))
}
Expand Down Expand Up @@ -59,4 +60,7 @@ class JkanimeExtractor(

return listOf(Video(streamUrl, "${prefix}Desuka", streamUrl))
}

@Serializable
data class NozomiResponse(val file: String? = null)
}

0 comments on commit cec8a11

Please sign in to comment.