Animasu: added new server

This commit is contained in:
jack 2023-11-29 05:44:01 +07:00
parent 7dcaa2459d
commit fc542ae39e
5 changed files with 124 additions and 4 deletions

View file

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

View file

@ -10,5 +10,7 @@ class AnimasuPlugin: Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(Animasu())
registerExtractorAPI(Archivd())
registerExtractorAPI(Newuservideo())
}
}

View file

@ -0,0 +1,102 @@
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.INFER_TYPE
import com.lagradost.cloudstream3.utils.Qualities
class Archivd : ExtractorApi() {
override val name: String = "Archivd"
override val mainUrl: String = "https://archivd.net"
override val requiresReferer = true
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val res = app.get(url).document
val json = res.select("div#app").attr("data-page")
val video = AppUtils.tryParseJson<Sources>(json)?.props?.datas?.data?.link?.media
callback.invoke(
ExtractorLink(
this.name,
this.name,
video ?: return,
"$mainUrl/",
Qualities.Unknown.value,
INFER_TYPE
)
)
}
data class Link(
@JsonProperty("media") val media: String? = null,
)
data class Data(
@JsonProperty("link") val link: Link? = null,
)
data class Datas(
@JsonProperty("data") val data: Data? = null,
)
data class Props(
@JsonProperty("datas") val datas: Datas? = null,
)
data class Sources(
@JsonProperty("props") val props: Props? = null,
)
}
class Newuservideo : ExtractorApi() {
override val name: String = "Uservideo"
override val mainUrl: String = "https://new.uservideo.xyz"
override val requiresReferer = true
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val iframe = app.get(url,referer=referer).document.select("iframe#videoFrame").attr("src")
val doc = app.get(iframe,referer="$mainUrl/").text
val json = "VIDEO_CONFIG\\s?=\\s?(.*)".toRegex().find(doc)?.groupValues?.get(1)
AppUtils.tryParseJson<Sources>(json)?.streams?.map {
callback.invoke(
ExtractorLink(
this.name,
this.name,
it.playUrl ?: return@map,
"$mainUrl/",
when (it.formatId) {
18 -> Qualities.P360.value
22 -> Qualities.P720.value
else -> Qualities.Unknown.value
},
INFER_TYPE
)
)
}
}
data class Streams(
@JsonProperty("play_url") val playUrl: String? = null,
@JsonProperty("format_id") val formatId: Int? = null,
)
data class Sources(
@JsonProperty("streams") val streams: ArrayList<Streams>? = null,
)
}

View file

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

View file

@ -3,9 +3,11 @@ package com.hexated
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
import com.lagradost.cloudstream3.network.WebViewResolver
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.loadExtractor
import com.lagradost.nicehttp.requestCreator
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
@ -16,6 +18,7 @@ class KuramanimeProvider : MainAPI() {
override val hasMainPage = true
override var lang = "id"
override val hasDownloadSupport = true
private var auth: String? = null
private var headers: Map<String,String> = mapOf()
private var cookies: Map<String,String> = mapOf()
override val supportedTypes = setOf(
@ -199,7 +202,7 @@ class KuramanimeProvider : MainAPI() {
val token = res.select("meta[name=csrf-token]").attr("content")
headers = mapOf(
"Accept" to "application/json, text/javascript, */*; q=0.01",
"Authorization" to "Bearer ${getAuth()}",
"Authorization" to "${getAuth(data)}",
"X-Requested-With" to "XMLHttpRequest",
"X-CSRF-TOKEN" to token
)
@ -225,10 +228,23 @@ class KuramanimeProvider : MainAPI() {
}
private fun getAuth() : String {
val key = "kuramanime2:LEcXGYdOGcMCV8jM5fhRdM2mneSj6kaNts:${APIHolder.unixTimeMS};"
val key = "kuramanime3:LEcXGYdOGcMCV8jM5fhRdM2mneSj6kaNts:${APIHolder.unixTimeMS};"
return base64Encode(base64Encode(key.toByteArray()).toByteArray())
}
private suspend fun fetchAuth(url: String) : String? {
val found = WebViewResolver(
Regex("$mainUrl/misc/post/EVhcpMNbO77acNZcHr2XVjaG8WAdNC1u")
).resolveUsingWebView(
requestCreator(
"GET", url
)
).first
return found?.headers?.get("Authorization")
}
private suspend fun getAuth(url: String) = auth ?: fetchAuth(url)
private suspend fun getMisc(): String {
val misc = app.get(
"$mainUrl/misc/post/EVhcpMNbO77acNZcHr2XVjaG8WAdNC1u",