This commit is contained in:
alex 2024-01-02 01:07:49 +07:00
parent 4643275ab4
commit 4c14b600e5
4 changed files with 26 additions and 68 deletions

View file

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

View file

@ -84,17 +84,13 @@ class Anilibria : MainAPI() {
val document = app.get(url).document val document = app.get(url).document
val title = document.selectFirst("h1.release-title")?.text() ?: return null val title = document.selectFirst("h1.release-title")?.text() ?: return null
val poster = fixUrlNull(document.selectFirst("img#adminPoster")?.attr("src")) val enTitle = (document.selectFirst("h1.release-title br")?.nextSibling()
val trackTitle = (document.selectFirst("h1.release-title br")?.nextSibling()
?: document.selectFirst("h1.release-title")?.text()?.substringAfter("/")?.trim()).toString() ?: document.selectFirst("h1.release-title")?.text()?.substringAfter("/")?.trim()).toString()
val poster = fixUrlNull(document.selectFirst("img#adminPoster")?.attr("src"))
val type = document.selectFirst("div#xreleaseInfo b:contains(Тип:)")?.nextSibling() val type = document.selectFirst("div#xreleaseInfo b:contains(Тип:)")?.nextSibling()
.toString().substringBefore(",").trim() .toString().substringBefore(",").trim()
val trackType = type.let {
if(it.contains("Фильм", true)) "movie" else "tv"
}
val year = document.selectFirst("div#xreleaseInfo b:contains(Сезон:)")?.nextElementSibling() val year = document.selectFirst("div#xreleaseInfo b:contains(Сезон:)")?.nextElementSibling()
?.text()?.filter { it.isDigit() }?.toIntOrNull() ?.text()?.filter { it.isDigit() }?.toIntOrNull()
val (malId, anilistId, image, cover) = getTracker(trackTitle, trackType, year)
val episodes = document.select("script").find { it.data().contains("var player =") }?.data() val episodes = document.select("script").find { it.data().contains("var player =") }?.data()
?.substringAfter("file:[")?.substringBefore("],")?.let { data -> ?.substringAfter("file:[")?.substringBefore("],")?.let { data ->
tryParseJson<List<Episodes>>("[$data]")?.mapNotNull { eps -> tryParseJson<List<Episodes>>("[$data]")?.mapNotNull { eps ->
@ -106,15 +102,14 @@ class Anilibria : MainAPI() {
} }
} }
return newAnimeLoadResponse(title, url, getType(type)) { return newAnimeLoadResponse(title, url, getType(type)) {
posterUrl = image ?: poster japName = enTitle
backgroundPosterUrl = cover ?: image ?: poster posterUrl = poster
backgroundPosterUrl = poster
this.year = year this.year = year
addEpisodes(DubStatus.Subbed, episodes) addEpisodes(DubStatus.Subbed, episodes)
plot = document.select("p.detail-description").text().trim() plot = document.select("p.detail-description").text().trim()
this.tags = document.selectFirst("div#xreleaseInfo b:contains(Жанры:)")?.nextSibling() this.tags = document.selectFirst("div#xreleaseInfo b:contains(Жанры:)")?.nextSibling()
.toString().split(",").map { it.trim() } .toString().split(",").map { it.trim() }
addMalId(malId)
addAniListId(anilistId?.toIntOrNull())
} }
} }
@ -143,43 +138,6 @@ class Anilibria : MainAPI() {
return true return true
} }
private suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker {
val res = app.get("https://consumet-instance.vercel.app/meta/anilist/$title")
.parsedSafe<AniSearch>()?.results?.find { media ->
(media.title?.english.equals(title, true) || media.title?.romaji.equals(
title,
true
)) || (media.type.equals(type, true) && media.releaseDate == year)
}
return Tracker(res?.malId, res?.aniId, res?.image, res?.cover)
}
data class Tracker(
val malId: Int? = null,
val aniId: String? = null,
val image: String? = null,
val cover: String? = null,
)
data class Title(
@JsonProperty("romaji") val romaji: String? = null,
@JsonProperty("english") val english: String? = null,
)
data class Results(
@JsonProperty("id") val aniId: String? = null,
@JsonProperty("malId") val malId: Int? = null,
@JsonProperty("title") val title: Title? = null,
@JsonProperty("releaseDate") val releaseDate: Int? = null,
@JsonProperty("type") val type: String? = null,
@JsonProperty("image") val image: String? = null,
@JsonProperty("cover") val cover: String? = null,
)
data class AniSearch(
@JsonProperty("results") val results: ArrayList<Results>? = arrayListOf(),
)
private data class Episodes( private data class Episodes(
@JsonProperty("file") val file: String? = null, @JsonProperty("file") val file: String? = null,
@JsonProperty("title") val title: String? = null, @JsonProperty("title") val title: String? = null,

View file

@ -365,16 +365,16 @@ open class SoraStream : TmdbProvider() {
val res = parseJson<LinkData>(data) val res = parseJson<LinkData>(data)
argamap( argamap(
{ // {
invokeFebbox( // invokeFebbox(
res.title, // res.title,
res.year, // res.year,
res.season, // res.season,
res.lastSeason, // res.lastSeason,
res.episode, // res.episode,
callback // callback
) // )
}, // },
{ {
invokeDumpStream( invokeDumpStream(
res.title, res.title,

View file

@ -52,16 +52,16 @@ class SoraStreamLite : SoraStream() {
val res = AppUtils.parseJson<LinkData>(data) val res = AppUtils.parseJson<LinkData>(data)
argamap( argamap(
{ // {
invokeFebbox( // invokeFebbox(
res.title, // res.title,
res.year, // res.year,
res.season, // res.season,
res.lastSeason, // res.lastSeason,
res.episode, // res.episode,
callback // callback
) // )
}, // },
{ {
if (!res.isAnime) invokeWatchsomuch( if (!res.isAnime) invokeWatchsomuch(
res.imdbId, res.imdbId,