mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
fixed tracker in Kickassanime
This commit is contained in:
parent
f070b4c99a
commit
e34a635659
3 changed files with 32 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 6
|
version = 7
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -96,7 +96,7 @@ open class Kickassanime : MainAPI() {
|
||||||
} ?: throw ErrorLoadingException()
|
} ?: throw ErrorLoadingException()
|
||||||
|
|
||||||
val title = res.name ?: return null
|
val title = res.name ?: return null
|
||||||
val trackerTitle = res.en_title.orEmpty().ifEmpty { res.name }.fixTitle()
|
val trackerTitle = res.en_title.orEmpty().ifEmpty { res.name }.getTrackerTitle()
|
||||||
val poster = getImageUrl(res.image)
|
val poster = getImageUrl(res.image)
|
||||||
val tags = res.genres?.map { it.name ?: return null }
|
val tags = res.genres?.map { it.name ?: return null }
|
||||||
val year = res.startdate?.substringBefore("-")?.toIntOrNull()
|
val year = res.startdate?.substringBefore("-")?.toIntOrNull()
|
||||||
|
@ -111,12 +111,13 @@ open class Kickassanime : MainAPI() {
|
||||||
when (it) {
|
when (it) {
|
||||||
"TV Series" -> "tv"
|
"TV Series" -> "tv"
|
||||||
"Ova" -> "ova"
|
"Ova" -> "ova"
|
||||||
|
"ONA" -> "ona"
|
||||||
"Movie" -> "movie"
|
"Movie" -> "movie"
|
||||||
else -> "tv"
|
else -> "tv"
|
||||||
}
|
}
|
||||||
} ?: if (episodes.size == 1) "movie" else "tv"
|
} ?: if (episodes.size == 1) "movie" else "tv"
|
||||||
|
|
||||||
val (malId, anilistId, image, cover) = getTracker(trackerTitle, type, year)
|
val (malId, anilistId, image, cover) = getTracker(trackerTitle, title.getTrackerTitle(), type, year)
|
||||||
|
|
||||||
return newAnimeLoadResponse(title, url, getType(type)) {
|
return newAnimeLoadResponse(title, url, getType(type)) {
|
||||||
engName = title
|
engName = title
|
||||||
|
@ -181,15 +182,25 @@ open class Kickassanime : MainAPI() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker {
|
private suspend fun getTracker(
|
||||||
val res = app.get("https://api.consumet.org/meta/anilist/$title")
|
title: String?,
|
||||||
.parsedSafe<AniSearch>()?.results?.find { media ->
|
romajiTitle: String?,
|
||||||
(media.title?.english.equals(title, true) || media.title?.romaji.equals(
|
type: String?,
|
||||||
title,
|
year: Int?
|
||||||
true
|
): Tracker {
|
||||||
)) || (media.type.equals(type, true) && media.releaseDate == year)
|
val res = searchAnime(title).orEmpty().ifEmpty { searchAnime(romajiTitle) }
|
||||||
}
|
val media = res?.find { media ->
|
||||||
return Tracker(res?.malId, res?.aniId, res?.image, res?.cover)
|
(media.title?.english.equals(title, true) || media.title?.romaji.equals(
|
||||||
|
title,
|
||||||
|
true
|
||||||
|
)) || (media.type.equals(type, true) && media.releaseDate == year)
|
||||||
|
}
|
||||||
|
return Tracker(media?.malId, media?.aniId, media?.image, media?.cover)
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun searchAnime(title: String?): ArrayList<Results>? {
|
||||||
|
return app.get("https://api.consumet.org/meta/anilist/$title")
|
||||||
|
.parsedSafe<AniSearch>()?.results
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Tracker(
|
data class Tracker(
|
||||||
|
|
|
@ -38,8 +38,15 @@ fun String.base64Decode(): String {
|
||||||
fun decode(input: String): String =
|
fun decode(input: String): String =
|
||||||
URLDecoder.decode(input, "utf-8").replace(" ", "%20")
|
URLDecoder.decode(input, "utf-8").replace(" ", "%20")
|
||||||
|
|
||||||
fun String.fixTitle(): String {
|
fun String.getTrackerTitle(): String {
|
||||||
return this.replace("(Dub)", "").replace("(Uncensored)", "").trim()
|
val blacklist = arrayOf(
|
||||||
|
"Dub",
|
||||||
|
"Uncensored",
|
||||||
|
"TV",
|
||||||
|
"JPN DUB",
|
||||||
|
"Uncensored"
|
||||||
|
).joinToString("|") { "\\($it\\)" }
|
||||||
|
return this.replace(Regex(blacklist), "").trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getImageUrl(link: String?): String? {
|
fun getImageUrl(link: String?): String? {
|
||||||
|
|
Loading…
Reference in a new issue