Aniwave: Empty video list fixed

* removed custom encryption/decryption keys option

* fully removed custom encryption/decryption keys

* updated new video server names

* add invalid hoster preferences solution

* updated extVersionCode to 72
This commit is contained in:
Josef František Straka 2024-07-31 05:10:58 +02:00 committed by GitHub
parent 7615210b7f
commit fd8a01f3ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 62 deletions

View file

@ -1,7 +1,7 @@
ext { ext {
extName = 'Aniwave' extName = 'Aniwave'
extClass = '.Aniwave' extClass = '.Aniwave'
extVersionCode = 71 extVersionCode = 72
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View file

@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.animeextension.en.nineanime
import android.app.Application import android.app.Application
import android.content.SharedPreferences import android.content.SharedPreferences
import android.widget.Toast import android.widget.Toast
import androidx.preference.EditTextPreference
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.MultiSelectListPreference import androidx.preference.MultiSelectListPreference
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
@ -90,7 +89,7 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request { override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
val filters = AniwaveFilters.getSearchParameters(filters) val filters = AniwaveFilters.getSearchParameters(filters)
val vrf = if (query.isNotBlank()) utils.vrfEncrypt(getEncryptionKey(), query) else "" val vrf = if (query.isNotBlank()) utils.vrfEncrypt(KEY_ENCRYPT, query) else ""
var url = "$baseUrl/filter?keyword=$query" var url = "$baseUrl/filter?keyword=$query"
if (filters.genre.isNotBlank()) url += filters.genre if (filters.genre.isNotBlank()) url += filters.genre
@ -140,7 +139,7 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override fun episodeListRequest(anime: SAnime): Request { override fun episodeListRequest(anime: SAnime): Request {
val id = client.newCall(GET(baseUrl + anime.url)).execute().asJsoup() val id = client.newCall(GET(baseUrl + anime.url)).execute().asJsoup()
.selectFirst("div[data-id]")!!.attr("data-id") .selectFirst("div[data-id]")!!.attr("data-id")
val vrf = utils.vrfEncrypt(getEncryptionKey(), id) val vrf = utils.vrfEncrypt(KEY_ENCRYPT, id)
val listHeaders = headers.newBuilder().apply { val listHeaders = headers.newBuilder().apply {
add("Accept", "application/json, text/javascript, */*; q=0.01") add("Accept", "application/json, text/javascript, */*; q=0.01")
@ -196,7 +195,7 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override fun videoListRequest(episode: SEpisode): Request { override fun videoListRequest(episode: SEpisode): Request {
val ids = episode.url.substringBefore("&") val ids = episode.url.substringBefore("&")
val vrf = utils.vrfEncrypt(getEncryptionKey(), ids) val vrf = utils.vrfEncrypt(KEY_ENCRYPT, ids)
val url = "/ajax/server/list/$ids?vrf=$vrf" val url = "/ajax/server/list/$ids?vrf=$vrf"
val epurl = episode.url.substringAfter("epurl=") val epurl = episode.url.substringAfter("epurl=")
@ -218,7 +217,7 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override fun videoListParse(response: Response): List<Video> { override fun videoListParse(response: Response): List<Video> {
val epurl = response.request.url.fragment!! val epurl = response.request.url.fragment!!
val document = response.parseAs<ResultResponse>().toDocument() val document = response.parseAs<ResultResponse>().toDocument()
val hosterSelection = preferences.getStringSet(PREF_HOSTER_KEY, PREF_HOSTER_DEFAULT)!! val hosterSelection = getHosters()
val typeSelection = preferences.getStringSet(PREF_TYPE_TOGGLE_KEY, PREF_TYPES_TOGGLE_DEFAULT)!! val typeSelection = preferences.getStringSet(PREF_TYPE_TOGGLE_KEY, PREF_TYPES_TOGGLE_DEFAULT)!!
return document.select("div.servers > div").parallelFlatMapBlocking { elem -> return document.select("div.servers > div").parallelFlatMapBlocking { elem ->
@ -249,7 +248,7 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private val mp4uploadExtractor by lazy { Mp4uploadExtractor(client) } private val mp4uploadExtractor by lazy { Mp4uploadExtractor(client) }
private fun extractVideo(server: VideoData, epUrl: String): List<Video> { private fun extractVideo(server: VideoData, epUrl: String): List<Video> {
val vrf = utils.vrfEncrypt(getEncryptionKey(), server.serverId) val vrf = utils.vrfEncrypt(KEY_ENCRYPT, server.serverId)
val listHeaders = headers.newBuilder().apply { val listHeaders = headers.newBuilder().apply {
add("Accept", "application/json, text/javascript, */*; q=0.01") add("Accept", "application/json, text/javascript, */*; q=0.01")
@ -264,18 +263,14 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
return runCatching { return runCatching {
val parsed = response.parseAs<ServerResponse>() val parsed = response.parseAs<ServerResponse>()
val embedLink = utils.vrfDecrypt(getDecryptionKey(), parsed.result.url) val embedLink = utils.vrfDecrypt(KEY_DECRYPT, parsed.result.url)
when (server.serverName) { when (server.serverName) {
"Vidstream", "Megaf" -> { "vidstream", "megaf" -> {
val hosterName = when (server.serverName) { vidsrcExtractor.videosFromUrl(embedLink, server.serverName, server.type)
"Vidstream" -> "Vidstream"
else -> "Megaf"
} }
vidsrcExtractor.videosFromUrl(embedLink, hosterName, server.type) "moonf" -> filemoonExtractor.videosFromUrl(embedLink, "MoonF - ${server.type} - ")
}
"filemoon" -> filemoonExtractor.videosFromUrl(embedLink, "Filemoon - ${server.type} - ")
"streamtape" -> streamtapeExtractor.videoFromUrl(embedLink, "StreamTape - ${server.type}")?.let(::listOf) ?: emptyList() "streamtape" -> streamtapeExtractor.videoFromUrl(embedLink, "StreamTape - ${server.type}")?.let(::listOf) ?: emptyList()
"mp4upload" -> mp4uploadExtractor.videosFromUrl(embedLink, headers, suffix = " - ${server.type}") "mp4u" -> mp4uploadExtractor.videosFromUrl(embedLink, headers, suffix = " - ${server.type}")
else -> emptyList() else -> emptyList()
} }
}.getOrElse { emptyList() } }.getOrElse { emptyList() }
@ -313,20 +308,23 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
} }
} }
private fun getDecryptionKey(): String { private fun getHosters(): Set<String> {
var prefKey = preferences.getString(PREF_VERIFY_KEY_DECRYPT_KEY, null) val hosterSelection = preferences.getStringSet(PREF_HOSTER_KEY, PREF_HOSTER_DEFAULT)!!
if (prefKey.isNullOrBlank()) { var invalidRecord = false
prefKey = PREF_VERIFY_KEY_DECRYPT_VALUE hosterSelection.forEach { str ->
val index = HOSTERS_NAMES.indexOf(str)
if (index == -1) {
invalidRecord = true
} }
return prefKey
} }
private fun getEncryptionKey(): String { // found invalid record, reset to defaults
var prefKey = preferences.getString(PREF_VERIFY_KEY_ENCRYPT_KEY, null) if (invalidRecord) {
if (prefKey.isNullOrBlank()) { preferences.edit().putStringSet(PREF_HOSTER_KEY, PREF_HOSTER_DEFAULT).apply()
prefKey = PREF_VERIFY_KEY_ENCRYPT_VALUE return PREF_HOSTER_DEFAULT.toSet()
} }
return prefKey
return hosterSelection.toSet()
} }
companion object { companion object {
@ -356,16 +354,16 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private val HOSTERS = arrayOf( private val HOSTERS = arrayOf(
"Vidstream", "Vidstream",
"Megaf", "Megaf",
"Filemoon", "MoonF",
"StreamTape", "StreamTape",
"Mp4Upload", "MP4u",
) )
private val HOSTERS_NAMES = arrayOf( private val HOSTERS_NAMES = arrayOf(
"Vidstream", "vidstream",
"Megaf", "megaf",
"filemoon", "moonf",
"streamtape", "streamtape",
"mp4upload", "mp4u",
) )
private val PREF_HOSTER_DEFAULT = HOSTERS_NAMES.toSet() private val PREF_HOSTER_DEFAULT = HOSTERS_NAMES.toSet()
@ -374,16 +372,16 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private val PREF_TYPES_TOGGLE_DEFAULT = TYPES.toSet() private val PREF_TYPES_TOGGLE_DEFAULT = TYPES.toSet()
// https://rowdy-avocado.github.io/multi-keys/ // https://rowdy-avocado.github.io/multi-keys/
private const val PREF_VERIFY_KEY_DECRYPT_KEY = "verify_key_decrypt" private const val KEY_DECRYPT = "ctpAbOz5u7S6OMkx"
private const val PREF_VERIFY_KEY_DECRYPT_VALUE = "ctpAbOz5u7S6OMkx" private const val KEY_ENCRYPT = "p01EDKu734HJP1Tm"
private const val PREF_VERIFY_KEY_ENCRYPT_KEY = "verify_key_encrypt"
private const val PREF_VERIFY_KEY_ENCRYPT_VALUE = "p01EDKu734HJP1Tm"
} }
// ============================== Settings ============================== // ============================== Settings ==============================
override fun setupPreferenceScreen(screen: PreferenceScreen) { override fun setupPreferenceScreen(screen: PreferenceScreen) {
// validate hosters preferences and if invalid reset
getHosters()
ListPreference(screen.context).apply { ListPreference(screen.context).apply {
key = PREF_DOMAIN_KEY key = PREF_DOMAIN_KEY
title = "Preferred domain" title = "Preferred domain"
@ -484,29 +482,5 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
preferences.edit().putStringSet(key, newValue as Set<String>).commit() preferences.edit().putStringSet(key, newValue as Set<String>).commit()
} }
}.also(screen::addPreference) }.also(screen::addPreference)
EditTextPreference(screen.context).apply {
key = PREF_VERIFY_KEY_DECRYPT_KEY
title = "Custom decryption key"
setDefaultValue("")
setOnPreferenceChangeListener { _, newValue ->
@Suppress("UNCHECKED_CAST")
val newKey = newValue as String
preferences.edit().putString(key, newKey).commit()
}
}.also(screen::addPreference)
EditTextPreference(screen.context).apply {
key = PREF_VERIFY_KEY_ENCRYPT_KEY
title = "Custom encryption key"
setDefaultValue("")
setOnPreferenceChangeListener { _, newValue ->
@Suppress("UNCHECKED_CAST")
val newKey = newValue as String
preferences.edit().putString(key, newKey).commit()
}
}.also(screen::addPreference)
} }
} }