mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
added Anilibria
This commit is contained in:
parent
367e40d19e
commit
a868b28d4c
4 changed files with 182 additions and 0 deletions
27
Anilibria/build.gradle.kts
Normal file
27
Anilibria/build.gradle.kts
Normal file
|
@ -0,0 +1,27 @@
|
|||
// use an integer for version numbers
|
||||
version = 1
|
||||
|
||||
|
||||
cloudstream {
|
||||
language = "ru"
|
||||
// All of these properties are optional, you can safely remove them
|
||||
|
||||
// description = "Lorem Ipsum"
|
||||
authors = listOf("Hexated")
|
||||
|
||||
/**
|
||||
* Status int as the following:
|
||||
* 0: Down
|
||||
* 1: Ok
|
||||
* 2: Slow
|
||||
* 3: Beta only
|
||||
* */
|
||||
status = 1 // will be 3 if unspecified
|
||||
tvTypes = listOf(
|
||||
"AnimeMovie",
|
||||
"OVA",
|
||||
"Anime",
|
||||
)
|
||||
|
||||
iconUrl = "https://www.google.com/s2/favicons?domain=anilibria.tv&sz=%size%"
|
||||
}
|
2
Anilibria/src/main/AndroidManifest.xml
Normal file
2
Anilibria/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="com.hexated"/>
|
139
Anilibria/src/main/kotlin/com/hexated/Anilibria.kt
Normal file
139
Anilibria/src/main/kotlin/com/hexated/Anilibria.kt
Normal file
|
@ -0,0 +1,139 @@
|
|||
package com.hexated
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
|
||||
class Anilibria : MainAPI() {
|
||||
override var mainUrl = "https://anilibria.tv"
|
||||
override var name = "Anilibria"
|
||||
override val hasMainPage = true
|
||||
override var lang = "ru"
|
||||
override val hasDownloadSupport = true
|
||||
|
||||
override val supportedTypes = setOf(
|
||||
TvType.Anime,
|
||||
TvType.AnimeMovie,
|
||||
TvType.OVA
|
||||
)
|
||||
|
||||
override val mainPage = mainPageOf(
|
||||
"1" to "Новое",
|
||||
"2" to "Популярное",
|
||||
)
|
||||
|
||||
override suspend fun getMainPage(
|
||||
page: Int,
|
||||
request: MainPageRequest
|
||||
): HomePageResponse {
|
||||
val document = app.post(
|
||||
"$mainUrl/public/catalog.php", data = mapOf(
|
||||
"page" to "$page",
|
||||
"xpage" to "catalog",
|
||||
"sort" to request.data,
|
||||
"finish" to "1",
|
||||
"search" to "{\"year\":\"\",\"genre\":\"\",\"season\":\"\"}"
|
||||
), headers = mapOf("X-Requested-With" to "XMLHttpRequest")
|
||||
).parsedSafe<Home>()?.table?.let { Jsoup.parse(it) }
|
||||
val home = document?.select("a")?.mapNotNull {
|
||||
it.toSearchResult()
|
||||
} ?: throw ErrorLoadingException("Invalid json responses")
|
||||
return newHomePageResponse(request.name, home)
|
||||
}
|
||||
|
||||
private fun Element.toSearchResult(): AnimeSearchResponse? {
|
||||
val href = fixUrl(this.attr("href"))
|
||||
val title = this.selectFirst("span")?.text() ?: return null
|
||||
val posterUrl = fixUrlNull(this.selectFirst("img")?.attr("src"))
|
||||
|
||||
return newAnimeSearchResponse(title, href, TvType.Anime) {
|
||||
this.posterUrl = posterUrl
|
||||
addDubStatus(isDub = true)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun search(query: String): List<SearchResponse> {
|
||||
val document = app.post(
|
||||
"$mainUrl/public/search.php",
|
||||
data = mapOf("search" to query, "small" to "1"),
|
||||
headers = mapOf("X-Requested-With" to "XMLHttpRequest")
|
||||
).parsedSafe<Search>()?.mes?.let { Jsoup.parse(it) }
|
||||
|
||||
return document?.select("a")?.mapNotNull {
|
||||
it.toSearchResult()
|
||||
} ?: throw ErrorLoadingException("Invalid json responses")
|
||||
}
|
||||
|
||||
override suspend fun load(url: String): LoadResponse {
|
||||
val document = app.get(url).document
|
||||
|
||||
val title = document.selectFirst("h1.release-title")!!.text().trim()
|
||||
val episodes = document.select("script").find { it.data().contains("var player =") }?.data()
|
||||
?.substringAfter("file:[")?.substringBefore("],")?.let { data ->
|
||||
tryParseJson<List<Episodes>>("[$data]")?.mapNotNull { eps ->
|
||||
Episode(
|
||||
eps.file ?: return@mapNotNull null,
|
||||
name = eps.title ?: return@mapNotNull null,
|
||||
posterUrl = fixUrlNull(eps.poster),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return newAnimeLoadResponse(title, url, TvType.Anime) {
|
||||
posterUrl = fixUrlNull(document.selectFirst("img#adminPoster")?.attr("src"))
|
||||
this.year =
|
||||
document.selectFirst("div#xreleaseInfo b:contains(Сезон:)")?.nextElementSibling()
|
||||
?.text()?.filter { it.isDigit() }?.toIntOrNull()
|
||||
addEpisodes(DubStatus.Subbed, episodes)
|
||||
plot = document.select("p.detail-description").text().trim()
|
||||
this.tags = document.selectFirst("div#xreleaseInfo").toString().let { tag ->
|
||||
Regex("Жанры:</b>(.*\\n?.*)<br>").find(tag)?.groupValues?.getOrNull(1)?.split(",")
|
||||
?.map { it.trim() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun loadLinks(
|
||||
data: String,
|
||||
isCasting: Boolean,
|
||||
subtitleCallback: (SubtitleFile) -> Unit,
|
||||
callback: (ExtractorLink) -> Unit
|
||||
): Boolean {
|
||||
|
||||
data.split(",").map { it.trim() }.map { m3u ->
|
||||
val quality = Regex("\\[([0-9]+p)]").find(m3u)?.groupValues?.getOrNull(1)
|
||||
val link = m3u.removePrefix("[$quality]").trim()
|
||||
callback.invoke(
|
||||
ExtractorLink(
|
||||
this.name,
|
||||
this.name,
|
||||
link,
|
||||
"$mainUrl/",
|
||||
getQualityFromName(quality),
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private data class Episodes(
|
||||
@JsonProperty("file") val file: String? = null,
|
||||
@JsonProperty("title") val title: String? = null,
|
||||
@JsonProperty("poster") val poster: String? = null,
|
||||
)
|
||||
|
||||
private data class Home(
|
||||
@JsonProperty("table") val table: String? = null,
|
||||
)
|
||||
|
||||
private data class Search(
|
||||
@JsonProperty("mes") val mes: String? = null,
|
||||
)
|
||||
|
||||
}
|
14
Anilibria/src/main/kotlin/com/hexated/AnilibriaPlugin.kt
Normal file
14
Anilibria/src/main/kotlin/com/hexated/AnilibriaPlugin.kt
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
package com.hexated
|
||||
|
||||
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
|
||||
import com.lagradost.cloudstream3.plugins.Plugin
|
||||
import android.content.Context
|
||||
|
||||
@CloudstreamPlugin
|
||||
class AnilibriaPlugin: Plugin() {
|
||||
override fun load(context: Context) {
|
||||
// All providers should be added in this manner. Please don't edit the providers list directly.
|
||||
registerMainAPI(Anilibria())
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue