[test] added lib support in Kickassanime

This commit is contained in:
hexated 2023-02-02 21:19:45 +07:00
parent aa42180d4e
commit 15370e9c14
4 changed files with 40 additions and 3 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers
version = 7
version = 8
cloudstream {

View file

@ -10,6 +10,7 @@ import com.hexated.KickassanimeExtractor.invokeSapphire
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
import com.lagradost.cloudstream3.syncproviders.SyncIdName
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
@ -20,6 +21,11 @@ open class Kickassanime : MainAPI() {
override var lang = "en"
override val hasDownloadSupport = true
override val supportedSyncNames = setOf(
SyncIdName.MyAnimeList,
SyncIdName.Anilist
)
override val supportedTypes = setOf(
TvType.Anime,
TvType.AnimeMovie,
@ -28,6 +34,8 @@ open class Kickassanime : MainAPI() {
companion object {
const val kaast = "https://kaast1.com"
private const val consumetAnilist = "https://api.consumet.org/meta/anilist"
private const val consumetMal = "https://api.consumet.org/meta/mal"
fun getType(t: String): TvType {
return when {
t.contains("Ova", true) -> TvType.OVA
@ -87,6 +95,22 @@ open class Kickassanime : MainAPI() {
?: throw ErrorLoadingException()
}
override suspend fun getLoadUrl(name: SyncIdName, id: String): String {
val syncId = id.split("/").last()
val url = if (name == SyncIdName.Anilist) {
"$consumetAnilist/info/$syncId"
} else {
"$consumetMal/info/$syncId"
}
val res = app.get(url).parsedSafe<SyncInfo>()?.title
val romanjiUrl = "$mainUrl/anime/${res?.romaji?.createSlug()}"
val englishUrl = "$mainUrl/anime/${res?.english?.createSlug()}"
return if (app.get(romanjiUrl).url != "$mainUrl/") romanjiUrl else englishUrl
}
override suspend fun load(url: String): LoadResponse? {
val document = app.get(url).document
@ -199,7 +223,7 @@ open class Kickassanime : MainAPI() {
}
private suspend fun searchAnime(title: String?): ArrayList<Results>? {
return app.get("https://api.consumet.org/meta/anilist/$title")
return app.get("$consumetAnilist/$title")
.parsedSafe<AniSearch>()?.results
}
@ -327,4 +351,13 @@ open class Kickassanime : MainAPI() {
@JsonProperty("subtitles") val subtitles: ArrayList<SapphireSubtitles>? = arrayListOf(),
)
data class SyncTitle(
@JsonProperty("romaji") val romaji: String? = null,
@JsonProperty("english") val english: String? = null,
)
data class SyncInfo(
@JsonProperty("title") val title: SyncTitle? = null,
)
}

View file

@ -38,6 +38,10 @@ fun String.base64Decode(): String {
fun decode(input: String): String =
URLDecoder.decode(input, "utf-8").replace(" ", "%20")
fun String.createSlug(): String {
return this.replace(Regex("[^\\w ]+"), "").replace(" ", "-").lowercase()
}
fun String.getTrackerTitle(): String {
val blacklist = arrayOf(
"Dub",

View file

@ -66,7 +66,7 @@ open class SoraStream : TmdbProvider() {
const val gdbot = "https://gdbot.xyz"
const val consumetAnilistAPI = "https://api.consumet.org/meta/anilist"
const val kamyrollAPI = "https://api.kamyroll.tech"
var baymovies = "https://opengatewayindex.pages.dev"
const val baymovies = "https://opengatewayindex.pages.dev"
private val apiKey =
base64DecodeAPI("ZTM=NTg=MjM=MjM=ODc=MzI=OGQ=MmE=Nzk=Nzk=ZjI=NTA=NDY=NDA=MzA=YjA=") // PLEASE DON'T STEAL