feat(en/aniwatch): Update domains (#1854)
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'AniWatch.to'
|
extName = 'AniWatch.to'
|
||||||
pkgNameSuffix = 'en.zoro'
|
pkgNameSuffix = 'en.zoro'
|
||||||
extClass = '.AniWatch'
|
extClass = '.AniWatch'
|
||||||
extVersionCode = 31
|
extVersionCode = 32
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class AniWatch : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override val name = "AniWatch.to"
|
override val name = "AniWatch.to"
|
||||||
|
|
||||||
override val baseUrl = "https://aniwatch.to"
|
override val baseUrl by lazy { preferences.getString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT)!! }
|
||||||
|
|
||||||
override val id = 6706411382606718900L
|
override val id = 6706411382606718900L
|
||||||
|
|
||||||
@ -83,7 +83,9 @@ class AniWatch : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
override fun episodeListRequest(anime: SAnime): Request {
|
override fun episodeListRequest(anime: SAnime): Request {
|
||||||
val id = anime.url.substringAfterLast("-")
|
val id = anime.url.substringAfterLast("-")
|
||||||
val referer = Headers.headersOf("Referer", baseUrl + anime.url)
|
val referer = Headers.headersOf("Referer", baseUrl + anime.url)
|
||||||
return GET("$baseUrl/ajax/v2/episode/list/$id", referer)
|
val ajaxRoute = if (baseUrl == "https://kaido.to") "" else "/v2"
|
||||||
|
|
||||||
|
return GET("$baseUrl/ajax$ajaxRoute/episode/list/$id", referer)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||||
@ -111,7 +113,9 @@ class AniWatch : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
override fun videoListRequest(episode: SEpisode): Request {
|
override fun videoListRequest(episode: SEpisode): Request {
|
||||||
val id = episode.url.substringAfterLast("?ep=")
|
val id = episode.url.substringAfterLast("?ep=")
|
||||||
val referer = Headers.headersOf("Referer", baseUrl + episode.url)
|
val referer = Headers.headersOf("Referer", baseUrl + episode.url)
|
||||||
return GET("$baseUrl/ajax/v2/episode/servers?episodeId=$id", referer)
|
val ajaxRoute = if (baseUrl == "https://kaido.to") "" else "/v2"
|
||||||
|
|
||||||
|
return GET("$baseUrl/ajax$ajaxRoute/episode/servers?episodeId=$id", referer)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun videoListParse(response: Response): List<Video> {
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
@ -126,7 +130,9 @@ class AniWatch : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
val name = server.text()
|
val name = server.text()
|
||||||
val id = server.attr("data-id")
|
val id = server.attr("data-id")
|
||||||
val subDub = server.attr("data-type")
|
val subDub = server.attr("data-type")
|
||||||
val url = "$baseUrl/ajax/v2/episode/sources?id=$id"
|
val ajaxRoute = if (baseUrl == "https://kaido.to") "" else "/v2"
|
||||||
|
|
||||||
|
val url = "$baseUrl/ajax$ajaxRoute/episode/sources?id=$id"
|
||||||
val reqBody = client.newCall(GET(url, episodeReferer)).execute()
|
val reqBody = client.newCall(GET(url, episodeReferer)).execute()
|
||||||
.body.string()
|
.body.string()
|
||||||
val sourceUrl = reqBody.substringAfter("\"link\":\"")
|
val sourceUrl = reqBody.substringAfter("\"link\":\"")
|
||||||
@ -330,6 +336,22 @@ class AniWatch : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
// ============================== Settings ==============================
|
// ============================== Settings ==============================
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
val domainPref = ListPreference(screen.context).apply {
|
||||||
|
key = PREF_DOMAIN_KEY
|
||||||
|
title = PREF_DOMAIN_TITLE
|
||||||
|
entries = PREF_DOMAIN_ENTRIES
|
||||||
|
entryValues = PREF_DOMAIN_ENTRY_VALUES
|
||||||
|
setDefaultValue(PREF_DOMAIN_DEFAULT)
|
||||||
|
summary = "%s"
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val selected = newValue as String
|
||||||
|
val index = findIndexOfValue(selected)
|
||||||
|
val entry = entryValues[index] as String
|
||||||
|
preferences.edit().putString(key, entry).commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val videoQualityPref = ListPreference(screen.context).apply {
|
val videoQualityPref = ListPreference(screen.context).apply {
|
||||||
key = PREF_QUALITY_KEY
|
key = PREF_QUALITY_KEY
|
||||||
title = PREF_QUALITY_TITLE
|
title = PREF_QUALITY_TITLE
|
||||||
@ -387,6 +409,7 @@ class AniWatch : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screen.addPreference(domainPref)
|
||||||
screen.addPreference(videoQualityPref)
|
screen.addPreference(videoQualityPref)
|
||||||
screen.addPreference(epTypePref)
|
screen.addPreference(epTypePref)
|
||||||
screen.addPreference(subLangPref)
|
screen.addPreference(subLangPref)
|
||||||
@ -436,6 +459,12 @@ class AniWatch : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
private const val PREF_QUALITY_TITLE = "Preferred video quality"
|
private const val PREF_QUALITY_TITLE = "Preferred video quality"
|
||||||
private val PREF_QUALITY_ENTRIES = arrayOf("360p", "720p", "1080p")
|
private val PREF_QUALITY_ENTRIES = arrayOf("360p", "720p", "1080p")
|
||||||
|
|
||||||
|
private const val PREF_DOMAIN_KEY = "preferred_domain"
|
||||||
|
private const val PREF_DOMAIN_TITLE = "Preferred domain (requires app restart)"
|
||||||
|
private const val PREF_DOMAIN_DEFAULT = "https://kaido.to"
|
||||||
|
private val PREF_DOMAIN_ENTRIES = arrayOf("kaido.to", "aniwatch.to")
|
||||||
|
private val PREF_DOMAIN_ENTRY_VALUES = arrayOf("https://kaido.to", "https://aniwatch.to")
|
||||||
|
|
||||||
private const val PREF_TYPE_KEY = "preferred_type"
|
private const val PREF_TYPE_KEY = "preferred_type"
|
||||||
private const val PREF_TYPE_TITLE = "Preferred episode type/mode"
|
private const val PREF_TYPE_TITLE = "Preferred episode type/mode"
|
||||||
private val PREF_TYPE_ENTRIES = arrayOf("sub", "dub")
|
private val PREF_TYPE_ENTRIES = arrayOf("sub", "dub")
|
||||||
|
@ -17,27 +17,23 @@ class AniWatchExtractor(private val client: OkHttpClient) {
|
|||||||
.build()
|
.build()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val SERVER_URL = "https://megacloud.tv"
|
private val SERVER_URL = arrayOf("https://megacloud.tv", "https://rapid-cloud.co")
|
||||||
private const val JS_URL = SERVER_URL + "/js/player/a/prod/e1-player.min.js"
|
private val SOURCES_URL = arrayOf("/embed-2/ajax/e-1/getSources?id=", "/ajax/embed-6/getSources?id=")
|
||||||
private const val SOURCES_URL = SERVER_URL + "/embed-2/ajax/e-1/getSources?id="
|
private val SOURCES_SPLITTER = arrayOf("/e-1/", "/embed-6/")
|
||||||
|
private val SOURCES_KEY = arrayOf("6", "0")
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will create a lag of 1~3s at the initialization of the class, but the
|
|
||||||
// speedup of the manual cache will be worth it.
|
|
||||||
private val cachedJs by lazy {
|
|
||||||
newClient.newCall(GET(JS_URL, cache = cacheControl)).execute()
|
|
||||||
.body.string()
|
|
||||||
}
|
|
||||||
init { cachedJs }
|
|
||||||
|
|
||||||
fun getSourcesJson(url: String): String? {
|
fun getSourcesJson(url: String): String? {
|
||||||
val id = url.substringAfter("/e-1/", "")
|
val type = if (url.startsWith("https://megacloud.tv")) 0 else 1
|
||||||
|
val keyType = SOURCES_KEY[type]
|
||||||
|
|
||||||
|
val id = url.substringAfter(SOURCES_SPLITTER[type], "")
|
||||||
.substringBefore("?", "").ifEmpty { return null }
|
.substringBefore("?", "").ifEmpty { return null }
|
||||||
val srcRes = newClient.newCall(GET(SOURCES_URL + id, cache = cacheControl))
|
val srcRes = newClient.newCall(GET(SERVER_URL[type] + SOURCES_URL[type] + id, cache = cacheControl))
|
||||||
.execute()
|
.execute()
|
||||||
.body.string()
|
.body.string()
|
||||||
|
|
||||||
val key = newClient.newCall(GET("https://raw.githubusercontent.com/enimax-anime/key/e6/key.txt"))
|
val key = newClient.newCall(GET("https://raw.githubusercontent.com/enimax-anime/key/e$keyType/key.txt"))
|
||||||
.execute()
|
.execute()
|
||||||
.body.string()
|
.body.string()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user