feat(multisrc/zorotheme): Force clear outdated hosts (#3043)
This commit is contained in:
parent
6f85b879ee
commit
c61a4478cc
@ -2,7 +2,7 @@ plugins {
|
||||
id("lib-multisrc")
|
||||
}
|
||||
|
||||
baseVersionCode = 1
|
||||
baseVersionCode = 2
|
||||
|
||||
dependencies {
|
||||
api(project(":lib:megacloud-extractor"))
|
||||
|
@ -36,6 +36,7 @@ abstract class ZoroTheme(
|
||||
override val lang: String,
|
||||
override val name: String,
|
||||
override val baseUrl: String,
|
||||
private val hosterNames: List<String>,
|
||||
) : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||
|
||||
override val supportsLatest = true
|
||||
@ -44,6 +45,7 @@ abstract class ZoroTheme(
|
||||
|
||||
val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
.clearOldHosts()
|
||||
}
|
||||
|
||||
private val docHeaders = headers.newBuilder().apply {
|
||||
@ -54,8 +56,6 @@ abstract class ZoroTheme(
|
||||
|
||||
protected open val ajaxRoute = ""
|
||||
|
||||
abstract val hosterNames: List<String>
|
||||
|
||||
private val useEnglish by lazy { preferences.getTitleLang == "English" }
|
||||
private val markFiller by lazy { preferences.markFiller }
|
||||
|
||||
@ -238,9 +238,7 @@ abstract class ZoroTheme(
|
||||
return embedLinks.parallelCatchingFlatMap(::extractVideo)
|
||||
}
|
||||
|
||||
protected open fun extractVideo(server: VideoData): List<Video> {
|
||||
return emptyList()
|
||||
}
|
||||
abstract fun extractVideo(server: VideoData): List<Video>
|
||||
|
||||
override fun videoListSelector() = throw UnsupportedOperationException()
|
||||
|
||||
@ -249,6 +247,21 @@ abstract class ZoroTheme(
|
||||
override fun videoUrlParse(document: Document) = throw UnsupportedOperationException()
|
||||
|
||||
// ============================= Utilities ==============================
|
||||
|
||||
private fun SharedPreferences.clearOldHosts(): SharedPreferences {
|
||||
if (hostToggle.all { hosterNames.contains(it) }) {
|
||||
return this
|
||||
}
|
||||
|
||||
edit()
|
||||
.remove(PREF_HOSTER_KEY)
|
||||
.putStringSet(PREF_HOSTER_KEY, hosterNames.toSet())
|
||||
.remove(PREF_SERVER_KEY)
|
||||
.putString(PREF_SERVER_KEY, hosterNames.first())
|
||||
.apply()
|
||||
return this
|
||||
}
|
||||
|
||||
private fun Set<String>.contains(s: String, ignoreCase: Boolean): Boolean {
|
||||
return any { it.equals(s, ignoreCase) }
|
||||
}
|
||||
|
@ -9,13 +9,12 @@ class Kaido : ZoroTheme(
|
||||
"en",
|
||||
"Kaido",
|
||||
"https://kaido.to",
|
||||
) {
|
||||
override val hosterNames: List<String> = listOf(
|
||||
hosterNames = listOf(
|
||||
"Vidstreaming",
|
||||
"Vidcloud",
|
||||
"StreamTape",
|
||||
)
|
||||
|
||||
),
|
||||
) {
|
||||
private val streamtapeExtractor by lazy { StreamTapeExtractor(client) }
|
||||
private val megaCloudExtractor by lazy { MegaCloudExtractor(client, headers, preferences) }
|
||||
|
||||
|
@ -9,17 +9,16 @@ class HiAnime : ZoroTheme(
|
||||
"en",
|
||||
"HiAnime",
|
||||
"https://hianime.to",
|
||||
hosterNames = listOf(
|
||||
"HD-1",
|
||||
"HD-2",
|
||||
"StreamTape",
|
||||
),
|
||||
) {
|
||||
override val id = 6706411382606718900L
|
||||
|
||||
override val ajaxRoute = "/v2"
|
||||
|
||||
override val hosterNames: List<String> = listOf(
|
||||
"HD-1",
|
||||
"HD-2",
|
||||
"StreamTape",
|
||||
)
|
||||
|
||||
private val streamtapeExtractor by lazy { StreamTapeExtractor(client) }
|
||||
private val megaCloudExtractor by lazy { MegaCloudExtractor(client, headers, preferences) }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user