[RU]LibGroup no empty series filter and custom domain switcher 18+ (#15623)
* [RU]LibGroup no empty series filter * domain * custom domain switcher 18+
This commit is contained in:
parent
a4653d812a
commit
38e7e2347a
@ -16,7 +16,7 @@
|
||||
|
||||
<!-- LibUrlActivity sites can be added here. -->
|
||||
<data
|
||||
android:host="hentailib.me"
|
||||
android:host="v1.hentailib.org"
|
||||
android:pathPattern="/..*/v..*"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
|
@ -1,5 +1,9 @@
|
||||
package eu.kanade.tachiyomi.extension.ru.hentailib
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import androidx.preference.EditTextPreference
|
||||
import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
@ -7,11 +11,20 @@ import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class HentaiLib : LibGroup("HentaiLib", "https://hentailib.me", "ru") {
|
||||
class HentaiLib : LibGroup("HentaiLib", "https://v1.hentailib.org", "ru") {
|
||||
|
||||
override val id: Long = 6425650164840473547
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
private var domain: String = preferences.getString(DOMAIN_TITLE, DOMAIN_DEFAULT)!!
|
||||
override val baseUrl: String = domain
|
||||
|
||||
override val client: OkHttpClient = super.client.newBuilder()
|
||||
.addInterceptor(::imageContentTypeIntercept)
|
||||
.build()
|
||||
@ -229,7 +242,31 @@ class HentaiLib : LibGroup("HentaiLib", "https://hentailib.me", "ru") {
|
||||
SearchFilter("Яндэрэ", "146"),
|
||||
)
|
||||
|
||||
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
|
||||
super.setupPreferenceScreen(screen)
|
||||
EditTextPreference(screen.context).apply {
|
||||
key = DOMAIN_TITLE
|
||||
this.title = DOMAIN_TITLE
|
||||
summary = domain
|
||||
this.setDefaultValue(DOMAIN_DEFAULT)
|
||||
dialogTitle = DOMAIN_TITLE
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
try {
|
||||
val res = preferences.edit().putString(DOMAIN_TITLE, newValue as String).commit()
|
||||
Toast.makeText(screen.context, "Для смены домена необходимо перезапустить приложение с полной остановкой.", Toast.LENGTH_LONG).show()
|
||||
res
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
false
|
||||
}
|
||||
}
|
||||
}.let(screen::addPreference)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PREFIX_SLUG_SEARCH = "slug:"
|
||||
|
||||
private const val DOMAIN_TITLE = "Домен"
|
||||
private const val DOMAIN_DEFAULT = "https://v1.hentailib.org"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package eu.kanade.tachiyomi.extension.ru.yaoilib
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import androidx.preference.EditTextPreference
|
||||
import eu.kanade.tachiyomi.multisrc.libgroup.LibGroup
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
@ -7,9 +11,18 @@ import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class YaoiLib : LibGroup("YaoiLib", "https://v1.slashlib.me", "ru") {
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
private var domain: String = preferences.getString(DOMAIN_TITLE, DOMAIN_DEFAULT)!!
|
||||
override val baseUrl: String = domain
|
||||
|
||||
override val client: OkHttpClient = super.client.newBuilder()
|
||||
.addInterceptor(::imageContentTypeIntercept)
|
||||
.build()
|
||||
@ -175,7 +188,31 @@ class YaoiLib : LibGroup("YaoiLib", "https://v1.slashlib.me", "ru") {
|
||||
SearchFilter("18+", "2"),
|
||||
)
|
||||
|
||||
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
|
||||
super.setupPreferenceScreen(screen)
|
||||
EditTextPreference(screen.context).apply {
|
||||
key = DOMAIN_TITLE
|
||||
this.title = DOMAIN_TITLE
|
||||
summary = domain
|
||||
this.setDefaultValue(DOMAIN_DEFAULT)
|
||||
dialogTitle = DOMAIN_TITLE
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
try {
|
||||
val res = preferences.edit().putString(DOMAIN_TITLE, newValue as String).commit()
|
||||
Toast.makeText(screen.context, "Для смены домена необходимо перезапустить приложение с полной остановкой.", Toast.LENGTH_LONG).show()
|
||||
res
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
false
|
||||
}
|
||||
}
|
||||
}.let(screen::addPreference)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PREFIX_SLUG_SEARCH = "slug:"
|
||||
|
||||
private const val DOMAIN_TITLE = "Домен"
|
||||
private const val DOMAIN_DEFAULT = "https://v1.slashlib.me"
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,11 @@ class LibGenerator : ThemeSourceGenerator {
|
||||
|
||||
override val themeClass = "LibGroup"
|
||||
|
||||
override val baseVersionCode: Int = 16
|
||||
override val baseVersionCode: Int = 17
|
||||
|
||||
override val sources = listOf(
|
||||
SingleLang("MangaLib", "https://mangalib.me", "ru", overrideVersionCode = 74),
|
||||
SingleLang("HentaiLib", "https://hentailib.me", "ru", isNsfw = true, overrideVersionCode = 19),
|
||||
SingleLang("HentaiLib", "https://v1.hentailib.org", "ru", isNsfw = true, overrideVersionCode = 19),
|
||||
SingleLang("YaoiLib", "https://v1.slashlib.me", "ru", isNsfw = true, overrideVersionCode = 2),
|
||||
)
|
||||
|
||||
|
@ -129,7 +129,7 @@ abstract class LibGroup(
|
||||
}
|
||||
|
||||
private fun fetchLatestMangaFromApi(page: Int): Observable<MangasPage> {
|
||||
return client.newCall(POST("$baseUrl/filterlist?dir=desc&sort=last_chapter_at&page=$page", catalogHeaders()))
|
||||
return client.newCall(POST("$baseUrl/filterlist?dir=desc&sort=last_chapter_at&page=$page&chapters[min]=1", catalogHeaders()))
|
||||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
latestUpdatesParse(response)
|
||||
@ -156,7 +156,7 @@ abstract class LibGroup(
|
||||
}
|
||||
|
||||
private fun fetchPopularMangaFromApi(page: Int): Observable<MangasPage> {
|
||||
return client.newCall(POST("$baseUrl/filterlist?dir=desc&sort=views&page=$page", catalogHeaders()))
|
||||
return client.newCall(POST("$baseUrl/filterlist?dir=desc&sort=views&page=$page&chapters[min]=1", catalogHeaders()))
|
||||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
popularMangaParse(response)
|
||||
@ -539,7 +539,7 @@ abstract class LibGroup(
|
||||
val resBody = tokenResponse.body.string()
|
||||
csrfToken = "_token\" content=\"(.*)\"".toRegex().find(resBody)!!.groups[1]!!.value
|
||||
}
|
||||
val url = "$baseUrl/filterlist?page=$page".toHttpUrlOrNull()!!.newBuilder()
|
||||
val url = "$baseUrl/filterlist?page=$page&chapters[min]=1".toHttpUrlOrNull()!!.newBuilder()
|
||||
if (query.isNotEmpty()) {
|
||||
url.addQueryParameter("name", query)
|
||||
}
|
||||
@ -579,6 +579,11 @@ abstract class LibGroup(
|
||||
url.addQueryParameter(if (favorite.isIncluded()) "bookmarks[include][]" else "bookmarks[exclude][]", favorite.id)
|
||||
}
|
||||
}
|
||||
is RequireChapters -> {
|
||||
if (filter.state == 1) {
|
||||
url.setQueryParameter("chapters[min]", "0")
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@ -606,6 +611,7 @@ abstract class LibGroup(
|
||||
StatusList(getStatusList()),
|
||||
StatusTitleList(getStatusTitleList()),
|
||||
MyList(getMyList()),
|
||||
RequireChapters(),
|
||||
)
|
||||
|
||||
private class OrderBy : Filter.Sort(
|
||||
@ -701,6 +707,12 @@ abstract class LibGroup(
|
||||
SearchFilter("Прочитано", "4"),
|
||||
SearchFilter("Любимые", "5"),
|
||||
)
|
||||
|
||||
private class RequireChapters : Filter.Select<String>(
|
||||
"Только проекты с главами",
|
||||
arrayOf("Да", "Все"),
|
||||
)
|
||||
|
||||
companion object {
|
||||
const val PREFIX_SLUG_SEARCH = "slug:"
|
||||
private const val SERVER_PREF = "MangaLibImageServer"
|
||||
|
Loading…
x
Reference in New Issue
Block a user