Add domain switcher XXManhwa, TruyenVn, SayHentai & Fix author TruyenGG (#6157)

* Add url change feature XXManhwa, TruyenVn, SayHentai

* Fix author Truyengg

* Fix truyenvn
This commit is contained in:
are-are-are 2024-11-20 16:16:56 +07:00 committed by Draff
parent ea99590719
commit bcf57d6f73
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
8 changed files with 162 additions and 19 deletions

View File

@ -3,7 +3,7 @@ ext {
extClass = ".SayHentai"
themePkg = "manhwaz"
baseUrl = "https://sayhentai.art"
overrideVersionCode = 8
overrideVersionCode = 9
isNsfw = true
}

View File

@ -1,13 +1,66 @@
package eu.kanade.tachiyomi.extension.vi.sayhentai
import android.app.Application
import android.content.SharedPreferences
import android.widget.Toast
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.multisrc.manhwaz.ManhwaZ
import eu.kanade.tachiyomi.source.ConfigurableSource
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class SayHentai : ManhwaZ(
class SayHentai :
ManhwaZ(
"SayHentai",
"https://sayhentai.art",
"vi",
mangaDetailsAuthorHeading = "Tác giả",
mangaDetailsStatusHeading = "Trạng thái",
) {
),
ConfigurableSource {
override fun popularMangaSelector() = "#slide-top > .item:contains(a)"
private val preferences: SharedPreferences =
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
init {
preferences.getString(DEFAULT_BASE_URL_PREF, null).let { prefDefaultBaseUrl ->
if (prefDefaultBaseUrl != super.baseUrl) {
preferences.edit()
.putString(BASE_URL_PREF, super.baseUrl)
.putString(DEFAULT_BASE_URL_PREF, super.baseUrl)
.apply()
}
}
}
override val baseUrl by lazy { getPrefBaseUrl() }
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val baseUrlPref = androidx.preference.EditTextPreference(screen.context).apply {
key = BASE_URL_PREF
title = BASE_URL_PREF_TITLE
summary = BASE_URL_PREF_SUMMARY
setDefaultValue(super.baseUrl)
dialogTitle = BASE_URL_PREF_TITLE
dialogMessage = "Default: ${super.baseUrl}"
setOnPreferenceChangeListener { _, _ ->
Toast.makeText(screen.context, RESTART_APP, Toast.LENGTH_LONG).show()
true
}
}
screen.addPreference(baseUrlPref)
}
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, super.baseUrl)!!
companion object {
private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl"
private const val RESTART_APP = "Khởi chạy lại ứng dụng để áp dụng thay đổi."
private const val BASE_URL_PREF_TITLE = "Ghi đè URL cơ sở"
private const val BASE_URL_PREF = "overrideBaseUrl"
private const val BASE_URL_PREF_SUMMARY =
"Dành cho sử dụng tạm thời, cập nhật tiện ích sẽ xóa cài đặt."
}
}

View File

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

View File

@ -81,7 +81,7 @@ class TruyenGG : ParsedHttpSource(), ConfigurableSource {
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
title = document.select("h1[itemprop=name]").text()
author = document.select("p:contains(Tác Giả) + p").joinToString { it.text() }
author = document.selectFirst("p:contains(Tác Giả) + p")?.text()
genre = document.select("a.clblue").joinToString { it.text() }
description = document.select("div.story-detail-info").text().trim()
thumbnail_url = document.selectFirst(".thumbblock img")!!.attr("abs:src")

View File

@ -3,7 +3,7 @@ ext {
extClass = '.TruyenVN'
themePkg = 'madara'
baseUrl = 'https://truyenvn.vin'
overrideVersionCode = 7
overrideVersionCode = 8
isNsfw = true
}

View File

@ -1,17 +1,70 @@
package eu.kanade.tachiyomi.extension.vi.truyenvn
import android.app.Application
import android.content.SharedPreferences
import android.widget.Toast
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.multisrc.madara.Madara
import eu.kanade.tachiyomi.source.ConfigurableSource
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.text.SimpleDateFormat
import java.util.Locale
class TruyenVN : Madara(
class TruyenVN :
Madara(
"TruyenVN",
"https://truyenvn.vin",
"vi",
dateFormat = SimpleDateFormat("dd/MM/yyyy", Locale.ROOT),
) {
),
ConfigurableSource {
override val useLoadMoreRequest = LoadMoreStrategy.Never
override val useNewChapterEndpoint = true
override val mangaSubString = "truyen-tranh"
private val preferences: SharedPreferences =
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
init {
preferences.getString(DEFAULT_BASE_URL_PREF, null).let { prefDefaultBaseUrl ->
if (prefDefaultBaseUrl != super.baseUrl) {
preferences.edit()
.putString(BASE_URL_PREF, super.baseUrl)
.putString(DEFAULT_BASE_URL_PREF, super.baseUrl)
.apply()
}
}
}
override val baseUrl by lazy { getPrefBaseUrl() }
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val baseUrlPref = androidx.preference.EditTextPreference(screen.context).apply {
key = BASE_URL_PREF
title = BASE_URL_PREF_TITLE
summary = BASE_URL_PREF_SUMMARY
setDefaultValue(super.baseUrl)
dialogTitle = BASE_URL_PREF_TITLE
dialogMessage = "Default: ${super.baseUrl}"
setOnPreferenceChangeListener { _, _ ->
Toast.makeText(screen.context, RESTART_APP, Toast.LENGTH_LONG).show()
true
}
}
screen.addPreference(baseUrlPref)
}
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, super.baseUrl)!!
companion object {
private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl"
private const val RESTART_APP = "Khởi chạy lại ứng dụng để áp dụng thay đổi."
private const val BASE_URL_PREF_TITLE = "Ghi đè URL cơ sở"
private const val BASE_URL_PREF = "overrideBaseUrl"
private const val BASE_URL_PREF_SUMMARY =
"Dành cho sử dụng tạm thời, cập nhật tiện ích sẽ xóa cài đặt."
}
}

View File

@ -1,7 +1,7 @@
ext {
extName = 'XXManhwa'
extClass = '.XxManhwa'
extVersionCode = 5
extVersionCode = 6
isNsfw = true
}

View File

@ -1,6 +1,8 @@
package eu.kanade.tachiyomi.extension.vi.xxmanhwa
import android.app.Application
import android.widget.Toast
import androidx.preference.EditTextPreference
import androidx.preference.PreferenceScreen
import androidx.preference.SwitchPreferenceCompat
import eu.kanade.tachiyomi.network.GET
@ -31,7 +33,9 @@ class XxManhwa : ParsedHttpSource(), ConfigurableSource {
override val lang = "vi"
override val baseUrl = "https://google.xxmanhwa2.top"
private val defaultBaseUrl = "https://google.xxmanhwa2.top"
override val baseUrl by lazy { getPrefBaseUrl() }
override val supportsLatest = false
@ -187,6 +191,17 @@ class XxManhwa : ParsedHttpSource(), ConfigurableSource {
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException()
init {
preferences.getString(DEFAULT_BASE_URL_PREF, null).let { prefDefaultBaseUrl ->
if (prefDefaultBaseUrl != defaultBaseUrl) {
preferences.edit()
.putString(BASE_URL_PREF, defaultBaseUrl)
.putString(DEFAULT_BASE_URL_PREF, defaultBaseUrl)
.apply()
}
}
}
override fun setupPreferenceScreen(screen: PreferenceScreen) {
SwitchPreferenceCompat(screen.context).apply {
key = KEY_HIDE_PAID_CHAPTERS
@ -194,15 +209,37 @@ class XxManhwa : ParsedHttpSource(), ConfigurableSource {
summary = "Ẩn các chương truyện cần nạp VIP để đọc.\n$baseUrl/thong-tin-cap-bac-tai-khoan"
setDefaultValue(false)
}.let(screen::addPreference)
EditTextPreference(screen.context).apply {
key = BASE_URL_PREF
title = BASE_URL_PREF_TITLE
summary = BASE_URL_PREF_SUMMARY
setDefaultValue(defaultBaseUrl)
dialogTitle = BASE_URL_PREF_TITLE
dialogMessage = "Default: $defaultBaseUrl"
setOnPreferenceChangeListener { _, _ ->
Toast.makeText(screen.context, RESTART_APP, Toast.LENGTH_LONG).show()
true
}
}.let(screen::addPreference)
}
private inline fun <reified T> String.parseAs(): T = json.decodeFromString(this)
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, defaultBaseUrl)!!
companion object {
private const val KEY_HIDE_PAID_CHAPTERS = "hidePaidChapters"
// The website generates this by creating a canvas, doing some funny things to it, and then
// gets the SHA256 of the canvas' data URI. Pretty much a static string until the site updates.
private const val WP_NONCE = "e732af2390628a21d8b7500e621b1493c28d9330b415e88f27b8b4e2f9a440a3"
private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl"
private const val RESTART_APP = "Khởi chạy lại ứng dụng để áp dụng thay đổi."
private const val BASE_URL_PREF_TITLE = "Ghi đè URL cơ sở"
private const val BASE_URL_PREF = "overrideBaseUrl"
private const val BASE_URL_PREF_SUMMARY =
"Dành cho sử dụng tạm thời, cập nhật tiện ích sẽ xóa cài đặt."
}
}