Added Support for Bato.to Mirrors (#10137)

* Update AndroidManifest.xml

* Update BatoToUrlActivity.kt

* Added Mirror Support

* Update build.gradle

* Added missing url path
This commit is contained in:
jopejoe1 2021-12-20 01:04:44 +13:00 committed by GitHub
parent 1acab4972f
commit 74ef573bd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 7 deletions

View File

@ -14,10 +14,23 @@ package="eu.kanade.tachiyomi.extension">
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:host="*.bato.to" />
<data android:host="bato.to" />
<data android:host="*.batotoo.com" />
<data android:host="batotoo.com" />
<data android:host="*.comiko.net" />
<data android:host="comiko.net" />
<data android:host="*.battwo.com" />
<data android:host="battwo.com" />
<data android:host="*.mangatoto.com" />
<data android:host="mangatoto.com" />
<data <data
android:host="bato.to"
android:pathPattern="/series/..*" android:pathPattern="/series/..*"
android:scheme="https" /> android:scheme="https" />
<data
android:pathPattern="/subject-overview/..*"
android:scheme="https" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>

View File

@ -6,7 +6,7 @@ ext {
extName = 'Bato.to' extName = 'Bato.to'
pkgNameSuffix = 'all.batoto' pkgNameSuffix = 'all.batoto'
extClass = '.BatoToFactory' extClass = '.BatoToFactory'
extVersionCode = 15 extVersionCode = 16
isNsfw = true isNsfw = true
} }

View File

@ -1,8 +1,13 @@
package eu.kanade.tachiyomi.extension.all.batoto package eu.kanade.tachiyomi.extension.all.batoto
import android.app.Application
import android.content.SharedPreferences
import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen
import com.squareup.duktape.Duktape import com.squareup.duktape.Duktape
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.MangasPage
@ -22,6 +27,8 @@ import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import org.jsoup.parser.Parser import org.jsoup.parser.Parser
import rx.Observable import rx.Observable
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.util.Calendar import java.util.Calendar
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -29,10 +36,43 @@ import java.util.concurrent.TimeUnit
open class BatoTo( open class BatoTo(
override val lang: String, override val lang: String,
private val siteLang: String private val siteLang: String
) : ParsedHttpSource() { ) : ConfigurableSource, ParsedHttpSource() {
private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}
override val name: String = "Bato.to" override val name: String = "Bato.to"
override val baseUrl: String = "https://bato.to" override val baseUrl: String = getResolutionPref()!!
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val mirrorPref = ListPreference(screen.context).apply {
key = "${MIRROR_PREF_KEY}_$lang"
title = MIRROR_PREF_TITLE
entries = MIRROR_PREF_ENTRIES
entryValues = MIRROR_PREF_ENTRY_VALUES
setDefaultValue(MIRROR_PREF_DEFAULT_VALUE)
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
preferences.edit().putString("${MIRROR_PREF_KEY}_$lang", entry).commit()
}
}
screen.addPreference(mirrorPref)
}
private fun getResolutionPref(): String? = preferences.getString("${MIRROR_PREF_KEY}_$lang", MIRROR_PREF_DEFAULT_VALUE)
companion object {
private const val MIRROR_PREF_KEY = "MIRROR"
private const val MIRROR_PREF_TITLE = "Mirror"
private val MIRROR_PREF_ENTRIES = arrayOf("Bato.to", "Batotoo.com", "Comiko.net", "Battwo.com", "Mangatoto.com")
private val MIRROR_PREF_ENTRY_VALUES = arrayOf("https://bato.to", "https://batotoo.com", "https://comiko.net", "https://battwo.com", "https://mangatoto.com")
private val MIRROR_PREF_DEFAULT_VALUE = MIRROR_PREF_ENTRY_VALUES[0]
}
override val supportsLatest = true override val supportsLatest = true
private val json: Json by injectLazy() private val json: Json by injectLazy()

View File

@ -15,7 +15,7 @@ class BatoToUrlActivity : Activity() {
val pathSegments = intent?.data?.pathSegments val pathSegments = intent?.data?.pathSegments
if (host != null && pathSegments != null) { if (host != null && pathSegments != null) {
val query = fromGuya(pathSegments) val query = fromBatoTo(pathSegments)
if (query == null) { if (query == null) {
Log.e("BatoToUrlActivity", "Unable to parse URI from intent $intent") Log.e("BatoToUrlActivity", "Unable to parse URI from intent $intent")
@ -40,7 +40,7 @@ class BatoToUrlActivity : Activity() {
exitProcess(0) exitProcess(0)
} }
private fun fromGuya(pathSegments: MutableList<String>): String? { private fun fromBatoTo(pathSegments: MutableList<String>): String? {
return if (pathSegments.size >= 2) { return if (pathSegments.size >= 2) {
val id = pathSegments[1] val id = pathSegments[1]
"ID:$id" "ID:$id"