Add anime providers

This commit is contained in:
Blatzar 2022-08-11 16:55:58 +02:00
parent b74b8614db
commit b3f33b368a
139 changed files with 9873 additions and 9 deletions

View file

@ -0,0 +1,22 @@
// use an integer for version numbers
version = 1
cloudstream {
// All of these properties are optional, you can safely remove them
// description = "Lorem Ipsum"
// authors = listOf("Cloudburst")
/**
* Status int as the following:
* 0: Down
* 1: Ok
* 2: Slow
* 3: Beta only
* */
status = 1 // will be 3 if unspecified
// Set to true to get an 18+ symbol next to the plugin
adult = false // will be false if unspecified
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.lagradost"/>

View file

@ -0,0 +1,357 @@
package com.lagradost
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.Jsoup
class NineAnimeProvider : MainAPI() {
override var mainUrl = "https://9anime.id"
override var name = "9Anime"
override val hasMainPage = true
override val hasChromecastSupport = true
override val hasDownloadSupport = true
override val supportedTypes = setOf(TvType.Anime)
override val hasQuickSearch = true
// taken from https://github.com/saikou-app/saikou/blob/b35364c8c2a00364178a472fccf1ab72f09815b4/app/src/main/java/ani/saikou/parsers/anime/NineAnime.kt
// GNU General Public License v3.0 https://github.com/saikou-app/saikou/blob/main/LICENSE.md
companion object {
private const val nineAnimeKey =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
private const val cipherKey = "kMXzgyNzT3k5dYab"
fun encodeVrf(text: String, mainKey: String): String {
return encode(
encrypt(
cipher(mainKey, encode(text)),
nineAnimeKey
)//.replace("""=+$""".toRegex(), "")
)
}
fun decodeVrf(text: String, mainKey: String): String {
return decode(cipher(mainKey, decrypt(text, nineAnimeKey)))
}
fun encrypt(input: String, key: String): String {
if (input.any { it.code > 255 }) throw Exception("illegal characters!")
var output = ""
for (i in input.indices step 3) {
val a = intArrayOf(-1, -1, -1, -1)
a[0] = input[i].code shr 2
a[1] = (3 and input[i].code) shl 4
if (input.length > i + 1) {
a[1] = a[1] or (input[i + 1].code shr 4)
a[2] = (15 and input[i + 1].code) shl 2
}
if (input.length > i + 2) {
a[2] = a[2] or (input[i + 2].code shr 6)
a[3] = 63 and input[i + 2].code
}
for (n in a) {
if (n == -1) output += "="
else {
if (n in 0..63) output += key[n]
}
}
}
return output
}
fun cipher(key: String, text: String): String {
val arr = IntArray(256) { it }
var u = 0
var r: Int
arr.indices.forEach {
u = (u + arr[it] + key[it % key.length].code) % 256
r = arr[it]
arr[it] = arr[u]
arr[u] = r
}
u = 0
var c = 0
return text.indices.map { j ->
c = (c + 1) % 256
u = (u + arr[c]) % 256
r = arr[c]
arr[c] = arr[u]
arr[u] = r
(text[j].code xor arr[(arr[c] + arr[u]) % 256]).toChar()
}.joinToString("")
}
@Suppress("SameParameterValue")
private fun decrypt(input: String, key: String): String {
val t = if (input.replace("""[\t\n\f\r]""".toRegex(), "").length % 4 == 0) {
input.replace("""==?$""".toRegex(), "")
} else input
if (t.length % 4 == 1 || t.contains("""[^+/0-9A-Za-z]""".toRegex())) throw Exception("bad input")
var i: Int
var r = ""
var e = 0
var u = 0
for (o in t.indices) {
e = e shl 6
i = key.indexOf(t[o])
e = e or i
u += 6
if (24 == u) {
r += ((16711680 and e) shr 16).toChar()
r += ((65280 and e) shr 8).toChar()
r += (255 and e).toChar()
e = 0
u = 0
}
}
return if (12 == u) {
e = e shr 4
r + e.toChar()
} else {
if (18 == u) {
e = e shr 2
r += ((65280 and e) shr 8).toChar()
r += (255 and e).toChar()
}
r
}
}
fun encode(input: String): String =
java.net.URLEncoder.encode(input, "utf-8").replace("+", "%20")
private fun decode(input: String): String = java.net.URLDecoder.decode(input, "utf-8")
}
override val mainPage = mainPageOf(
"$mainUrl/ajax/home/widget/trending?page=" to "Trending",
"$mainUrl/ajax/home/widget/updated-all?page=" to "All",
"$mainUrl/ajax/home/widget/updated-sub?page=" to "Recently Updated (SUB)",
"$mainUrl/ajax/home/widget/updated-dub?page=" to "Recently Updated (DUB)",
"$mainUrl/ajax/home/widget/updated-china?page=" to "Recently Updated (Chinese)",
"$mainUrl/ajax/home/widget/random?page=" to "Random",
)
override suspend fun getMainPage(
page: Int,
request: MainPageRequest
): HomePageResponse {
val url = request.data + page
val home = Jsoup.parse(
app.get(
url
).parsed<Response>().html
).select("div.item").mapNotNull { element ->
val title = element.selectFirst(".info > .name") ?: return@mapNotNull null
val link = title.attr("href")
val poster = element.selectFirst(".poster > a > img")?.attr("src")
val meta = element.selectFirst(".poster > a > .meta > .inner > .left")
val subbedEpisodes = meta?.selectFirst(".sub")?.text()?.toIntOrNull()
val dubbedEpisodes = meta?.selectFirst(".dub")?.text()?.toIntOrNull()
newAnimeSearchResponse(title.text() ?: return@mapNotNull null, link) {
this.posterUrl = poster
addDubStatus(
dubbedEpisodes != null,
subbedEpisodes != null,
dubbedEpisodes,
subbedEpisodes
)
}
}
return newHomePageResponse(request.name, home)
}
data class Response(
@JsonProperty("result") val html: String
)
data class QuickSearchResponse(
//@JsonProperty("status") val status: Int? = null,
@JsonProperty("result") val result: QuickSearchResult? = null,
//@JsonProperty("message") val message: String? = null,
//@JsonProperty("messages") val messages: ArrayList<String> = arrayListOf()
)
data class QuickSearchResult(
@JsonProperty("html") val html: String? = null,
//@JsonProperty("linkMore") val linkMore: String? = null
)
override suspend fun quickSearch(query: String): List<SearchResponse>? {
val vrf = encodeVrf(query, cipherKey)
val url =
"$mainUrl/ajax/anime/search?keyword=$query&vrf=$vrf"
val response = app.get(url).parsedSafe<QuickSearchResponse>()
val document = Jsoup.parse(response?.result?.html ?: return null)
return document.select(".items > a").mapNotNull { element ->
val link = fixUrl(element?.attr("href") ?: return@mapNotNull null)
val title = element.selectFirst(".info > .name")?.text() ?: return@mapNotNull null
newAnimeSearchResponse(title, link) {
posterUrl = element.selectFirst(".poster > span > img")?.attr("src")
}
}
}
override suspend fun search(query: String): List<SearchResponse> {
val vrf = encodeVrf(query, cipherKey)
//?language%5B%5D=${if (selectDub) "dubbed" else "subbed"}&
val url =
"$mainUrl/filter?keyword=${encode(query)}&vrf=${vrf}&page=1"
return app.get(url).document.select("#list-items div.ani.poster.tip > a").mapNotNull {
val link = fixUrl(it.attr("href") ?: return@mapNotNull null)
val img = it.select("img")
val title = img.attr("alt")
newAnimeSearchResponse(title, link) {
posterUrl = img.attr("src")
}
}
}
override suspend fun load(url: String): LoadResponse {
val validUrl = url.replace("https://9anime.to", mainUrl)
val doc = app.get(validUrl).document
val meta = doc.selectFirst("#w-info") ?: throw ErrorLoadingException("Could not find info")
val ratingElement = meta.selectFirst(".brating > #w-rating")
val id = ratingElement?.attr("data-id") ?: throw ErrorLoadingException("Could not find id")
val binfo =
meta.selectFirst(".binfo") ?: throw ErrorLoadingException("Could not find binfo")
val info = binfo.selectFirst(".info") ?: throw ErrorLoadingException("Could not find info")
val title = (info.selectFirst(".title") ?: info.selectFirst(".d-title"))?.text()
?: throw ErrorLoadingException("Could not find title")
val vrf = encodeVrf(id, cipherKey)
val episodeListUrl = "$mainUrl/ajax/episode/list/$id?vrf=$vrf"
val body =
app.get(episodeListUrl).parsedSafe<Response>()?.html
?: throw ErrorLoadingException("Could not parse json with cipherKey=$cipherKey id=$id url=\n$episodeListUrl")
val subEpisodes = ArrayList<Episode>()
val dubEpisodes = ArrayList<Episode>()
//TODO RECOMMENDATIONS
Jsoup.parse(body).body().select(".episodes > ul > li > a").mapNotNull { element ->
val ids = element.attr("data-ids").split(",", limit = 2)
val epNum = element.attr("data-num")
.toIntOrNull() // might fuck up on 7.5 ect might use data-slug instead
val epTitle = element.selectFirst("span.d-title")?.text()
//val filler = element.hasClass("filler")
ids.getOrNull(1)?.let { dub ->
dubEpisodes.add(
Episode(
"$mainUrl/ajax/server/list/$dub?vrf=${encodeVrf(dub, cipherKey)}",
epTitle,
episode = epNum
)
)
}
ids.getOrNull(0)?.let { sub ->
subEpisodes.add(
Episode(
"$mainUrl/ajax/server/list/$sub?vrf=${encodeVrf(sub, cipherKey)}",
epTitle,
episode = epNum
)
)
}
}
return newAnimeLoadResponse(title, url, TvType.Anime) {
addEpisodes(DubStatus.Dubbed, dubEpisodes)
addEpisodes(DubStatus.Subbed, subEpisodes)
plot = info.selectFirst(".synopsis > .shorting > .content")?.text()
posterUrl = binfo.selectFirst(".poster > span > img")?.attr("src")
rating = ratingElement.attr("data-score").toFloat().times(1000f).toInt()
info.select(".bmeta > .meta > div").forEach { element ->
when (element.ownText()) {
"Genre: " -> {
tags = element.select("span > a").mapNotNull { it?.text() }
}
"Duration: " -> {
duration = getDurationFromString(element.selectFirst("span")?.text())
}
"Type: " -> {
type = when (element.selectFirst("span > a")?.text()) {
"ONA" -> TvType.OVA
else -> {
type
}
}
}
"Status: " -> {
showStatus = when (element.selectFirst("span")?.text()) {
"Releasing" -> ShowStatus.Ongoing
"Completed" -> ShowStatus.Completed
else -> {
showStatus
}
}
}
else -> {}
}
}
}
}
data class Result(
@JsonProperty("url")
val url: String? = null
)
data class Links(
@JsonProperty("result")
val result: Result? = null
)
//TODO 9anime outro into {"status":200,"result":{"url":"","skip_data":{"intro_begin":67,"intro_end":154,"outro_begin":1337,"outro_end":1415,"count":3}},"message":"","messages":[]}
private suspend fun getEpisodeLinks(id: String): Links? {
return app.get("$mainUrl/ajax/server/$id?vrf=${encodeVrf(id, cipherKey)}").parsedSafe()
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
val body = app.get(data).parsed<Response>().html
val document = Jsoup.parse(body)
document.select("li").apmap {
try {
val name = it.text()
val encodedStreamUrl =
getEpisodeLinks(it.attr("data-link-id"))?.result?.url ?: return@apmap
val url = decodeVrf(encodedStreamUrl, cipherKey)
if (!loadExtractor(url, mainUrl, subtitleCallback, callback)) {
callback(
ExtractorLink(
this.name,
name,
url,
mainUrl,
Qualities.Unknown.value,
url.contains(".m3u8")
)
)
}
} catch (e: Exception) {
logError(e)
}
}
return true
}
}

View file

@ -0,0 +1,27 @@
package com.lagradost
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin
import android.content.Context
@CloudstreamPlugin
class NineAnimeProviderPlugin : Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(NineAnimeProvider())
registerMainAPI(WcoProvider())
registerExtractorAPI(Mcloud())
registerExtractorAPI(Vidstreamz())
registerExtractorAPI(Vizcloud())
registerExtractorAPI(Vizcloud2())
registerExtractorAPI(VizcloudOnline())
registerExtractorAPI(VizcloudXyz())
registerExtractorAPI(VizcloudLive())
registerExtractorAPI(VizcloudInfo())
registerExtractorAPI(MwvnVizcloudInfo())
registerExtractorAPI(VizcloudDigital())
registerExtractorAPI(VizcloudCloud())
registerExtractorAPI(VizcloudSite())
registerExtractorAPI(WcoStream())
}
}

View file

@ -0,0 +1,238 @@
package com.lagradost
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink
import org.json.JSONObject
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.util.*
class WcoProvider : MainAPI() {
companion object {
fun getType(t: String): TvType {
return if (t.contains("OVA") || t.contains("Special")) TvType.OVA
else if (t.contains("Movie")) TvType.AnimeMovie
else TvType.Anime
}
}
override var mainUrl = "https://wcostream.cc"
override var name = "WCO Stream"
override val hasQuickSearch = true
override val hasMainPage = true
override val supportedTypes = setOf(
TvType.AnimeMovie,
TvType.Anime,
TvType.OVA
)
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
val urls = listOf(
Pair("$mainUrl/ajax/list/recently_updated?type=tv", "Recently Updated Anime"),
Pair("$mainUrl/ajax/list/recently_updated?type=movie", "Recently Updated Movies"),
Pair("$mainUrl/ajax/list/recently_added?type=tv", "Recently Added Anime"),
Pair("$mainUrl/ajax/list/recently_added?type=movie", "Recently Added Movies"),
)
val items = ArrayList<HomePageList>()
for (i in urls) {
try {
val response = JSONObject(
app.get(
i.first,
).text
).getString("html") // I won't make a dataclass for this shit
val document = Jsoup.parse(response)
val results = document.select("div.flw-item").map {
val filmPoster = it.selectFirst("> div.film-poster")
val filmDetail = it.selectFirst("> div.film-detail")
val nameHeader = filmDetail!!.selectFirst("> h3.film-name > a")
val title = nameHeader!!.text().replace(" (Dub)", "")
val href =
nameHeader.attr("href").replace("/watch/", "/anime/")
.replace(Regex("-episode-.*"), "/")
val isDub =
filmPoster!!.selectFirst("> div.film-poster-quality")?.text()
?.contains("DUB")
?: false
val poster = filmPoster.selectFirst("> img")!!.attr("data-src")
val set: EnumSet<DubStatus> =
EnumSet.of(if (isDub) DubStatus.Dubbed else DubStatus.Subbed)
AnimeSearchResponse(title, href, this.name, TvType.Anime, poster, null, set)
}
items.add(HomePageList(i.second, results))
} catch (e: Exception) {
e.printStackTrace()
}
}
if (items.size <= 0) throw ErrorLoadingException()
return HomePageResponse(items)
}
private fun fixAnimeLink(url: String): String {
val regex = "watch/([a-zA-Z\\-0-9]*)-episode".toRegex()
val (aniId) = regex.find(url)!!.destructured
return "$mainUrl/anime/$aniId"
}
private fun parseSearchPage(soup: Document): List<SearchResponse> {
val items = soup.select(".film_list-wrap > .flw-item")
if (items.isEmpty()) return ArrayList()
return items.map { i ->
val href = fixAnimeLink(i.selectFirst("a")!!.attr("href"))
val img = fixUrl(i.selectFirst("img")!!.attr("data-src"))
val title = i.selectFirst("img")!!.attr("title")
val isDub = !i.select(".pick.film-poster-quality").isEmpty()
val year =
i.selectFirst(".film-detail.film-detail-fix > div > span:nth-child(1)")!!.text()
.toIntOrNull()
val type =
i.selectFirst(".film-detail.film-detail-fix > div > span:nth-child(3)")!!.text()
if (getType(type) == TvType.AnimeMovie) {
MovieSearchResponse(
title, href, this.name, TvType.AnimeMovie, img, year
)
} else {
AnimeSearchResponse(
title,
href,
this.name,
TvType.Anime,
img,
year,
EnumSet.of(if (isDub) DubStatus.Dubbed else DubStatus.Subbed),
)
}
}
}
override suspend fun search(query: String): List<SearchResponse> {
val url = "$mainUrl/search"
val response =
app.get(url, params = mapOf("keyword" to query))
var document = Jsoup.parse(response.text)
val returnValue = parseSearchPage(document).toMutableList()
while (!document.select(".pagination").isEmpty()) {
val link = document.select("a.page-link[rel=\"next\"]")
if (!link.isEmpty() && returnValue.size < 40) {
val extraResponse = app.get(fixUrl(link[0].attr("href"))).text
document = Jsoup.parse(extraResponse)
returnValue.addAll(parseSearchPage(document))
} else {
break
}
}
return returnValue.distinctBy { it.url }
}
override suspend fun quickSearch(query: String): List<SearchResponse> {
val response = JSONObject(
app.post(
"https://wcostream.cc/ajax/search",
data = mapOf("keyword" to query)
).text
).getString("html") // I won't make a dataclass for this shit
val document = Jsoup.parse(response)
return document.select("a.nav-item").mapNotNull {
val title = it.selectFirst("img")?.attr("title") ?: return@mapNotNull null
val img = it?.selectFirst("img")?.attr("src") ?: return@mapNotNull null
val href = it?.attr("href") ?: return@mapNotNull null
val isDub = title.contains("(Dub)")
val filmInfo = it.selectFirst(".film-infor")
val year = filmInfo?.select("span")?.get(0)?.text()?.toIntOrNull()
val type = filmInfo?.select("span")?.get(1)?.text().toString()
if (getType(type) == TvType.AnimeMovie) {
MovieSearchResponse(
title, href, this.name, TvType.AnimeMovie, img, year
)
} else {
AnimeSearchResponse(
title,
href,
this.name,
TvType.Anime,
img,
year,
EnumSet.of(if (isDub) DubStatus.Dubbed else DubStatus.Subbed),
)
}
}
}
override suspend fun load(url: String): LoadResponse {
val response = app.get(url, timeout = 120).text
val document = Jsoup.parse(response)
val japaneseTitle =
document.selectFirst("div.elements div.row > div:nth-child(1) > div.row-line:nth-child(1)")
?.text()?.trim()?.replace("Other names:", "")?.trim()
val canonicalTitle = document.selectFirst("meta[name=\"title\"]")
?.attr("content")?.split("| W")?.get(0).toString()
val isDubbed = canonicalTitle.contains("Dub")
val episodeNodes = document.select(".tab-content .nav-item > a")
val episodes = ArrayList(episodeNodes?.map {
Episode(it.attr("href"))
} ?: ArrayList())
val statusElem =
document.selectFirst("div.elements div.row > div:nth-child(1) > div.row-line:nth-child(2)")
val status = when (statusElem?.text()?.replace("Status:", "")?.trim()) {
"Ongoing" -> ShowStatus.Ongoing
"Completed" -> ShowStatus.Completed
else -> null
}
val yearText =
document.selectFirst("div.elements div.row > div:nth-child(2) > div.row-line:nth-child(4)")
?.text()
val year = yearText?.replace("Date release:", "")?.trim()?.split("-")?.get(0)?.toIntOrNull()
val poster = document.selectFirst(".film-poster-img")?.attr("src")
val type = document.selectFirst("span.item.mr-1 > a")?.text()?.trim()
val synopsis = document.selectFirst(".description > p")?.text()?.trim()
val genre =
document.select("div.elements div.row > div:nth-child(1) > div.row-line:nth-child(5) > a")
.map { it?.text()?.trim().toString() }
return newAnimeLoadResponse(canonicalTitle, url, getType(type ?: "")) {
japName = japaneseTitle
engName = canonicalTitle
posterUrl = poster
this.year = year
addEpisodes(if (isDubbed) DubStatus.Dubbed else DubStatus.Subbed, episodes)
showStatus = status
plot = synopsis
tags = genre
}
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
val response = app.get(data).text
val servers = Jsoup.parse(response).select("#servers-list > ul > li").map {
mapOf(
"link" to it?.selectFirst("a")?.attr("data-embed"),
"title" to it?.selectFirst("span")?.text()?.trim()
)
}
for (server in servers) {
WcoStream().getSafeUrl(server["link"].toString(), null, subtitleCallback, callback)
Mcloud().getSafeUrl(server["link"].toString(), null, subtitleCallback, callback)
}
return true
}
}

View file

@ -0,0 +1,133 @@
package com.lagradost
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.NineAnimeProvider.Companion.cipher
import com.lagradost.NineAnimeProvider.Companion.encrypt
import com.lagradost.cloudstream3.ErrorLoadingException
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
class Vidstreamz : WcoStream() {
override var mainUrl = "https://vidstreamz.online"
}
open class Mcloud : WcoStream() {
override var name = "Mcloud"
override var mainUrl = "https://mcloud.to"
override val requiresReferer = true
}
class Vizcloud : WcoStream() {
override var mainUrl = "https://vizcloud2.ru"
}
class Vizcloud2 : WcoStream() {
override var mainUrl = "https://vizcloud2.online"
}
class VizcloudOnline : WcoStream() {
override var mainUrl = "https://vizcloud.online"
}
class VizcloudXyz : WcoStream() {
override var mainUrl = "https://vizcloud.xyz"
}
class VizcloudLive : WcoStream() {
override var mainUrl = "https://vizcloud.live"
}
class VizcloudInfo : WcoStream() {
override var mainUrl = "https://vizcloud.info"
}
class MwvnVizcloudInfo : WcoStream() {
override var mainUrl = "https://mwvn.vizcloud.info"
}
class VizcloudDigital : WcoStream() {
override var mainUrl = "https://vizcloud.digital"
}
class VizcloudCloud : WcoStream() {
override var mainUrl = "https://vizcloud.cloud"
}
class VizcloudSite : WcoStream() {
override var mainUrl = "https://vizcloud.site"
}
open class WcoStream : ExtractorApi() {
override var name = "VidStream" // Cause works for animekisa and wco
override var mainUrl = "https://vidstream.pro"
override val requiresReferer = false
private val regex = Regex("(.+?/)e(?:mbed)?/([a-zA-Z0-9]+)")
companion object {
// taken from https://github.com/saikou-app/saikou/blob/b35364c8c2a00364178a472fccf1ab72f09815b4/app/src/main/java/ani/saikou/parsers/anime/extractors/VizCloud.kt
// GNU General Public License v3.0 https://github.com/saikou-app/saikou/blob/main/LICENSE.md
private var lastChecked = 0L
private const val jsonLink =
"https://raw.githubusercontent.com/chenkaslowankiya/BruhFlow/main/keys.json"
private var cipherKey: VizCloudKey? = null
suspend fun getKey(): VizCloudKey {
cipherKey =
if (cipherKey != null && (lastChecked - System.currentTimeMillis()) < 1000 * 60 * 30) cipherKey!!
else {
lastChecked = System.currentTimeMillis()
app.get(jsonLink).parsed()
}
return cipherKey!!
}
data class VizCloudKey(
@JsonProperty("cipherKey") val cipherKey: String,
@JsonProperty("mainKey") val mainKey: String,
@JsonProperty("encryptKey") val encryptKey: String,
@JsonProperty("dashTable") val dashTable: String
)
private const val baseTable =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+=/_"
private fun dashify(id: String, dashTable: String): String {
val table = dashTable.split(" ")
return id.mapIndexedNotNull { i, c ->
table.getOrNull((baseTable.indexOf(c) * 16) + (i % 16))
}.joinToString("-")
}
}
//private val key = "LCbu3iYC7ln24K7P" // key credits @Modder4869
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink> {
val group = regex.find(url)?.groupValues!!
val host = group[1]
val viz = getKey()
val id = encrypt(
cipher(
viz.cipherKey,
encrypt(group[2], viz.encryptKey).also { println(it) }
).also { println(it) },
viz.encryptKey
).also { println(it) }
val link =
"${host}mediainfo/${dashify(id, viz.dashTable)}?key=${viz.mainKey}" //
val response = app.get(link, referer = referer)
data class Sources(@JsonProperty("file") val file: String)
data class Media(@JsonProperty("sources") val sources: List<Sources>)
data class Data(@JsonProperty("media") val media: Media)
data class Response(@JsonProperty("data") val data: Data)
if (!response.text.startsWith("{")) throw ErrorLoadingException("Seems like 9Anime kiddies changed stuff again, Go touch some grass for bout an hour Or use a different Server")
return response.parsed<Response>().data.media.sources.map {
ExtractorLink(name, it.file,it.file,host,Qualities.Unknown.value,it.file.contains(".m3u8"))
}
}
}