fix(en/9anime): Switch from Consumet's 9anime API (#1722)

This commit is contained in:
enimax-anime
2023-06-13 12:51:46 -07:00
committed by GitHub
parent 12059855c0
commit bab58afbc0
5 changed files with 41 additions and 14 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'FMovies'
pkgNameSuffix = 'en.fmovies'
extClass = '.FMovies'
extVersionCode = 2
extVersionCode = 3
libVersion = '13'
}

View File

@ -249,10 +249,11 @@ class FMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
)
val vidId = decrypted.substringAfterLast("/").substringBefore("?")
val (serverName, action) = when (name) {
"Vidstream" -> Pair("Vidstream", "vizcloud")
"MyCloud" -> Pair("MyCloud", "mcloud")
"Vidstream" -> Pair("Vidstream", "rawVizcloud")
"MyCloud" -> Pair("MyCloud", "rawMcloud")
else -> return@parallelMap null
}
val playlistUrl = callConsumet(vidId, action)
val playlist = client.newCall(GET(playlistUrl, embedReferer)).execute()
@ -289,11 +290,19 @@ class FMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private fun callConsumet(query: String, action: String): String {
return client.newCall(
GET("https://api.consumet.org/anime/9anime/helper?query=$query&action=$action"),
GET("https://9anime.eltik.net/$action?query=$query&apikey=aniyomi"),
).execute().body.string().let {
when (action) {
"vizcloud", "mcloud" -> {
it.substringAfter("file\":\"").substringBefore("\"")
"rawVizcloud", "rawMcloud" -> {
val rawURL = json.decodeFromString<RawResponse>(it).rawURL
val referer = if (action == "rawVizcloud") "https://vidstream.pro/" else "https://mcloud.to/"
val apiResponse = client.newCall(
GET(
url = rawURL,
headers = Headers.headersOf("Referer", referer),
),
).execute().body.string()
apiResponse.substringAfter("file\":\"").substringBefore("\"")
}
"fmovies-decrypt" -> {
json.decodeFromString<VrfResponse>(it).url
@ -411,7 +420,6 @@ class FMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private const val PREF_HOSTER_TITLE = "Enable/Disable Hosts"
private val PREF_HOSTER_DEFAULT = setOf("Vidstream", "Filemoon")
}
// ============================== Settings ==============================
override fun setupPreferenceScreen(screen: PreferenceScreen) {

View File

@ -34,3 +34,8 @@ data class FMoviesSubs(
val file: String,
val label: String,
)
@Serializable
data class RawResponse(
val rawURL: String,
)

View File

@ -6,7 +6,7 @@ ext {
extName = '9anime'
pkgNameSuffix = 'en.nineanime'
extClass = '.NineAnime'
extVersionCode = 43
extVersionCode = 44
libVersion = '13'
}

View File

@ -104,7 +104,7 @@ class NineAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
throw Exception("Not used")
private fun searchAnimeRequest(page: Int, query: String, filters: NineAnimeFilters.FilterSearchParams): Request {
val vrf = if (query.isNotBlank()) callConsumet(query, "searchVrf") else ""
val vrf = if (query.isNotBlank()) callConsumet(query, "vrf") else ""
var url = "$baseUrl/filter?keyword=$query"
if (filters.genre.isNotBlank()) url += filters.genre
@ -282,8 +282,8 @@ class NineAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
)
val vidId = embedLink.substringAfterLast("/").substringBefore("?")
val (serverName, action) = when (server.third) {
"vidstream" -> Pair("Vidstream", "vizcloud")
"mycloud" -> Pair("MyCloud", "mcloud")
"vidstream" -> Pair("Vidstream", "rawVizcloud")
"mycloud" -> Pair("MyCloud", "rawMcloud")
else -> return emptyList()
}
val playlistUrl = callConsumet(vidId, action)
@ -333,11 +333,20 @@ class NineAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private fun callConsumet(query: String, action: String): String {
return client.newCall(
GET("https://api.consumet.org/anime/9anime/helper?query=$query&action=$action"),
GET("https://9anime.eltik.net/$action?query=$query&apikey=aniyomi"),
).execute().body.string().let {
when (action) {
"vizcloud", "mcloud" -> {
it.substringAfter("file\":\"").substringBefore("\"")
"rawVizcloud", "rawMcloud" -> {
val rawURL = json.decodeFromString<RawResponse>(it).rawURL
val referer = if (action == "rawVizcloud") "https://vidstream.pro/" else "https://mcloud.to/"
val apiResponse = client.newCall(
GET(
url = rawURL,
headers = Headers.headersOf("Referer", referer),
),
).execute().body.string()
apiResponse.substringAfter("file\":\"").substringBefore("\"")
}
"decrypt" -> {
json.decodeFromString<VrfResponse>(it).url
@ -389,6 +398,11 @@ class NineAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val vrfQuery: String? = null,
)
@Serializable
data class RawResponse(
val rawURL: String,
)
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val domainPref = ListPreference(screen.context).apply {
key = "preferred_domain"