[RU]GroupLe add "No auth" message and AllHentai domain switcher (#13498)

* [RU]GroupLe add "No auth" message and AllHentai domain switcher

* auto redirectable domain

* fix pars breaked image text

* change redirect Exception massage
This commit is contained in:
Yjin 2022-09-19 18:39:02 +05:00 committed by GitHub
parent 2d31ba573a
commit 1df19dcf90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 6 deletions

View File

@ -1,16 +1,29 @@
package eu.kanade.tachiyomi.extension.ru.allhentai
import android.app.Application
import android.content.SharedPreferences
import android.widget.Toast
import androidx.preference.EditTextPreference
import eu.kanade.tachiyomi.multisrc.grouple.GroupLe
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import okhttp3.Request
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class AllHentai : GroupLe("AllHentai", "http://23.allhen.online", "ru") {
class AllHentai : GroupLe("AllHentai", "http://allhen.online", "ru") {
override val id: Long = 1809051393403180443
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 fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val url = super.searchMangaRequest(page, query, filters).url.newBuilder()
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
@ -253,4 +266,30 @@ class AllHentai : GroupLe("AllHentai", "http://23.allhen.online", "ru") {
private val tagsName = getTagsList().map {
it.name
}.toTypedArray()
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 {
private const val DOMAIN_TITLE = "Домен"
private const val DOMAIN_DEFAULT = "http://allhen.online"
}
}

View File

@ -49,7 +49,7 @@ abstract class GroupLe(
val originalRequest = chain.request()
val response = chain.proceed(originalRequest)
if (originalRequest.url.toString().contains(baseUrl) and (originalRequest.url.toString().contains("internal/redirect") or (response.code == 301)))
throw IOException("Манга переехала на другой адрес/ссылку!")
throw IOException("Ссылка на мангу была изменена. Перемегрируйте мангу на тотже (или смежный с GroupLe) источник или передабавте из Поисковика/Каталога.")
response
}
.build()
@ -186,7 +186,7 @@ abstract class GroupLe(
override fun chapterListSelector() = "div.chapters-link > table > tbody > tr:has(td > a):has(td.date:not(.text-info))"
private fun chapterFromElement(element: Element, manga: SManga): SChapter {
val urlElement = element.select("a").first()
val urlElement = element.select("a.chapter-link").first()
val chapterInf = element.select("td.item-title").first()
val urlText = urlElement.text()
@ -249,7 +249,14 @@ abstract class GroupLe(
override fun pageListParse(response: Response): List<Page> {
val html = response.body!!.string()
val beginIndex = html.indexOf("rm_h.initReader( [")
val readerMark = "rm_h.initReader( ["
if (!html.contains(readerMark)) {
throw Exception("Для просмотра 18+ контента необходима авторизация через WebView")
}
val beginIndex = html.indexOf(readerMark)
val endIndex = html.indexOf(");", beginIndex)
val trimmedHtml = html.substring(beginIndex, endIndex)

View File

@ -9,12 +9,12 @@ class GroupLeGenerator : ThemeSourceGenerator {
override val themeClass = "GroupLe"
override val baseVersionCode: Int = 7
override val baseVersionCode: Int = 8
override val sources = listOf(
SingleLang("ReadManga", "https://readmanga.live", "ru", overrideVersionCode = 46),
SingleLang("MintManga", "https://mintmanga.live", "ru", overrideVersionCode = 46),
SingleLang("AllHentai", "http://23.allhen.online", "ru", isNsfw = true, overrideVersionCode = 22),
SingleLang("AllHentai", "http://allhen.online", "ru", isNsfw = true, overrideVersionCode = 22),
SingleLang("SelfManga", "https://selfmanga.live", "ru", overrideVersionCode = 22),
SingleLang("RuMIX", "https://rumix.me", "ru", overrideVersionCode = 1)
)