Skip to content

Commit

Permalink
Animasu: added new server
Browse files Browse the repository at this point in the history
  • Loading branch information
jackjohn committed Nov 28, 2023
1 parent 7dcaa24 commit fc542ae
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Animasu/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// use an integer for version numbers
version = 5
version = 6


cloudstream {
Expand Down
2 changes: 2 additions & 0 deletions Animasu/src/main/kotlin/com/hexated/AnimasuPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
102 changes: 102 additions & 0 deletions Animasu/src/main/kotlin/com/hexated/Extractors.kt
Original file line number Diff line number Diff line change
@@ -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,
)

}
2 changes: 1 addition & 1 deletion KuramanimeProvider/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// use an integer for version numbers
version = 22
version = 23


cloudstream {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(
Expand Down Expand Up @@ -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
)
Expand All @@ -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",
Expand Down

0 comments on commit fc542ae

Please sign in to comment.