Anichi: fix trackers

This commit is contained in:
hexated 2023-06-30 12:51:14 +07:00
parent 55aa05ac5f
commit 9d1e0646e9
2 changed files with 28 additions and 10 deletions

View file

@ -1,7 +1,7 @@
import org.jetbrains.kotlin.konan.properties.Properties import org.jetbrains.kotlin.konan.properties.Properties
// use an integer for version numbers // use an integer for version numbers
version = 1 version = 2
android { android {
defaultConfig { defaultConfig {

View file

@ -2,7 +2,10 @@ package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.getTracker
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.extractors.helper.GogoHelper import com.lagradost.cloudstream3.extractors.helper.GogoHelper
import com.lagradost.cloudstream3.mvvm.safeApiCall import com.lagradost.cloudstream3.mvvm.safeApiCall
@ -28,6 +31,14 @@ class Anichi : MainAPI() {
} }
} }
private fun getType(t: String?): TvType {
return when {
t.equals("OVA", true) || t.equals("Special") -> TvType.OVA
t.equals("Movie", true) -> TvType.AnimeMovie
else -> TvType.Anime
}
}
override val supportedTypes = setOf(TvType.Anime, TvType.AnimeMovie) override val supportedTypes = setOf(TvType.Anime, TvType.AnimeMovie)
private val popularTitle = "Popular" private val popularTitle = "Popular"
@ -148,6 +159,7 @@ class Anichi : MainAPI() {
val title = showData.name val title = showData.name
val description = showData.description val description = showData.description
val poster = showData.thumbnail val poster = showData.thumbnail
val type = getType(showData.type ?: "")
val episodes = showData.availableEpisodes.let { val episodes = showData.availableEpisodes.let {
if (it == null) return@let Pair(null, null) if (it == null) return@let Pair(null, null)
@ -176,9 +188,13 @@ class Anichi : MainAPI() {
Pair(Actor(name, image), role) Pair(Actor(name, image), role)
} }
return newAnimeLoadResponse(title ?: "", url, TvType.Anime) { val names = showData.altNames?.plus(title)?.filterNotNull() ?: emptyList()
posterUrl = poster val trackers = getTracker(names, TrackerType.getTypes(type), showData.airedStart?.year)
backgroundPosterUrl = showData.banner
return newAnimeLoadResponse(title ?: "", url, type) {
engName = showData.altNames?.firstOrNull()
posterUrl = trackers?.image ?: poster
backgroundPosterUrl = trackers?.cover ?: showData.banner
rating = showData.averageScore?.times(100) rating = showData.averageScore?.times(100)
tags = showData.genres tags = showData.genres
year = showData.airedStart?.year year = showData.airedStart?.year
@ -192,7 +208,8 @@ class Anichi : MainAPI() {
//this.recommendations = recommendations //this.recommendations = recommendations
showStatus = getStatus(showData.status.toString()) showStatus = getStatus(showData.status.toString())
addMalId(trackers?.malId)
addAniListId(trackers?.aniId?.toIntOrNull())
plot = description?.replace(Regex("""<(.*?)>"""), "") plot = description?.replace(Regex("""<(.*?)>"""), "")
} }
} }
@ -215,10 +232,10 @@ class Anichi : MainAPI() {
val link = source.sourceUrl?.replace(" ", "%20") ?: return@safeApiCall val link = source.sourceUrl?.replace(" ", "%20") ?: return@safeApiCall
if (URI(link).isAbsolute || link.startsWith("//")) { if (URI(link).isAbsolute || link.startsWith("//")) {
val fixedLink = if (link.startsWith("//")) "https:$link" else link val fixedLink = if (link.startsWith("//")) "https:$link" else link
val host = URI(link).host.fixHost() val host = link.getHost()
when { when {
fixedLink.contains(Regex("(?i)playtaku|gogo")) -> { fixedLink.contains(Regex("(?i)playtaku|gogo")) || source.sourceName == "Vid-mp4" -> {
invokeGogo(fixedLink, subtitleCallback, callback) invokeGogo(fixedLink, subtitleCallback, callback)
} }
embedIsBlacklisted(fixedLink) -> { embedIsBlacklisted(fixedLink) -> {
@ -245,7 +262,7 @@ class Anichi : MainAPI() {
val links = app.get(fixedLink).parsedSafe<AnichiVideoApiResponse>()?.links val links = app.get(fixedLink).parsedSafe<AnichiVideoApiResponse>()?.links
?: emptyList() ?: emptyList()
links.forEach { server -> links.forEach { server ->
val host = server.link.fixHost() val host = server.link.getHost()
when { when {
source.sourceName == "Default" -> { source.sourceName == "Default" -> {
if (server.resolutionStr == "SUB" || server.resolutionStr == "Alt vo_SUB") { if (server.resolutionStr == "SUB" || server.resolutionStr == "Alt vo_SUB") {
@ -359,8 +376,8 @@ class Anichi : MainAPI() {
}) })
} }
private fun String.fixHost(): String { private fun String.getHost(): String {
return fixTitle(URI(this).host.substringBeforeLast(".").substringAfter(".")) return fixTitle(URI(this).host.substringBeforeLast(".").substringAfterLast("."))
} }
companion object { companion object {
@ -451,6 +468,7 @@ class Anichi : MainAPI() {
@JsonProperty("genres") val genres: List<String>?, @JsonProperty("genres") val genres: List<String>?,
@JsonProperty("averageScore") val averageScore: Int?, @JsonProperty("averageScore") val averageScore: Int?,
@JsonProperty("characters") val characters: List<Characters>?, @JsonProperty("characters") val characters: List<Characters>?,
@JsonProperty("altNames") val altNames: List<String>?,
@JsonProperty("description") val description: String?, @JsonProperty("description") val description: String?,
@JsonProperty("status") val status: String?, @JsonProperty("status") val status: String?,
@JsonProperty("banner") val banner: String?, @JsonProperty("banner") val banner: String?,