mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
9anime should work now
This commit is contained in:
parent
9b6b06437f
commit
c6a10518f5
5 changed files with 311 additions and 261 deletions
|
@ -837,9 +837,9 @@ fun AnimeSearchResponse.addDubStatus(
|
||||||
|
|
||||||
fun AnimeSearchResponse.addDubStatus(status: String, episodes: Int? = null) {
|
fun AnimeSearchResponse.addDubStatus(status: String, episodes: Int? = null) {
|
||||||
if (status.contains("(dub)", ignoreCase = true)) {
|
if (status.contains("(dub)", ignoreCase = true)) {
|
||||||
addDubStatus(DubStatus.Dubbed)
|
addDubStatus(DubStatus.Dubbed, episodes)
|
||||||
} else if (status.contains("(sub)", ignoreCase = true)) {
|
} else if (status.contains("(sub)", ignoreCase = true)) {
|
||||||
addDubStatus(DubStatus.Subbed)
|
addDubStatus(DubStatus.Subbed, episodes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,27 +1020,30 @@ interface LoadResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun LoadResponse.addDuration(input: String?) {
|
fun LoadResponse.addDuration(input: String?) {
|
||||||
val cleanInput = input?.trim()?.replace(" ", "") ?: return
|
this.duration = getDurationFromString(input) ?: this.duration
|
||||||
Regex("([0-9]*)h.*?([0-9]*)m").find(cleanInput)?.groupValues?.let { values ->
|
|
||||||
if (values.size == 3) {
|
|
||||||
val hours = values[1].toIntOrNull()
|
|
||||||
val minutes = values[2].toIntOrNull()
|
|
||||||
this.duration = if (minutes != null && hours != null) {
|
|
||||||
hours * 60 + minutes
|
|
||||||
} else null
|
|
||||||
if (this.duration != null) return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Regex("([0-9]*)m").find(cleanInput)?.groupValues?.let { values ->
|
|
||||||
if (values.size == 2) {
|
|
||||||
this.duration = values[1].toIntOrNull()
|
|
||||||
if (this.duration != null) return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getDurationFromString(input: String?): Int? {
|
||||||
|
val cleanInput = input?.trim()?.replace(" ", "") ?: return null
|
||||||
|
Regex("([0-9]*)h.*?([0-9]*)m").find(cleanInput)?.groupValues?.let { values ->
|
||||||
|
if (values.size == 3) {
|
||||||
|
val hours = values[1].toIntOrNull()
|
||||||
|
val minutes = values[2].toIntOrNull()
|
||||||
|
return if (minutes != null && hours != null) {
|
||||||
|
hours * 60 + minutes
|
||||||
|
} else null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Regex("([0-9]*)m").find(cleanInput)?.groupValues?.let { values ->
|
||||||
|
if (values.size == 2) {
|
||||||
|
return values[1].toIntOrNull()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
fun LoadResponse?.isEpisodeBased(): Boolean {
|
fun LoadResponse?.isEpisodeBased(): Boolean {
|
||||||
if (this == null) return false
|
if (this == null) return false
|
||||||
return this is EpisodeResponse && this.type.isEpisodeBased()
|
return this is EpisodeResponse && this.type.isEpisodeBased()
|
||||||
|
@ -1118,7 +1121,7 @@ data class AnimeLoadResponse(
|
||||||
) : LoadResponse, EpisodeResponse
|
) : LoadResponse, EpisodeResponse
|
||||||
|
|
||||||
fun AnimeLoadResponse.addEpisodes(status: DubStatus, episodes: List<Episode>?) {
|
fun AnimeLoadResponse.addEpisodes(status: DubStatus, episodes: List<Episode>?) {
|
||||||
if (episodes == null) return
|
if (episodes.isNullOrEmpty()) return
|
||||||
this.episodes[status] = episodes
|
this.episodes[status] = episodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,10 @@ package com.lagradost.cloudstream3.animeproviders
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
import com.lagradost.cloudstream3.utils.Qualities
|
||||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class NineAnimeProvider : MainAPI() {
|
class NineAnimeProvider : MainAPI() {
|
||||||
override var mainUrl = "https://9anime.id"
|
override var mainUrl = "https://9anime.id"
|
||||||
|
@ -16,6 +15,7 @@ class NineAnimeProvider : MainAPI() {
|
||||||
override val hasChromecastSupport = true
|
override val hasChromecastSupport = true
|
||||||
override val hasDownloadSupport = true
|
override val hasDownloadSupport = true
|
||||||
override val supportedTypes = setOf(TvType.Anime)
|
override val supportedTypes = setOf(TvType.Anime)
|
||||||
|
override val hasQuickSearch = true
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getDubStatus(title: String): DubStatus {
|
fun getDubStatus(title: String): DubStatus {
|
||||||
|
@ -25,35 +25,147 @@ class NineAnimeProvider : MainAPI() {
|
||||||
DubStatus.Subbed
|
DubStatus.Subbed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private const val nineAnimeKey =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||||
|
private const val cipherKey = "rTKp3auwu0ULA6II"
|
||||||
|
|
||||||
|
private fun encodeVrf(text: String): String {
|
||||||
|
return encode(
|
||||||
|
encrypt(
|
||||||
|
cipher(cipherKey, encode(text)),
|
||||||
|
nineAnimeKey
|
||||||
|
).replace("""=+$""".toRegex(), "")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun decodeVrf(text: String): String {
|
||||||
|
return decode(cipher(cipherKey, 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private 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 suspend fun getMainPage(): HomePageResponse {
|
override suspend fun getMainPage(): HomePageResponse {
|
||||||
val items = listOf(
|
val items = listOf(
|
||||||
Pair("$mainUrl/ajax/home/widget?name=trending", "Trending"),
|
"$mainUrl/ajax/home/widget/trending?page=1" to "Trending",
|
||||||
Pair("$mainUrl/ajax/home/widget?name=updated_all", "All"),
|
"$mainUrl/ajax/home/widget/updated-all?page=1" to "All",
|
||||||
Pair("$mainUrl/ajax/home/widget?name=updated_sub&page=1", "Recently Updated (SUB)"),
|
"$mainUrl/ajax/home/widget/updated-sub?page=1" to "Recently Updated (SUB)",
|
||||||
Pair(
|
"$mainUrl/ajax/home/widget/updated-dub?page=1" to
|
||||||
"$mainUrl/ajax/home/widget?name=updated_dub&page=1",
|
"Recently Updated (DUB)",
|
||||||
"Recently Updated (DUB)"
|
"$mainUrl/ajax/home/widget/updated-china?page=1" to
|
||||||
),
|
"Recently Updated (Chinese)",
|
||||||
Pair(
|
"$mainUrl/ajax/home/widget/random?page=1" to "Random",
|
||||||
"$mainUrl/ajax/home/widget?name=updated_chinese&page=1",
|
|
||||||
"Recently Updated (Chinese)"
|
|
||||||
),
|
|
||||||
Pair("$mainUrl/ajax/home/widget?name=random", "Random"),
|
|
||||||
).apmap { (url, name) ->
|
).apmap { (url, name) ->
|
||||||
val home = Jsoup.parse(
|
val home = Jsoup.parse(
|
||||||
app.get(
|
app.get(
|
||||||
url
|
url
|
||||||
).parsed<Response>().html
|
).parsed<Response>().html
|
||||||
).select("ul.anime-list li").map {
|
).select("div.item").mapNotNull { element ->
|
||||||
val title = it.selectFirst("a.name")!!.text()
|
val title = element.selectFirst(".info > .name") ?: return@mapNotNull null
|
||||||
val link = it.selectFirst("a")!!.attr("href")
|
val link = title.attr("href")
|
||||||
val poster = it.selectFirst("a.poster img")!!.attr("src")
|
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, link) {
|
newAnimeSearchResponse(title.text() ?: return@mapNotNull null, link) {
|
||||||
this.posterUrl = poster
|
this.posterUrl = poster
|
||||||
addDubStatus(getDubStatus(title))
|
addDubStatus(
|
||||||
|
dubbedEpisodes != null,
|
||||||
|
subbedEpisodes != null,
|
||||||
|
dubbedEpisodes,
|
||||||
|
subbedEpisodes
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,248 +175,184 @@ class NineAnimeProvider : MainAPI() {
|
||||||
return HomePageResponse(items)
|
return HomePageResponse(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Credits to https://github.com/jmir1
|
|
||||||
private val key =
|
|
||||||
"c/aUAorINHBLxWTy3uRiPt8J+vjsOheFG1E0q2X9CYwDZlnmd4Kb5M6gSVzfk7pQ" //key credits to @Modder4869
|
|
||||||
|
|
||||||
private fun getVrf(id: String): String? {
|
|
||||||
val reversed = ue(encode(id) + "0000000").slice(0..5).reversed()
|
|
||||||
|
|
||||||
return reversed + ue(je(reversed, encode(id) ?: return null)).replace(
|
|
||||||
"""=+$""".toRegex(),
|
|
||||||
""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getLink(url: String): String? {
|
|
||||||
val i = url.slice(0..5)
|
|
||||||
val n = url.slice(6..url.lastIndex)
|
|
||||||
return decode(je(i, ze(n)))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ue(input: String): String {
|
|
||||||
if (input.any { it.code >= 256 }) 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun je(inputOne: String, inputTwo: String): String {
|
|
||||||
val arr = IntArray(256) { it }
|
|
||||||
var output = ""
|
|
||||||
var u = 0
|
|
||||||
var r: Int
|
|
||||||
for (a in arr.indices) {
|
|
||||||
u = (u + arr[a] + inputOne[a % inputOne.length].code) % 256
|
|
||||||
r = arr[a]
|
|
||||||
arr[a] = arr[u]
|
|
||||||
arr[u] = r
|
|
||||||
}
|
|
||||||
u = 0
|
|
||||||
var c = 0
|
|
||||||
for (f in inputTwo.indices) {
|
|
||||||
c = (c + f) % 256
|
|
||||||
u = (u + arr[c]) % 256
|
|
||||||
r = arr[c]
|
|
||||||
arr[c] = arr[u]
|
|
||||||
arr[u] = r
|
|
||||||
output += (inputTwo[f].code xor arr[(arr[c] + arr[u]) % 256]).toChar()
|
|
||||||
}
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ze(input: String): String {
|
|
||||||
val t = if (input.replace("""[\t\n\f\r]""".toRegex(), "").length % 4 == 0) {
|
|
||||||
input.replace(Regex("""/==?$/"""), "")
|
|
||||||
} else input
|
|
||||||
if (t.length % 4 == 1 || t.contains(Regex("""[^+/0-9A-Za-z]"""))) 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun encode(input: String): String? = java.net.URLEncoder.encode(input, "utf-8")
|
|
||||||
|
|
||||||
private fun decode(input: String): String? = java.net.URLDecoder.decode(input, "utf-8")
|
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
|
||||||
val url = "$mainUrl/filter?sort=title%3Aasc&keyword=$query"
|
|
||||||
|
|
||||||
return app.get(url).document.select("ul.anime-list li").mapNotNull {
|
|
||||||
val title = it.selectFirst("a.name")!!.text()
|
|
||||||
val href =
|
|
||||||
fixUrlNull(it.selectFirst("a")!!.attr("href"))?.replace(
|
|
||||||
Regex("(\\?ep=(\\d+)\$)"),
|
|
||||||
""
|
|
||||||
)
|
|
||||||
?: return@mapNotNull null
|
|
||||||
val image = it.selectFirst("a.poster img")!!.attr("src")
|
|
||||||
AnimeSearchResponse(
|
|
||||||
title,
|
|
||||||
href,
|
|
||||||
this.name,
|
|
||||||
TvType.Anime,
|
|
||||||
image,
|
|
||||||
null,
|
|
||||||
if (title.contains("(DUB)") || title.contains("(Dub)")) EnumSet.of(
|
|
||||||
DubStatus.Dubbed
|
|
||||||
) else EnumSet.of(DubStatus.Subbed),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data class Response(
|
data class Response(
|
||||||
@JsonProperty("html") val html: String
|
@JsonProperty("result") val html: String
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse? {
|
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)
|
||||||
|
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)
|
||||||
|
//?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 validUrl = url.replace("https://9anime.to", mainUrl)
|
||||||
val doc = app.get(validUrl).document
|
val doc = app.get(validUrl).document
|
||||||
val animeid =
|
|
||||||
doc.selectFirst("div.player-wrapper.watchpage")!!.attr("data-id") ?: return null
|
val meta = doc.selectFirst("#w-info") ?: throw ErrorLoadingException("Could not find info")
|
||||||
val animeidencoded = encode(getVrf(animeid) ?: return null)
|
val ratingElement = meta.selectFirst(".brating > #w-rating")
|
||||||
val poster = doc.selectFirst("aside.main div.thumb div img")!!.attr("src")
|
val id = ratingElement?.attr("data-id") ?: throw ErrorLoadingException("Could not find id")
|
||||||
val title = doc.selectFirst(".info .title")!!.text()
|
val binfo =
|
||||||
val description = doc.selectFirst("div.info p")!!.text().replace("Ver menos", "").trim()
|
meta.selectFirst(".binfo") ?: throw ErrorLoadingException("Could not find binfo")
|
||||||
val episodes = Jsoup.parse(
|
val info = binfo.selectFirst(".info") ?: throw ErrorLoadingException("Could not find info")
|
||||||
app.get(
|
|
||||||
"$mainUrl/ajax/anime/servers?ep=1&id=${animeid}&vrf=$animeidencoded&ep=8&episode=&token="
|
val title = (info.selectFirst(".title") ?: info.selectFirst(".d-title"))?.text()
|
||||||
).parsed<Response>().html
|
?: throw ErrorLoadingException("Could not find title")
|
||||||
).select("ul.episodes li a").mapNotNull {
|
|
||||||
val link = it?.attr("href") ?: return@mapNotNull null
|
val body =
|
||||||
val name = "Episode ${it.text()}"
|
app.get("$mainUrl/ajax/episode/list/$id?vrf=${encodeVrf(id)}").parsed<Response>().html
|
||||||
Episode(link, name)
|
|
||||||
|
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)}",
|
||||||
|
epTitle,
|
||||||
|
episode = epNum
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
ids.getOrNull(0)?.let { sub ->
|
||||||
|
subEpisodes.add(
|
||||||
|
Episode(
|
||||||
|
"$mainUrl/ajax/server/list/$sub?vrf=${encodeVrf(sub)}",
|
||||||
|
epTitle,
|
||||||
|
episode = epNum
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val recommendations =
|
return newAnimeLoadResponse(title, url, TvType.Anime) {
|
||||||
doc.select("div.container aside.main section div.body ul.anime-list li")
|
addEpisodes(DubStatus.Dubbed, dubEpisodes)
|
||||||
.mapNotNull { element ->
|
addEpisodes(DubStatus.Subbed, subEpisodes)
|
||||||
val recTitle = element.select("a.name").text() ?: return@mapNotNull null
|
|
||||||
val image = element.select("a.poster img").attr("src")
|
plot = info.selectFirst(".synopsis > .shorting > .content")?.text()
|
||||||
val recUrl = fixUrl(element.select("a").attr("href"))
|
posterUrl = binfo.selectFirst(".poster > span > img")?.attr("src")
|
||||||
newAnimeSearchResponse(recTitle, recUrl) {
|
rating = ratingElement.attr("data-score").toFloat().times(1000f).toInt()
|
||||||
this.posterUrl = image
|
|
||||||
addDubStatus(getDubStatus(recTitle))
|
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 -> {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
val infodoc = doc.selectFirst("div.info .meta .col1")!!.text()
|
|
||||||
val tvType = if (infodoc.contains("Movie")) TvType.AnimeMovie else TvType.Anime
|
|
||||||
val status =
|
|
||||||
if (infodoc.contains("Completed")) ShowStatus.Completed
|
|
||||||
else if (infodoc.contains("Airing")) ShowStatus.Ongoing
|
|
||||||
else null
|
|
||||||
val tags = doc.select("div.info .meta .col1 div:contains(Genre) a").map { it.text() }
|
|
||||||
|
|
||||||
return newAnimeLoadResponse(title, validUrl, tvType) {
|
|
||||||
this.posterUrl = poster
|
|
||||||
this.plot = description
|
|
||||||
this.recommendations = recommendations
|
|
||||||
this.showStatus = status
|
|
||||||
this.tags = tags
|
|
||||||
addEpisodes(DubStatus.Subbed, episodes)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Links(
|
data class Result(
|
||||||
@JsonProperty("url") val url: String
|
@JsonProperty("url")
|
||||||
|
val url: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Servers(
|
data class Links(
|
||||||
@JsonProperty("28") val mcloud: String?,
|
@JsonProperty("result")
|
||||||
@JsonProperty("35") val mp4upload: String?,
|
val result: Result? = null
|
||||||
@JsonProperty("40") val streamtape: String?,
|
|
||||||
@JsonProperty("41") val vidstream: String?,
|
|
||||||
@JsonProperty("43") val videovard: String?
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//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)}").parsedSafe()
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun loadLinks(
|
override suspend fun loadLinks(
|
||||||
data: String,
|
data: String,
|
||||||
isCasting: Boolean,
|
isCasting: Boolean,
|
||||||
subtitleCallback: (SubtitleFile) -> Unit,
|
subtitleCallback: (SubtitleFile) -> Unit,
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val document = app.get(data).document
|
val body = app.get(data).parsed<Response>().html
|
||||||
val animeid =
|
val document = Jsoup.parse(body)
|
||||||
document.selectFirst("div.player-wrapper.watchpage")!!.attr("data-id") ?: return false
|
|
||||||
val animeidencoded = encode(getVrf(animeid) ?: return false)
|
|
||||||
|
|
||||||
Jsoup.parse(
|
document.select("li").apmap {
|
||||||
app.get(
|
try {
|
||||||
"$mainUrl/ajax/anime/servers?&id=${animeid}&vrf=$animeidencoded&episode=&token="
|
val name = it.text()
|
||||||
).parsed<Response>().html
|
val encodedStreamUrl =
|
||||||
).select("div.body").map { element ->
|
getEpisodeLinks(it.attr("data-link-id"))?.result?.url ?: return@apmap
|
||||||
val jsonregex = Regex("(\\{.+\\}.*$data)")
|
val url = decodeVrf(encodedStreamUrl)
|
||||||
val servers = jsonregex.find(element.toString())?.value?.replace(
|
if (!loadExtractor(url, callback = callback, referer = mainUrl)) {
|
||||||
Regex("(\".*data-base=.*href=\"$data)"),
|
callback(
|
||||||
""
|
ExtractorLink(
|
||||||
)?.replace(""", "\"") ?: return@map
|
this.name,
|
||||||
|
name,
|
||||||
val jsonservers = parseJson<Servers?>(servers) ?: return@map
|
url,
|
||||||
listOfNotNull(
|
mainUrl,
|
||||||
jsonservers.vidstream,
|
Qualities.Unknown.value,
|
||||||
jsonservers.mcloud,
|
url.contains(".m3u8")
|
||||||
jsonservers.mp4upload,
|
)
|
||||||
jsonservers.streamtape,
|
)
|
||||||
jsonservers.videovard
|
|
||||||
).mapNotNull {
|
|
||||||
try {
|
|
||||||
val epserver = app.get("$mainUrl/ajax/anime/episode?id=$it").text
|
|
||||||
(if (epserver.contains("url")) {
|
|
||||||
parseJson<Links>(epserver)
|
|
||||||
} else null)?.url?.let { it1 -> getLink(it1.replace("=", "")) }
|
|
||||||
?.replace("/embed/", "/e/")
|
|
||||||
} catch (e: Exception) {
|
|
||||||
logError(e)
|
|
||||||
null
|
|
||||||
}
|
}
|
||||||
}.apmap { url ->
|
} catch (e: Exception) {
|
||||||
loadExtractor(
|
logError(e)
|
||||||
url, data, callback
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,12 +228,13 @@ abstract class AbstractPlayerFragment(
|
||||||
|
|
||||||
open fun playerError(exception: Exception) {
|
open fun playerError(exception: Exception) {
|
||||||
fun showToast(message: String, gotoNext: Boolean = false) {
|
fun showToast(message: String, gotoNext: Boolean = false) {
|
||||||
if (!gotoNext || hasNextMirror()) {
|
if (gotoNext && hasNextMirror()) {
|
||||||
showToast(
|
showToast(
|
||||||
activity,
|
activity,
|
||||||
message,
|
message,
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
)
|
)
|
||||||
|
nextMirror()
|
||||||
} else {
|
} else {
|
||||||
showToast(
|
showToast(
|
||||||
activity,
|
activity,
|
||||||
|
|
|
@ -214,7 +214,6 @@ class QuickSearchFragment : Fragment() {
|
||||||
when (it) {
|
when (it) {
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
it.value.let { data ->
|
it.value.let { data ->
|
||||||
println("DATA: $data")
|
|
||||||
(quick_search_autofit_results?.adapter as? SearchAdapter?)?.updateList(
|
(quick_search_autofit_results?.adapter as? SearchAdapter?)?.updateList(
|
||||||
data
|
data
|
||||||
)
|
)
|
||||||
|
|
|
@ -169,7 +169,6 @@ suspend fun loadExtractor(
|
||||||
for (extractor in extractorApis) {
|
for (extractor in extractorApis) {
|
||||||
if (url.startsWith(extractor.mainUrl)) {
|
if (url.startsWith(extractor.mainUrl)) {
|
||||||
return extractor.getSafeUrl(url, referer) ?: emptyList()
|
return extractor.getSafeUrl(url, referer) ?: emptyList()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return emptyList()
|
return emptyList()
|
||||||
|
|
Loading…
Reference in a new issue